akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<climits>
#include<cmath>
#include<stdio.h>
#include<fstream>
#include<numeric>

int main(){
	long long int W,H,x,y;

	std::cin >> W >> H >> x >> y;

	if(x*2==W) std::cout << x*H << " ";
	else{
		std::cout << W/2.0*H << " ";
	}

	if(x*2==W&&y*2==H) std::cout << 1 << std::endl;
	else std::cout << 0 << std::endl;

	return 0;
}


Measured memory_bytes: 256
#[allow(dead_code)]
fn scan<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn scan_split<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|t| t.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn scan_split_with<T: std::str::FromStr>(ch: char) -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split(ch)
        .map(|t| t.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn scan_lines<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| scan::<T>()).collect()
}

#[allow(unused_macros)]
macro_rules! scan_as_tuple {
    ( $t:ty ) => {
        (scan::<$t>(),)
    };
    ( $( $t:ty ),* ) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok();
            let v = s.trim().split_whitespace();
            let mut it = v;
            let ret = ( $(it.next().unwrap().parse::<$t>().ok().unwrap()),* );
            assert!(it.next() == None, "not all tokens consumed");
            ret
        }
    };
}

fn main() {
    let (_, x, _) = scan_as_tuple![String, String, String];
    println!("A{}C", x.chars().nth(0).unwrap());
}

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

static const int MMAX=20;
static const int NMAX=50000;
static const int INFTY=(1<<29);
int main(void){
    int n,m;
    int C[21];
    int T[NMAX+1];
    
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>C[i];
    }
    for(int i=0;i<=NMAX;i++){
        T[i]=INFTY;
    }
    T[0]=0;
    for(int i=1;i<=m;i++){
        for(int j=0;j+C[i]<=n;j++){
            T[j+C[i]]=min(T[j+C[i]],T[j]+1);
        }
    }
    cout<<T[n]<<endl;
    
    return 0;
}



Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;


ll i;


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


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

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

    string S;
    cin >> S;
    int N = S.size();
    vector<int> A(N + 1, 0);

    for (int i = 0; i < N; ++i) {
        if (S.at(i) == '<') {
            A.at(i + 1) = A.at(i) + 1;
        }
    }
    for (int i = N - 1; i >= 0; --i) {
        if (S.at(i) == '>') {
            A.at(i) = max(A.at(i), A.at(i + 1) + 1);
        }
    }

    ll ans = 0;
    for (auto &x : A) {
        ans += x;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2844
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef int_fast64_t ll;
typedef int_fast32_t intt;
typedef int_fast32_t tmp_m;
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, a, b) for (tmp_m i = a; i < b; ++i)
#define repp(i, a, b) for (tmp_m i = a; i >= b; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& b) const {
    if (dst != b.dst) return dst > b.dst;
    if (x != b.x) return x > b.x;
    return y > b.y;
  }
};

struct point {
  intt x;
  intt y;
  point() {}
  point(intt x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& b) const {
    if (x != b.x) return x > b.x;
    return y > b.y;
  }
};

inline bool spoint(point a, point b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}

inline bool spr(pr a, pr b) {
  if (a.dst != b.dst) return a.dst < b.dst;
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}

intt arr[200005];

void solve() {
  intt n;
  cin >> n;
  rep(i, 0, n - 1){
    intt a;
    cin >> a;
    ++arr[a];
  }
  rep(i, 1, n + 1){
    cout << arr[i] << endl;
  }
}

void init() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  // memset(dp, -1, sizeof dp);
}

int main() {
  init();
  solve();
  return 0;
}


Measured memory_bytes: 5164
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<HashMap<Integer, Integer>> graph = new ArrayList<>();
		for (int i = 0; i < n; i++) {
		    graph.add(new HashMap<>());
		}
		for (int i = 0; i < m; i++) {
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int c = sc.nextInt();
		    graph.get(a).put(b, c);
		}
		PriorityQueue<Path> queue = new PriorityQueue<>();
		int[][] costs = new int[n][n];
		for (int[] arr : costs) {
		    Arrays.fill(arr, Integer.MAX_VALUE);
		}
		for (int i = 0; i < n; i++) {
    		queue.add(new Path(i, 0));
 		    int[] counts = new int[n];
   		    while (queue.size() > 0) {
    		    Path p = queue.poll();
    		    if (costs[i][p.idx] <= p.value) {
    		        continue;
    		    }
    		    counts[p.idx]++;
    		    if (counts[p.idx] > n + 1) {
    		        System.out.println("NEGATIVE CYCLE");
    		        return;
    		    }
    		    costs[i][p.idx] = p.value;
    		    for (Map.Entry<Integer, Integer> entry : graph.get(p.idx).entrySet()) {
    		        queue.add(new Path(entry.getKey(), p.value + entry.getValue()));
    		    }
    		}
		}
		StringBuilder sb = new StringBuilder();
		for (int[] arr : costs) {
		    for (int i = 0; i < arr.length; i++) {
		        if (i > 0) {
		            sb.append(" ");
		        }
		        if (arr[i] == Integer.MAX_VALUE) {
		            sb.append("INF");
		        } else {
		            sb.append(arr[i]);
		        }
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
	}
	
	static class Path implements Comparable<Path> {
	    int idx;
	    int value;
	    
	    public Path(int idx, int value) {
	        this.idx = idx;
	        this.value = value;
	    }
	    
	    public int compareTo(Path another) {
	        return value - another.value;
	    }
	}
}



Measured memory_bytes: 68908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll mo = 1000000007;
const ll INF = 1LL << 62; //MAX 9223372036854775807
int main()
{
ll n , a , b ;
cin >> n >> a >> b ;
if(a>b)swap(a,b);
vector<ll> s(n+1);
s[0]=-1LL*INF;
rep(i, n){
  cin >> s[i+1];
}
rep(i,n-1){
  if(s[i+2]-s[i]<a){
    cout << 0 << endl;
    return 0;
  }
}
vector<ll> v(n+1);
ll sum=1,st=0,en=1;
v[0]=1;v[1]=1;
for(ll i=2;i<=n;i++){
  while(s[en]<=s[i]-b){
    sum+=v[en];
    sum%=mo;
    en++;
  }
  v[i]=sum;
  if(s[i-1]>s[i]-a){
    while(1){
      if(st!=en){
        sum-=v[st];
        sum%=mo;
      }
      v[st]=0;
      st++;
      if(st>en)en++;
      if(st==i-1)break;
    }
  }
}
for(auto an:v)ans=(ans+an+mo)%mo;;
cout << ans << endl;
return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,k;
	cin>>a>>b>>k;
	if(k==0)
	{
		cout<<a<<' '<<b<<endl;
		return 0;
	}
    if(k>a)
    {
    	k=k-a;
    	a=a-a;
    }
    else
    {
    	a=a-k;
    	cout<<a<<' '<<b<<endl;
    	return 0;
    }
    if(k>b)
    {
    	cout<<0<<' '<<0<<endl;
    	return 0;
    }
    else
    {
    	b=b-k;
    	cout<<a<<' '<<b<<endl;
    	return 0;
    }
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
    vector<PLL> arr;
    fr(i,0,n)
    {
        ll x,y;
        cin>>x>>y;
        arr.pb({x+y,x-y});
    }
    sort(ALL(arr));
    ll last=-inf;
    ll ans=0;
    fr(i,0,n)
    {
        if(arr[i].S>=last)
        {
            ans++;
            last=arr[i].F;
        }
    }
    cout<<ans<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 5288
#include <iostream>

using namespace std;

int sod(int a) {
  int ans = a % 10;
  while (a /= 10) ans += (a % 10);
  return ans;
}

int main() {
  int a;
  cin >> a;
  if (a % sod(a) == 0) cout << "Yes";
  else cout << "No";
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
// Math = ♥️

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
// #define ordered_set                            \
//     tree<ll, null_type, less<ll>, rb_tree_tag, \
//          tree_order_statistics_node_update>
const ll MOD = 998244353;

inline ll mult(ll a, ll b) {
    return (a * b) % MOD;
}

inline ll sum(ll a, ll b) {
    return (a + b) % MOD;
}

ll a, b, c, d;
ll dp[3005][3005][2];

ll solve(ll x, ll y, ll u) {
    if (x == c && y == d) {
        return 1;
    } else if (x > c || y > d) {
        return 0;
    }

    if (dp[x][y][u] == -1) {
        if (u == 0) {
            dp[x][y][u] =
                sum(mult(solve(x, y + 1, 0), x), mult(solve(x + 1, y, 1), y));
        } else {
            dp[x][y][u] = sum(mult(solve(x + 1, y, 1), y), solve(x, y + 1, 0));
        }
    }
    return dp[x][y][u];
}

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    memset(dp, -1, sizeof(dp));
    cin >> a >> b >> c >> d;

    cout << solve(a, b, 0) << "\n";
}


Measured memory_bytes: 145096
import java.io.*;
public class Main{
    public static void main(String args[]){
    try{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        double S = Double.parseDouble(str);
        int h = (int)Math.floor(S / 3600);
        int m = (int)Math.floor((S % 3600) / 60);
        int s = (int)Math.floor((S % 3600) % 60);
        System.out.println(h + ":" + m + ":" + s);

    }catch(IOException e){
        e.printStackTrace();
    }
    }
}

Measured memory_bytes: 24396
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <complex>
#include <iomanip>
#include <random>

using namespace std;

typedef long long ll;
#define int long long

int M = 998244353;
#define msum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define msub(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define mmult(a, b) (((a) * (b)) % M)

typedef long double ld;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vlll;
typedef vector<double> vd;
typedef vector<vd> vdd;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpi;
#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SZ(a) ((int)(a).size())
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);
const int oo = 1e18 + 100;
const string DIGITS = "0123456789", alph = "abcdefghijklmnopqrstuvwxyz", ALPH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

//THE END OF TEMPLATE////////////////////////////////////////////////////////////////////////////////

#define N 5000

int dp[N][N], nw[N][N];


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

	string s, t, ans;
	cin >> s >> t;

	for (int i = 1; i <= s.size(); i++)
	{
		for (int j = 1; j <= t.size(); j++)
		{
			dp[i][j] = dp[i - 1][j];
			nw[i][j] = 3;
			if (dp[i][j - 1] > dp[i][j])
			{
				dp[i][j] = dp[i][j - 1];
				nw[i][j] = 1;
			}
			if (dp[i - 1][j - 1] + (s[i - 1] == t[j - 1]) > dp[i][j])
			{
				dp[i][j] = dp[i - 1][j - 1] + (s[i - 1] == t[j - 1]);
				nw[i][j] = 2;
			}		
		}
	}

	int n = s.size(), m = t.size();

	while (nw[n][m] != 0)
	{
		if (nw[n][m] == 2) {
			ans += s[n - 1];
			n--;
			m--;
		}
		else if (nw[n][m] == 1) {
			m--;
		}
		else if (nw[n][m] == 3) {
			n--;
		}
	}

	reverse(ALL(ans));
	cout << ans;

}

//m1.codeforces.com, m2.codeforces.com или m3.codeforces.com

Measured memory_bytes: 237184
// segment tree (abstract version)

#include <bits/stdc++.h>

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

using namespace std;

template<class T>
class add_monoid{
	T a;
public:
	add_monoid(const T& val=T()):a(val){}
	static add_monoid unit(){ return add_monoid(); }
	add_monoid operator*(const add_monoid& x)const{
		return a+x.a;
	}
	T& get(){ return a; }
};

template<class T>
class sequence_monoid{
	vector<T> a;
public:
	sequence_monoid(){}
	sequence_monoid(const T& val):a(1,val){}
	sequence_monoid(const vector<T>& x):a(x){
		sort(a.begin(),a.end());
	}
	static sequence_monoid unit(){ return sequence_monoid(); }
	sequence_monoid operator*(const sequence_monoid& x)const{
		vector<T> res;
		merge(a.begin(),a.end(),x.a.begin(),x.a.end(),back_inserter(res));
		return res;
	}
	int lower_bound(const T& val)const{
		return std::lower_bound(a.begin(),a.end(),val)-a.begin();
	}
};

template<class M>
class segment_tree{
	int sz;
	vector<M> seg;
public:
	segment_tree(){}
	segment_tree(int n){ build(n); }
	segment_tree(const vector<M>& a){ build(a); }
	void build(int n){
		for(sz=1;sz<n;sz<<=1);
		seg.assign(2*sz,M::unit());
	}
	void build(const vector<M>& a){
		int n=a.size();
		build(n);
		rep(i,n) seg[sz+i]=a[i];
		for(int i=sz-1;i>0;i--){
			seg[i]=seg[2*i]*seg[2*i+1];
		}
	}
	template<class N,class F>
	N query(int l,int r,const F& f){
		N lcum=N::unit(),rcum=N::unit();
		for(int a=l+sz,b=r+sz;a<b;a>>=1,b>>=1){
			if(a&1) lcum=lcum*f(seg[a++]);
			if(b&1) rcum=f(seg[--b])*rcum;
		}
		return lcum*rcum;
	}
};

int main(){
	int n,q; scanf("%d%d",&n,&q);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]), a[i]--;

	vector<sequence_monoid<int>> x(n);
	vector<int> pre(n,-1);
	rep(i,n){
		x[i]=pre[a[i]];
		pre[a[i]]=i;
	}

	segment_tree<sequence_monoid<int>> S(x);
	rep(_,q){
		int l,r; scanf("%d%d",&l,&r); l--;
		auto ans=S.query<add_monoid<int>>(l,r,[&](const sequence_monoid<int>& x)->add_monoid<int>{
			return x.lower_bound(l);
		});
		printf("%d\n",ans.get());
	}

	return 0;
}


Measured memory_bytes: 125664
#include<stdio.h>
#include<string.h>

char t[10000];
char ans[100];
int p,len;
int i,n;

int main(){
  scanf("%d",&n);
  while(n>0){
    n--;
    for(i=0;i<100;i++)ans[i]=' ';
    
    scanf("%s",t);
    len=strlen(t);
    
    p=50;
    ans[p]=t[0];
    for(i=3;i<len;i+=3){
      if(t[i-1]=='>')p++;
      else p--;
      ans[p]=t[i];
    }
    
    for(i=0;i<100;i++)
      if(ans[i]!=' ')
        printf("%c",ans[i]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 996
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
char a;
int32_t main(){
CODE_START;
cin>>n;
for(ll i=0;i<n;i++)
{
    cin>>a;
    if(a=='Y'){
        rc("Four");
    }
}
cout<<"Three";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> a(n+1, 0);
  for(int i = 1; i <= n; i++){
    cin >> a[i];
    a[i] += a[i-1];
  }
  map<long long, long long> cnt;
  for(int i = 0; i <= n; i++){
    cnt[a[i]]++;
  }
  long long ans = 0;
  for(auto p : cnt){
    ans += p.second * (p.second-1) / 2;
  }
  cout << ans << endl;
  return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
string to_str(ll x){string res; while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return res;}
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; }
//template end



int main(){
    ll a,b; scanf("%lld%lld",&a,&b);
    ll g=__gcd(a,b),ans=a/g;
    ans*=b; printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 5005;
int vis[MAXN];
int a[MAXN];
int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(0);
//    cout.tie(0);

    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int l = n - 1;
    int s = 0;
    while(a[l] >= k) { vis[l] = 1; l--; }
    int st = l;
    while(l >= 0)
    {
        s += a[l];
        if(s >= k)
        {
            for(int i = l; i <= st; i++) vis[i] = 1;
            s -= a[l];
            st = l;
        }
        l--;
        if(s < k && l < 0)
        {
            if(st != -1)
            {
                l = st; s = 0; st = -1;
            }
        }
    }
    int cnt = 0;
    for(int i = 0; i < n; i++) if(!vis[i]) cnt++;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define rep(i,n) for(i=0;i<n;i++)
#define PI 3.14159265358979323846264338327950L
int gcd(int a,int b){//Greatest Common Divisor(最大公約数)
    if(a<b){
        int tmp=a;
        a=b;
        b=tmp;
    }
    while (b!=0){
        int r=a%b;
            a=b;
            b=r;
    }
    return a;
}
int main(){
    int a,b,c,k,num,ans=0;
    scanf("%d",&k);
    for(a=1;a<=k;a++){
        for(b=1;b<=k;b++){
            for(c=1;c<=k;c++){
                num=gcd(gcd(a,b),c);
                ans=ans+num;
            }
        }
    }
    printf("%d",ans);
    return 0;
}

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

#define ll long long
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define pii pair<int, int>

using namespace std;

int solve();

#define TASK ""

int main()
{
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // DEBUG
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

int solve()
{
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
}




Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

N = int(readline())
A = [int(readline()) for i in range(N)]

ans = 0
for i in range(N):
  pair, mod = divmod(A[i],2)
  ans += pair
  if mod:
    if i + 1 < N and A[i + 1] > 0:
      ans += 1
      A[i + 1] -= 1
  
print(ans)


Measured memory_bytes: 7072
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    int N;
    cin >> N;
    if (N % 2 == 0) {
        cout << N/2 - 1 << endl;
    } else {
        cout << N/2 << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define em3 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define EPS 1e-6
#define endl '\n'
long long mod = 1e9 + 7;
const int N = 1e5 + 5;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double pi = acos(-1);
typedef complex <double> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
ll n , k , arr[N] , ans = 1e18;
int main()
{
    em3
    cin >> n >> k;
    for(int i = 0 ; i < n ; i++)
        cin >> arr[i];
    sort(arr , arr + n);
    for(int i = 0 ; i < n ; i++)
        {
            if(i + k - 1 < n)
                ans = min(ans , arr[i + k - 1] - arr[i]);
        ///cout << arr[i + k - 1] - arr[i] << endl;
        }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int q, n;
  cin >> q >> n;
  vector<vector<int>> wt(n + 1, vector<int>(n + 1, 0));
  for (int _ = 0; _ < q; _++) {
    int i, j;
    cin >> i >> j;
    i %= 2 * n;
    j %= 2 * n;
    int par = 0;
    if (i >= n) {
      i -= n;
      par ^= 1;
    }
    if (j >= n) {
      j -= n;
      par ^= 1;
    }
    char clr;
    cin >> clr;
    par ^= (clr == 'W');
    i++;
    j++;
    if (!par) {
      wt[i][j]++;
    } else {
      wt[i][j]--;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      wt[i][j] += wt[i - 1][j] + wt[i][j - 1] - wt[i - 1][j - 1];
    }
  }
  int ans = 0;
  for (int di = 0; di < n; di++) {
    for (int dj = 0; dj < n; dj++) {
      int tmp = wt[n][n] -2 * wt[n][dj] - 2 * wt[di][n] + 4 * wt[di][dj];
      ans = max(ans, abs(tmp));
    }
  }
  ans = (ans + q) / 2;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4224
#!/usr/bin/env python3
import sys
import math
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(N: int, a: "List[int]"):
    odd, even, eveven = 0, 0, 0
    for av in a:
        b = int(math.log2(av & -av))
        if b == 0:
            odd += 1
        elif b == 1:
            even += 1
        else:
            eveven += 1
    if odd > int(math.ceil(N/2)):
        no()
    elif even > 0 and odd > eveven:
        no()
    elif even == 0 and odd <= eveven:
        yes()
    else:
        yes()

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15356
n, m = gets.split.map(&:to_i)
abs = Hash.new { |h, k| h[k] = [] }
m.times do
  a, b = gets.split.map(&:to_i)
  abs[a] << b
end

# puts(abs: abs)
l = abs.select { |_, v| v.include?(n) }.keys

puts (abs[1] & l).empty? ? "IMPOSSIBLE" : "POSSIBLE"


Measured memory_bytes: 29820
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  vector<int> A = {1,3,5,7,8,10,12};
  vector<int> B = {4,6,9,11};
  vector<int> C = {2};
  bool ok = false;
  for(int i=0;i<7;i++){
    if(x==A.at(i)){
      for(int j=0;j<7;j++){
        if(y==A.at(j)){
          ok = true;
        }
      }
    }
  }
  for(int i=0;i<4;i++){
    if(x==B.at(i)){
      for(int j=0;j<4;j++){
        if(y==B.at(j)){
          ok = true;
        }
      }
    }
  }
  if(ok){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/11  Problem: ABC 086 A / Link: http://abc086.contest.atcoder.jp/tasks/abc086_a  ----- */


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


	LL A, B; cin >> A >> B;
	LL ans = A*B;
	
	
	cout << (ans&1?"Odd":"Even") << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int arr[n+1];
  for(int i=1;i<=n;i++)
    cin>>arr[i];
  int dp[n+1];
  dp[1]=0;
  dp[2]=abs(arr[2]-arr[1]);
  for(int i=3;i<=n;i++)
    dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
  cout<<dp[n]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <cassert>

using namespace std;

const int MAXN = 1000 + 10;
const long long MOD = 1000000007;

int N;
char S[2][MAXN];
long long dp[MAXN][3][3];

void Work()
{
	scanf("%d", &N);
	scanf("%s%s", S[0], S[1]);

	if (S[0][0] == S[1][0])
	{
		dp[0][0][0] = dp[0][1][1] = dp[0][2][2] = 1;
	}
	else
	{
		dp[0][0][1] = dp[0][0][2] = 
		dp[0][1][0] = dp[0][1][2] = 
		dp[0][2][0] = dp[0][2][1] = 1;
	}

	for (int i = 1; i < N; i ++)
	{
		if (S[0][i] == S[1][i])
		{
			for (int a = 0; a < 3; a ++)
				for (int p = 0; p < 3; p ++)
					for (int q = 0; q < 3; q ++)
					{
						if (p != a && q != a)
							dp[i][a][a] = (dp[i][a][a] + dp[i - 1][p][q]) % MOD;
					}
		}
		else
		{
			for (int a = 0; a < 3; a ++)
				for (int b = 0; b < 3; b ++)
					if (a != b)
					{
						for (int p = 0; p < 3; p ++)
							for (int q = 0; q < 3; q ++)
							{
								if (S[0][i] == S[0][i - 1] && a != p) continue;
								if (S[0][i] != S[0][i - 1] && a == p) continue;
								if (S[1][i] == S[1][i - 1] && b != q) continue;
								if (S[1][i] != S[1][i - 1] && b == q) continue;
								dp[i][a][b] = (dp[i][a][b] + dp[i - 1][p][q]) % MOD;
							}
					}
		}
			
	}

	long long ans = 0;
	for (int i = 0; i < 3; i ++)
		for (int j = 0; j < 3; j ++)
			ans += dp[N - 1][i][j];
	printf("%d\n", (int) (ans % MOD));
}

int main()
{
	Work();
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int main()
{
	long long int n, a, b;
	while (scanf("%lld %lld %lld", &n, &a, &b) != EOF) {
		if (a > b) printf("0");
		else if (n == 1 && a != b) printf("0");
		else if (n == 1 && a == b) printf("1");
		else {
			long long int max = b * (n - 1) + a;
			long long int min = a * (n - 1) + b;
			printf("%lld", (long long)max - min + 1);
		}
	}
	return 0;
}

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

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

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> w;
  REP(i, n)
  {
    int cw;
    cin >> cw;
    w.push_back(cw);
  }

  int csum = 0, sum = 0, mind;
  REP(i, n)
  {
    sum += w[i];
  }

  mind = sum;

  REP(i, n)
  {
    csum += w[i];
    mind = min(mind, abs(2 * csum - sum));
  }

  cout << mind << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //標準入出力
#include <fstream>  //ファイルでの入出力
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <utility> //pair
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define MOD 1000000007
#define pair(a) pair<a,a>

void _main(){
    ll n,a,b; cin >> n>>a>>b;
    ll out;
    if((b-a)%2==0) out = (b-a)/2;
    else {
        ll tillw;
        if(b-1 > n-a) tillw = n-b;
        else tillw = a-1;
        out = tillw+1+(b-a-1)/2;
    }
    
    cout << out <<endl;
    return;
}
int main() {
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

#define MAX(X,Y) ((X)>(Y)?(X):(Y))


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

Measured memory_bytes: 128
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
    int a,b;
    cin>>a>>b;
    int sum=a-1,cnt=1;
    if(b==1) {
        cout<<0<<endl;
        return 0;
    }
    while(sum<b-1){
        sum+=a-1;
        cnt++;
    }
    cout<<cnt<<endl;
    

}



Measured memory_bytes: 256
//memset(dp,sizeof,-1);
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define sz size()
#define FORN(i,j,n) for(int i=j; i<(int)n;i++) 
#define FOR(i,n) FORN(i,0,n)
#define FORIT(i,x) for( auto i = x.begin() ; i != x.end() ; i++ )
#define MOD 998244353LL
#define LIM 262150
#define ones(x) __builtin_popcount(x)
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
using namespace std;
 
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;
ll n,w;
ll dp[105][100005];
ll weigh[100005];
ll cost[100005];
int main() {
	fastio;
	cin>> n >> w;
	FORN(i,1,n+1) cin>> weigh[i] >> cost[i];
	FOR(i,n+1){
		FOR(j,w+1){
			dp[i][j] = -1;
		}
    }
    FOR(i,n+1){
		FOR(j,w+1){
		    if(i == 0| j == 0){ dp[i][j] = 0; continue; }
			if(j >= weigh[i]) dp[i][j] = max(dp[i-1][j-weigh[i]]+cost[i],dp[i-1][j]);
			else dp[i][j] = dp[i-1][j];
		}
	}
    cout<< dp[n][w] << '\n';	
	return 0;
}


Measured memory_bytes: 82444
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = sorted([list(map(int, input().split())) for i in range(M)], key=lambda x: x[1], reverse=True)

if N == 1:
    print(max(A[0], BC[0][1]))
    quit()

heapq.heapify(A)
for b, c in BC:
    a = A[0]
    if a >= c:
        continue
    else:
        curPopped = 0
        while curPopped < b:
            a = heapq.heappop(A)
            if a >= c:
                heapq.heappush(A, a)
                break
            curPopped += 1
        for i in range(curPopped):
            heapq.heappush(A, c)

print(sum(A))
"""
import bisect
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
BC = [list(map(int, input().split())) for i in range(M)]

if N == 1:
    print(max(A[0], BC[0][1]))
    quit()

for b, c in BC:
    a = A[0]
    if a >= c:
        continue
    else:
        l = bisect.bisect_left(A, c)
        print(l)
        l = min(b, l)
        A = A[l:] + [c] * l
        print(l, A)

print(sum(A))
"""

Measured memory_bytes: 103832
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

ab.sort(key=lambda x: x[1])

bridge_i = 0
cnt = 0
for i in range(m):
    if ab[i][0] > bridge_i:
        bridge_i = ab[i][1] - 1
        cnt += 1

print(cnt)


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

int main(){
  float a,b,c,d,e,f;
  float x,y;
  while(cin >> a >> b >> c >> d >> e >> f){
    y = (c*d-a*f) / (b*d-a*e);
    x = (c - b*y) /a;
    printf("%.3f %.3f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 1232
N = int(input())
S = ["" for i in range(N)]
dict1 = {}
names =[]
for i in range(N):
    S[i] = input()

for i in range(N):
    if not (S[i] in dict1.keys()):
        names.append(S[i])
        dict1.update({S[i]:1})
    else:
        dict1[S[i]] +=1
maxv = 0
for i in range(len(names)):
    if maxv < dict1[names[i]]:
        maxv = dict1[names[i]]

winners = []

for i in range(len(names)):
    if dict1[names[i]] == maxv:
        winners.append(names[i])

winners.sort()
for i in range(len(winners)):
    print(winners[i])


Measured memory_bytes: 36404
#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()
typedef long long lint;
 
int main() {
  int s,w;
  cin >> s >> w;
  
  if(w>=s)cout << "unsafe" << endl;
  else cout << "safe" << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    vector<vector<int>> A(2, vector<int>(N));
    vector<int> up(N), down(N);
    for(int i = 0; i < 2; i++) for(int j = 0; j < N; j++) {
        cin >> A[i][j];
        if(i == 0) {
            if(j == 0) up[j] = A[i][j];
            else up[j] = up[j - 1] + A[i][j];
        }
        else {
            if(j == 0) down[j] = A[i][j];
            else down[j] = down[j - 1] + A[i][j];
        }
    }
    int ans = up[0] + down[N - 1];
    for(int i = 1; i < N; i++) {
        ans = max(ans, up[i] + down[N - 1] - down[i - 1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
import std.stdio, std.string, std.array, std.conv;

void main() {
    long[] tmp = readln.chomp.split.to!(long[]);
    long a = tmp[0], b = tmp[1];
    long m = a & b, n = a | b, l = a ^ b;
    int[] x = new int[32];
    int[] y = new int[32];
    int[] z = new int[32];
    foreach_reverse (i; 0 .. 32) {
        x[i] = m & 1;
        m /= 2;
        y[i] = n & 1;
        n /= 2;
        z[i] = l & 1;
        l /= 2;
    }
    x.to!(string[]).join.writeln;
    y.to!(string[]).join.writeln;
    z.to!(string[]).join.writeln;
}


Measured memory_bytes: 2492
import sys
sys.setrecursionlimit(10 ** 6)


def main():
    N = int(input())

    abc = []
    for _ in range(N-1):
        a, b, c = map(int, input().split())
        abc.append((a, b, c))

    Q, K = map(int, input().split())
    xy = []
    for _ in range(Q):
        x, y = map(int, input().split())
        xy.append((x, y))

    ans = ref_pypy(N, abc, Q, K, xy)
    print(*ans, sep="\n")


def ref_pypy(N, abc, Q, K, xy):
    """https://atcoder.jp/contests/abc070/submissions/5331379"""
    L = [-1 for i in range(N+1)]
    L[K] = 0
    n = [[] for i in range(N+1)]
    for a, b, c in abc:
        n[a].append([b, c])
        n[b].append([a, c])

    def dfs(x):
        for i in n[x]:
            if L[i[0]] == -1:
                L[i[0]] = L[x]+i[1]
                dfs(i[0])

    dfs(K)

    ans = []
    for x, y in xy:
        ans.append(L[x] + L[y])

    return ans


if __name__ == "__main__":
    main()


Measured memory_bytes: 225952
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);

        int n = stdIn.nextInt();
        int x = stdIn.nextInt();
        int[] l = new int[n];
        for(int i=0; i<n; i++){
            l[i] = stdIn.nextInt();
        }
        int counter = 1;
        long zahyou = 0;
        for(int i=0; i<n; i++){
            zahyou += l[i];
            if(x<zahyou){
                break;
            }else{
                counter++;
            }
        }
        System.out.println(counter);
    }
}


Measured memory_bytes: 22740
import std.c.stdio;
import std.c.string;

const int MOD = 100000;

const int MAX_H = 105;
const int MAX_W = 105;

int H, W;

int dp[MAX_H][MAX_W][4];

int main()
{
	while (true)
	{
		scanf("%d", &W);
		scanf("%d", &H);

		if (W == 0 && H == 0) { break; }

		for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { dp[i][j] = 0; } }

		for (int i = 0; i < H; i++)
			dp[i][0][2] = 1;

		for (int j = 0; j < W; j++)
			dp[0][j][3] = 1;

		for (int i = 1; i < H; i++)
		{
			for (int j = 1; j < W; j++)
			{
				dp[i][j][0] = dp[i - 1][j][3];
				dp[i][j][1] = dp[i][j - 1][2];
				
				for (int k = i - 1; k >= 1; k--)
				{
					dp[i][j][2] += dp[k][j][0];
				}

				dp[i][j][2] %= MOD;

				for (int k = j - 1; k >= 1; k--)
				{
					dp[i][j][3] += dp[i][k][1];
				}

				dp[i][j][3] %= MOD;
			}
		}

		printf("%d\n", (dp[H - 1][W - 1][0] + dp[H - 1][W - 1][1] + dp[H - 1][W - 1][2] + dp[H - 1][W - 1][3]) % MOD);
	}

	return 0;
}

Measured memory_bytes: 2372
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
        int a,b,n,x;
        cin>>a>>b;
        if((a+b)%2==0)
        cout<<(a+b)/2<<endl;
        else
            cout<<(a+b)/2+1<<endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
s=str(input())
a=[]
now=1
ans=2*k
for i in range(1,n):
  if s[i]==s[i-1]:
    now+=1
  else:
    ans+=now-1
    now=1
ans+=now-1
if ans>n-1:
  print(n-1)
else:
  print(ans)

Measured memory_bytes: 3316
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = input[0];
            int B = input[1];

            if (A == 1)
            {
                A = 14;
            }
            if(B == 1)
            {
                B = 14;
            }

            if (A > B)
            {
                Console.WriteLine("Alice");
            }
            else if (A == B)
            {
                Console.WriteLine("Draw");
            }
            else
            {
                Console.WriteLine("Bob");
            }
        }
    }
}

Measured memory_bytes: 11092
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();
        var a = s[0];
        var b = s[2];

        if (a == 'H')
        {
            Console.WriteLine(b);
        }
        else
        {
            Console.WriteLine(b == 'H' ? 'D' : 'H');
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

const int MOD = 1000000007;
struct mint {
    int64 x;
    mint(const int64 x1=0) { x = x1%MOD; };

    mint& operator++(int n) { x+=1; return *this; };
    mint& operator--(int n) { x-=1; return *this; };
    mint& operator=(int64 n) { x=n%MOD; return *this; };
    mint& operator--() {x-=1; return *this; };
    mint& operator+=(const mint a) { if ( (x+=a.x) >= MOD) x-=MOD; return *this; }
    mint& operator-=(const mint a) { if ( (x+= MOD-a.x) >= MOD) x-= MOD; return *this; }
    mint& operator*=(const mint a) { (x*=a.x) %= MOD; return *this; }
    mint& operator/=(const mint a) { return (*this) *= a.inv();}
    mint operator+(const mint a) const { mint res(*this); return res+=a; }
    mint operator-(const mint a) const { mint res(*this); return res-=a; }
    mint operator*(const mint a) const { mint res(*this); return res*=a; }
    mint operator/(const mint a) const { mint res(*this); return res/=a; }
    mint inv() const { return pow(MOD-2);}
    friend ostream& operator<<(ostream &os, const mint a) noexcept { return os << a.x; }
    constexpr bool operator == (const mint& r) const noexcept { return this->x == r.x; }
    constexpr bool operator != (const mint& r) const noexcept { return this->x != r.x; }
    mint pow(long long t) const {
        if (!t) return mint(1);
        mint a = pow(t>>1);
        a*=a;
        if(t&1) a*= *this;
        return a;
    }
};

struct combination {
    vector<mint> fact, ifact;

    // コンストラクタ
    combination(int n):fact(n+1),ifact(n+1) {
        fact[0] = mint(1);
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*mint(i);
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*mint(i);
    }

    mint nCr(int n, int r) {
        if (r < 0 || r > n) return 0;
        return fact[n]*ifact[r]*ifact[n-r];
    }
    mint nPr(int n, int r) {
        if (r < 0 || r > n) return 0;
        return fact[n]*ifact[n-r];
    }
} comb(5000);

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

    for (int i=1; i<=k; i++) {
       cout << comb.nCr(n-k+1, i) * comb.nCr(k-1,i-1) << endl;
    }
}

Measured memory_bytes: 512
n=int(input())
y=list(map(int,input().split()))

x=sorted(y)
c=n//2

ans1=x[n//2-1]
ans2=x[n//2]

for i in range(n):
  if y[i]>=ans2:
    print(ans1)
  else:
    print(ans2)

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


long long N;
pair<long long, long long> point[200000];
long long mod = 1000000007;

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        long long a;
        cin >> a;
        point[i] = make_pair(a, -1);
    }
    for(int i = 0; i < N; i++){
        long long b;
        cin >> b;
        point[i+N] = make_pair(b, 1);
    }
    sort(point, point+2*N);

    long long ans = 1, in_hand = 0;
    for(int i = 0; i < 2*N; i++){
        long long  coord, kind;
        coord = point[i].first;
        kind = point[i].second;
        if(in_hand * kind < 0){
            ans *= abs(in_hand);
            ans %= mod;
        }
        in_hand += kind;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int A[200000];
	ll goukei = 0;
	rep(i, N) goukei += (A[i] = getint());


	ll kotae = 1e18;
	ll P, Q, R, S;

	int q = 1, s = 3;
	P = A[0];
	Q = A[1];
	R = A[2];
	S = goukei - P - Q - R;
	for (int r = 2; r < N - 1; r++) {
		while (abs(P - Q) > abs(P - Q + 2 * A[q])) {
			P += A[q];
			Q -= A[q];
			q++;
		}
		while (abs(R - S) > abs(R - S + 2 * A[s])) {
			R += A[s];
			S -= A[s];
			s++;
		}

		ll saishou = min(min(P, Q), min(R, S));
		ll saidai = max(max(P, Q), max(R, S));
		kotae = min(kotae, saidai - saishou);

		Q += A[r];
		R -= A[r];
	}

	printf("%lld", kotae);

	Would you please return 0;
}

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

int ans[301][301];

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    string b[301];
    int cur = 1;
    vector<pair<int, int>> p;
    rep(i, H) {
        cin >> b[i];
        rep(j, W) {
            if (b[i][j] == '#') {
                ans[i][j] = cur++;
                p.emplace_back(i, j);
            }
        }
    }

    for (auto t : p) {
        int r = t.first, c = t.second;
        int cur = ans[r][c];
        for (int c2=c-1; c2>=0; --c2) {
            if (ans[r][c2] == 0) {
                ans[r][c2] = cur;
            }
            else break;
        }
        for (int c2=c+1; c2<W; ++c2) {
            if (ans[r][c2] == 0) {
                ans[r][c2] = cur;
            }
            else break;
        }
    }

    rep(r, H) {
        rep(c, W) {
            if (ans[r][c] != 0) {
                int cur = ans[r][c];
                for (int r2=r-1; r2>=0; --r2) {
                    if (ans[r2][c] == 0) {
                        ans[r2][c] = cur;
                    }
                    else break;
                }
                for (int r2=r+1; r2<H; ++r2) {
                    if (ans[r2][c] == 0) {
                        ans[r2][c] = cur;
                    }
                    else break;
                }
            }
        }
    }

    rep(r, H) {
        rep(c, W) {
            if (c) cout << " ";
            cout << ans[r][c];
        }
        cout << endl;
    }
}


Measured memory_bytes: 1944