akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

constexpr int MOD = int(1e9) + 7;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    i64 N;
    read(N);
    vector<i64> a(N), b(N);
    rep(i, N) read(a[i]);
    rep(i, N) read(b[i]);

    vector<pii> r(N), s(N);

    r[0] = pii(a[0], a[0]);
    reps(i, 1, N-1) {
        if (a[i-1] < a[i]) {
            r[i] = pii(a[i], a[i]);
        } else {
            r[i] = pii(1, a[i]);
        }
    }

    s[N-1] = pii(b[N-1], b[N-1]);
    repr(i, N-2, 0) {
        if (b[i] > b[i+1]) {
            s[i] = pii(b[i], b[i]);
        } else {
            s[i] = pii(1, b[i]);
        }
    }
    trace(r);
    trace(s);

    i64 ans = 1;
    rep(i, N) {
        const i64 range = max<i64>(0, min(r[i].second, s[i].second) - max(r[i].first, s[i].first) + 1);
        trace(i, range);
        ans *= range;
        ans %= MOD;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main() {

	string crypted;
	string encrypted;
	
	int len = 0;
	
	while(getline(cin, crypted)){
		len = crypted.size();
		for(int j=0; j<26; j++){
			for(int i=0; i<len; i++){
				if(crypted[i] >= 'a' && crypted[i] <= 'z'){
					crypted[i] =  (crypted[i] - 97 + 1) % 26 + 97;
				}
			}
			if(crypted.find("the", 0) != string::npos || crypted.find("this", 0) != string::npos || crypted.find("that", 0) != string::npos){
				cout << crypted << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n + 1);
  rep(i, n + 1) cin >> a[i];
  if(n == 0) {
    if(a[0] == 1)
      cout << 1 << endl;
    else
      cout << -1 << endl;
    return 0;
  }
  if(a[0] != 0) {
    cout << -1 << endl;
    return 0;
  }
  vector<P> p(n + 1);
  p[n] = P(a[n], a[n]);
  p[0] = P(1, 1);
  for(int i = n - 1; i >= 1; i--) {
    ll bl = p[i + 1].first;
    ll br = p[i + 1].second;
    ll l = (bl + a[i] + 1) / 2;
    ll r = br + a[i];
    p[i] = P(l, r);
  }
  ll ans = 1, now = 1;
  bool ok = true;
  rep2(i, 1, n + 1) {
    ll l = p[i].first;
    ll r = p[i].second;
    if(r < now || now * 2 < l) ok = false;
    now = min(r, now * 2);
    ans += now;
    now -= a[i];
  }
  cout << (ok ? ans : -1) << endl;
}

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


int main(){
    int total,i;
    string str;

    cin>>total>>i>>str;
    i--;
    if(str[i]=='A') str[i]='a';
    else if(str[i]=='B') str[i]='b';
    else str[i]='c';

    cout<<str<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'


signed main() {
  fio();
  int a, b;
  cin >> a;
  int ans = 0;
  for (int i = 1; i < a - i; i++) {
    int b = a - i;
    if (b > 0) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        w: f64,
        h: f64,
        x: f64,
        y: f64,
    }
    println!("{} {}", w * h / 2.0, if (x, y) == (w / 2.0, h / 2.0) { 1 } else { 0 })
}


Measured memory_bytes: 2200
#include<bits/stdc++.h>
    #define F first
    #define S second
    using ll = long long;
    const ll mod = 1000000007;
    const ll infi = 1000000000000000;
    const ll md = 998244353;
    using namespace std;
    using vl = vector<ll>;
    using pll =  pair<ll,ll>;
    
    vector<int> val,ans;
     
    void dfs(vector<int> adj[],int curr,int par,int sum){
        sum+=val[curr];
        ans[curr] = sum;
        for(int i=0;i<adj[curr].size();i++){
            if(adj[curr][i]!=par){
                dfs(adj,adj[curr][i],curr,sum);
            }
        }
    } 
     
    int main() {
        int n,q,u,v;
        cin>>n>>q;
        vector<int> adj[n];
        for(int i=0;i<n-1;i++){
            cin>>u>>v;
            adj[u-1].push_back(v-1);
            adj[v-1].push_back(u-1);
        }
        val.resize(n);ans.resize(n);
        for(int i=0;i<n;i++){
           val[i]=0;
           ans[i]=0;
        }
        int node,up;
        for(int i=0;i<q;i++){
            cin>>node>>up;
            val[node-1]+=up;
        }
        dfs(adj,0,-1,0);
        for(int i=0;i<n;i++) cout<<ans[i]<<" ";
        return 0;
    } 

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

int main(){
 	int H[100],W[100];
  	int k = 0;
  	while(true){
  		cin >> H[k] >> W[k];
      	if((H[k] == 0)&&(W[k] == 0))
          break;
      	k++;
    }
  	for(int l = 0; l < k; l++){
  		for(int i = 0; i < H[l]; i++){
      		for(int j = 0; j < W[l]; j++){
        		if((i == 0)||(i == H[l] - 1))
          			cout << "#";
        		else{
          			if((j == 0)||(j == W[l] - 1))
            			cout << "#";
       	  			else
            			cout << ".";
                }
      		}
      		cout << endl;
    	}
      cout << endl;
    }
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std; 
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define ld long double
#define fi first 
#define se second 
#define mp make_pair
#define pii pair<int ,int > 
#define pb push_back
#define mo 1000000007
 
int main()
{
	ios ; 
int a , b ; cin>>a>>b; 
if(a>=13)
cout<<b; 
else if(a>=6)
cout<<b/2;
else
cout<<0;
	return(0);
	
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <string>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

int main(void) {
  int x;
  scanf("%d", &x);
  int aa = x / 100;
  int bb = x % 100;
  bool yymm = 0 <= aa && aa <= 99 && 1 <= bb && bb <= 12;
  bool mmyy = 0 <= bb && bb <= 99 && 1 <= aa && aa <= 12;
  if(yymm && mmyy) {
    puts("AMBIGUOUS");
  } else if(yymm && !mmyy) {
    puts("YYMM");
  } else if(!yymm && mmyy) {
    puts("MMYY");
  } else {
    puts("NA");
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>

//#define libingzhen
#define space putchar(' ')
#define enter putchar('\n') 
#define MAXN 

using namespace std;

typedef long long int64;

int read() {
	int f = 1,res = 0;
	char ch = getchar();
	while(ch < '0' || ch > '9') {
		if(ch == '-') f *= -1;
		ch = getchar();
	}
	while('0' <= ch && ch <= '9') {
		res = res*10+ch-'0';
		ch = getchar();
	}
	return res*f;
}

void out(int i) {
	if(i < 0) {
		putchar('-');
		i = -i;
	}
	if(i > 9) out(i/10);
	putchar(i%10+'0');
	return;
}

int a,b,c;

void Init() {
	scanf("%d/%d/%d",&a,&b,&c);
}

void Solve() {
	if(a > 2019) {
		puts("TBD");
	}
	else if(a == 2019) {
		if(b > 4) {
			puts("TBD");
		}
		else if(b == 4) {
			if(c > 30) {
				puts("TBD");
			}
			else {
				puts("Heisei");
			}
		}
		else {
			puts("Heisei");
		}
	}
	else {
		puts("Heisei");
	}
}

int main() {
	
#ifdef libingzhen
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif	
	Init();
	Solve();
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int mod = 1_000_000_007;
        int N = sc.nextInt();
        int[] index = new int[200000];
        Arrays.fill(index, -1);
        int before = -1;

        long[] dp = new long[N+1];
        dp[0] = 1;
        for (int i=0;i<N;i++) {
            int C = sc.nextInt()-1;
            if (index[C]==-1) dp[i+1] = dp[i];
            else {
                if (before!=C) dp[i+1] = (dp[i]+dp[index[C]])%mod;
                else dp[i+1] = dp[i];
            }
            before =  C;
            index[C] = i+1;
        }
        System.out.println(dp[N]);
    }
}

Measured memory_bytes: 88492
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;



int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;

	vector<int> x(N), y(M);
	for (int i = 0; i < N; ++i) {
		cin >> x[i];
	}
	for (int i = 0; i < M; ++i) {
		cin >> y[i];
	}

	sort(x.begin(), x.end(), greater<int>());
	sort(y.begin(), y.end());

	if (x[0] < y[0] && X < Y && x[0] < Y && X < y[0]) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,-1,0,1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
    if(a>b){
        a = b; return true;
    }
    else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
    if(a<b){
        a = b; return true;
    }
    else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
    cout << a << " " << b << " " << c << "\n";
}
const ll mod = 1e9 + 7;
//const int mod = 998244353;

struct sum2D{
    vector<vector<ll>> sum;
    ll n,m;
    
    sum2D(vector<vector<ll>> &a){
        n = a.size();
        m = a[0].size();
        sum.resize(n+1);
        rep(i,n+1) sum[i].resize(m+1,0);
        rep(i,n) rep(j,m) sum[i+1][j+1] = a[i][j];
        rep(i,n) rep(j,m+1) sum[i+1][j] += sum[i][j];
        rep(j,m) rep(i,n+1) sum[i][j+1] += sum[i][j];
    }

    ll get(int y1, int x1, int y2, int x2){
        if(y1 > y2 || x1 > x2) return 0;
        y1--; x1--;
        return sum[y2][x2] - sum[y2][x1] - sum[y1][x2] + sum[y1][x1];
    }
};

int main(){
    ll n,m,q; cin >> n >> m >> q;
    vs s(n); rep(i,n) cin >> s[i];
    vvl tmpv(n,vl(m));
    rep(i,n) rep(j,m) tmpv[i][j] = s[i][j] - '0';
    vvl tate(n,vl(m,0)), yoko(n,vl(m,0));
    rep(i,n) rep(j,m){
        if(i < n-1 && tmpv[i][j] == 1 && tmpv[i+1][j] == 1) tate[i][j] = 1;
        if(j < m-1 && tmpv[i][j] == 1 && tmpv[i][j+1] == 1) yoko[i][j] = 1;
    }
    sum2D v(tmpv), ne(tate), me(yoko);
    while(q--){
        int a,b,c,d; cin >> a >> b >> c >> d;
        int ans = v.get(a,b,c,d) - ne.get(a,b,c-1,d) - me.get(a,b,c,d-1);
        cout << ans << "\n";
    }
}

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

int main()
{
int n;
  cin >>n;
  bool f = true;
  for (int i = 0; i < n;i++)
  {
int tmp;
    cin >> tmp;
    if (tmp % 2 == 0 && (tmp % 3 !=0 && tmp % 5!=0))
    f = false;
  }
  if (f)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}


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

using namespace std;


#define M_DEBUG if(0)


int main() {
    int n = 0;
	cin >> n;
	assert(2 <= n && n <= 200000);

	int a_max = 0; // 最大値
	int a_max_idx = -1; // 最大値の位置
	int a_max_2nd = 0; // 2番目に大きい値
	
	for (int i = 0; i < n; i++) {
		int a = 0;
		cin >> a;
		assert(1 <= a && a <= 200000);

		if (a_max < a) {
			M_DEBUG cout << "a_max" << " = " << a_max << " -> " << a << " idx = " << i << endl;
			M_DEBUG cout << "a_max_2nd" << " = " << a_max_2nd << " -> " << a_max << endl;
			a_max_2nd = a_max;
			a_max = a;
			a_max_idx = i;
		}
		if (a_max > a && a_max_2nd < a) {
			M_DEBUG cout << "a_max_2nd" << " = " << a_max_2nd << " -> " << a << endl;
			a_max_2nd = a;
		}

		// 最大値が2回出てきたときは、全部同じになる
		if (a_max == a && a_max_idx != i) {
			M_DEBUG cout << "a_max_2nd" << " = " << a_max_2nd << " -> " << a << endl;
			a_max_2nd = a;
		}
	}
	vector<int> a_list(n, a_max);
	a_list[a_max_idx] = a_max_2nd;

	for (int a : a_list) {
		cout << a << endl;
	}
	return 0;
}


Measured memory_bytes: 2432
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
s = list(sys.stdin.readline().split())
cnt = Counter(s)
if len(cnt.keys()) == 4:
    print('Four')
else:
    print('Three')

Measured memory_bytes: 38256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
        char s[250];
        scanf("%s",s);
        int len=strlen(s)-1;
        int n=len;
        for(int i=1;i<=len;i++)
        {
                int num=0;
                int flag=0;
                if(n%2==0)
                {
                        for(int j=0;j<n/2;j++)
                        {
                                if(s[j]==s[n/2+j])
                                        num++;
                                if(num==n/2)
                                {
                                        flag=1;
                                        printf("%d\n",n);
                                }
                        }
                }
                n--;
                if(flag==1)
                        break;
        }
        return 0;
}


Measured memory_bytes: 128
N=int(input())
A=list(map(int,input().split()))
c=0
L=[]
Benef=[]
for i in range(N-1):
    if A[i]>A[i+1]:
        L.append((c,i))
        Benef.append(A[i]-A[c])
        c=i+1
    elif i==N-2:
        L.append((c,N-1))
        Benef.append(A[N-1]-A[c])
l=len(L)
maney=1000
for j in range(l):
    maney+=(maney//A[L[j][0]])*Benef[j]
print(maney)

Measured memory_bytes: 9216
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	fmt.Println(a[0] - a[n-1])
}


Measured memory_bytes: 1844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  int a,b; cin >> a >> b;
  for (int i = 0; i <= 1000000; i++) {
    if (i*8/100 == a and i*1/10 == b) {
      cout << i << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
  return 0;
}



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

using namespace std;

int n;
string s,t,res;

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

	cin >> n;
	cin >> s >> t;
	for (int i=0;i<s.size();i++)
	{
		res += s[i];
		res += t[i];
	}
	cout << res;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
 
N, K = inpl()
A = sorted(inpl())
S = []
s = 0
for a in A:
    s += a
    S.append(s)

A = A[::-1]
DP = [True]+[False for _ in range(K-1)]

OK = [False for _ in range(N)]
 
for i, a in enumerate(A):
    DP1 = [False] * K
    if a >= K:
        OK[i] = True
        continue
    for j, d in enumerate(DP[-S[::-1][i]:], max(0, K-S[::-1][i])):
        if d:
            DP1[j] = True
            if j + a >= K:
                OK[i] = True
                break
            else:
                DP1[j+a] = True
    DP = DP1 
if sum(OK) == 0:
    print(N)
else:
    print(OK[::-1].index(True))

Measured memory_bytes: 52828
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll H, W;
  cin >> H >> W;
  vvc a(H, vc(W));
  rep(i, H){
    rep(j, W) cin >> a[i][j];
  }

  vvl b(H, vl(W, 1));
  rep(i, H){
    bool found = false;
    rep(j, W) found = found || (a[i][j] == '#');
    if(!found){
      rep(j, W) b[i][j] = 0;
    }
  }

  rep(j, W){
    bool found = false;
    rep(i, H) found = found || (a[i][j] == '#');
    if(!found){
      rep(i, H) b[i][j] = 0;
    }
  }

  ll plot;
  rep(i, H){
    plot = 0;

    rep(j, W){
      if(b[i][j] == 1){
        cout << a[i][j];
        plot++;
      }
    }

    if(plot > 0) cout << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;

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

int d, e;
double ans;

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

    while (cin >> d >> e, d | e) {
        ans = 1e9 + 7;
        rep(i,d+1) {
            rep(j,d+1) {
                if (i + j == d) {
                    double tmp = fabs(sqrt(i*i+j*j) - e);
                    if (ans > tmp) {
                        ans = tmp;
                    }
                }
            }
        }
        cout << fixed << setprecision(10) << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3224
#include <iostream>
#include <cmath>
using  std::endl;
using  std::cin;
using  std::cout;

int main(void)
{
    int32_t n, m;
    cin >> n >> m;

    for (uint32_t i = m/n; i > 0 ; i--) {
        if (m % i == 0) {
            if (m / i >= n) {
                cout << i << endl;
                break;
            }
        }
    }

    return 0;
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second

char win[256];

int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	win['r'] = 's';
	win['s'] = 'p';
	win['p'] = 'r';

	int n, k; string t;
	vector<int> g(3);
	cin >> n >> k;
	for (auto &i : g) cin >> i;
	cin >> t;

	int ans = 0;
	vector<char> play = { 'r', 's', 'p' };

	auto f = [&](string a)
	{
		int l = a.length();
		vector<vector<int>> dp(3, vector<int>(l, -2e9));
		for (int j = 0; j < 3; ++j)
			dp[j][0] = (win[play[j]] == a[0]) * g[j];
		for (int i = 1; i < l; ++i)
			for (int j = 0; j < 3; ++j)
				for (int k = 0; k < 3; ++k)
					if (j != k)
						dp[j][i] = max(dp[j][i], dp[k][i-1] + (win[play[j]] == a[i]) * g[j]);
		return max({ dp[0][l-1], dp[1][l-1], dp[2][l-1] });
	};

	for (int i = 0; i < k; ++i)
	{
		string a = "";
		for (int j = i; j < n; j += k)
			a += t[j];
		ans += f(a);
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
const long long INF=0x3f3f3f3f3f3f3f3f;
const int maxn=1e5+7;
vector<long long> posa,posb;
long long Finda(long long  x,int type)
{
	int ret=lower_bound(posa.begin(),posa.end(),x)-posa.begin();
	if(type) return posa[ret];
	else return posa[ret-1];
}
long long Findb(long long x,int type)
{
	int ret=lower_bound(posb.begin(),posb.end(),x)-posb.begin();
	if(type) return posb[ret];
	return posb[ret-1];
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b,q;
	long long temp;
	cin>>a>>b>>q;
	posa.push_back(-0x3f3f3f3f);
	posb.push_back(-0x3f3f3f3f);
	for(int i=0;i<a;i++)
	{
		cin>>temp;
		posa.push_back(temp);
	}
	for(int i=0;i<b;i++)
	{
		cin>>temp;
		posb.push_back(temp);
	}
	posa.push_back(0x3f3f3f3f3f3f3f3f);
	posb.push_back(0x3f3f3f3f3f3f3f3f);
	while(q--)
	{
		long long x;
		long long ans=INF;
		cin>>x;
		long long cur=0;
		long long pos=Finda(x,0);
		if(pos>0&&pos<INF) 
		{
			cur=x-pos;
			long long nxt=Findb(pos,0);
			if(nxt>0&&nxt<INF)
			{
				cur+=pos-nxt;
				ans=min(ans,cur);
			}
			cur=x-pos;
			nxt=Findb(pos,1);
			if(nxt>0&&nxt<INF)
			{
				cur+=nxt-pos;
				ans=min(ans,cur);
			}
		}
		cur=0;
		pos=Findb(x,0);
		if(pos>0&&pos<INF) 
		{
			cur=x-pos;
			long long nxt=Finda(pos,0);
			if(nxt>0&&nxt<INF)
			{
				cur+=pos-nxt;
				ans=min(ans,cur);
			}
			cur=x-pos;
			nxt=Finda(pos,1);
			if(nxt>0&&nxt<INF)
			{
				cur+=nxt-pos;
				ans=min(ans,cur);
			}
		}
		cur=0;
		pos=Finda(x,1);
		if(pos>0&&pos<INF)
		{
			cur=pos-x;
			long long nxt=Findb(pos,0);
			if(nxt>0&&nxt<INF)
			{
				cur+=pos-nxt;
				ans=min(ans,cur);
			}
			cur=pos-x;
			nxt=Findb(pos,1);
			if(nxt>0&&nxt<INF)
			{
				cur+=nxt-pos;
				ans=min(ans,cur);
			}
		}
		cur=0;
		pos=Findb(x,1);
		if(pos>0&&pos<INF)
		{
			cur=pos-x;
			long long nxt=Finda(pos,0);
			if(nxt>0&&nxt<INF)
			{
				cur+=pos-nxt;
				ans=min(ans,cur);
			}
			cur=pos-x;
			nxt=Finda(pos,1);
			if(nxt>0&&nxt<INF)
			{
				cur+=nxt-pos;
				ans=min(ans,cur);
			}
		}
		cout<<ans<<endl;
	}
}


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

using namespace std;

int main()
{
	int a=0, n;
	cin >> n;
	int *c = new int[n];
	int *v = new int[n];

	for(int i = 0; i < n; i++) 	cin >> v[i];
	for(int i = 0; i < n; i++)  cin >> c[i];

	for(int i = 0; i < n;i++)
	{
		if((v[i] - c[i]) > 0) a += (v[i] - c[i]);
	}
	cout << a;
	cin >> a;
	delete[] v;
	delete[] c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
//const int mod=1e9+7;
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
void ckmax(int &x,int y){
	if (x<y)
		x=y;
}
void ckmin(int &x,int y){
	if (x>y)
		x=y;
}
const int N=200005;
int n,k;
int a[N];
int check(){
	For(i,1,n)
		if (a[i]!=n)
			return 0;
	return 1;
}
int b[N];
int main(){
	n=read(),k=read();
	For(i,1,n)
		a[i]=read();
	while (k--&&!check()){
		clr(b);
		For(i,1,n)
			b[max(1,i-a[i])]++,b[min(n,i+a[i])+1]--;
		For(i,1,n)
			b[i]+=b[i-1],a[i]=b[i];
	}
	For(i,1,n)
		printf("%d ",a[i]);
	puts("");
	return 0;
}

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

int main()
{
    int N, count, ans;
    ans=0;
    count=0;
    cin>>N;

    rrep(i,N+1) {
        if(i%2==1){
            rrep(t,i+1){
                if(i%t==0){
                    count++;
                }
            }
            if(count==8) {
                ans++;
            }
        }
        count=0;
    };
    cout<< ans << endl;
    // fprintf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
from decimal import Decimal
a,b=map(str, input().split())
A=Decimal(a)
B=Decimal(b)

print(int(A*B))

#b=int(B*100)
#ans100bai=A*b
#if len(str(ans100bai))>2:
#	print(str(ans100bai)[:-2])
#else:
#	print(0)

# 2darray [[0] * 4 for i in range(3)]


Measured memory_bytes: 10076
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
main(){
  int n,k,g,m,c;
  cin>>n>>k>>g;
  m=g;
  while(cin>>c){
    m=max(m,c);
    g=gcd(g,c);
  }
  cout<<(k%g||m<k?"IM":"")<<"POSSIBLE";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    ll x;
    cin >> x;
    ll set = (x + 10) / 11;
    ll y = 11 * (set - 1) + 6;
    if (y >= x) cout << 2 * (set - 1) + 1;
    else cout << 2 * set;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

int fastpow(int x, int n, int m){
    int a = 1;
    IREP(i, 64){
        a = (a * a) % m;
        if(((n >> i) & 1) == 1) a = (a * x) % m;
    }
    return a;
}

class Combination
{
public:

    vec fact, invfact;
    int MAX_N, mod;

    Combination(int MAX_N, int mod): MAX_N(MAX_N), mod(mod) {
        fact = vec(MAX_N + 1);
        invfact = vec(MAX_N + 1);
        fact[0] = 1; invfact[0] = 1;
        FOR(i, 1, MAX_N + 1){
            fact[i] = (fact[i - 1] * i) % mod;
            invfact[i] = fastpow(fact[i], mod - 2, mod);
        }
    }

    int comb(int n, int r){
        if(r > n || r < 0 || n < 0) return 0;
        int a = fact[n];
        a = (a * invfact[r]) % mod;
        a = (a * invfact[n - r]) % mod;
        return a;
    }
};

signed main(){

    int H, W, A, B; cin >> H >> W >> A >> B;
    int mod = 1000000007;

    Combination C(H + W, mod);
    
    int ans = C.comb(H + W - 2, W - 1);

    REP(i, B){
        int tmp = C.comb(i + H - A - 1, i) * C.comb(W + A - i - 2, W - i - 1);
        tmp %= mod;
        ans = (ans + (mod - tmp)) % mod;
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

ll pow(ll a, ll n) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a) {
		if (n % 2LL == 1LL) {
			ret = ret * a;
		}
	}
	return ret;
}

int main() {
  ll L;
  cin>>L;
  ll s = L;
  ll cnt = 0LL;
  vector<ll> v;
  ll edge = 0LL;
  while(s!=0){
    edge+=s%3;
    v.push_back(s%3LL);
    s=s/3;
    cnt++;  
  }
  cout<<cnt+1<<" "<<(cnt-1)*3+edge<<endl;
  ll num = 1LL;
  for(ll i = 0LL; i < cnt-1; i++){
    cout<<i+1<<" "<<i+2<<" "<<0<<endl;
    cout<<i+1<<" "<<i+2<<" "<<num<<endl;
    cout<<i+1<<" "<<i+2<<" "<<num*2LL<<endl;
    num*=3;
  }
  ll total = 0LL;
  for(ll i = 0LL; i < cnt; i++){
    if(v[i]==1) {
      cout<<i+1<<" "<<cnt+1<<" "<<total<<endl;
      total+=pow(3,i);
    }
    if(v[i]==2){
      cout<<i+1<<" "<<cnt+1<<" "<<total<<endl;
      total+=pow(3,i);
      cout<<i+1<<" "<<cnt+1<<" "<<total<<endl;
      total+=pow(3,i);
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A<B ? 1:-1;//降順
}
int main(void){
    ll N, A[101], Alice=0, Bob=0;
    in(N);
    rep(i, N) in(A[i]);
    qsort(A, N, sizeof(ll), cmp);//降順ソート
    rep(i, N){
        if(i%2) Bob += A[i];
        else Alice += A[i];
    }
    put(Alice - Bob);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <string.h>
#include <math.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険

#define rep(i,l,r)for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r)for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k)for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す
/*
   upll : (a<b)なら-1, (a=b)なら0, (a>b)なら1
 downll : (a<b)なら1, (a=b)なら0, (a>b)なら-1

 const void* a : 型を縛らずにconstをつける(=変数aが読み込み専用の変数であることを明示する)
        (ll*)a : 変数aがconst long long *型であると明示する
*/
// int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
// int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
// void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
// void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

vector<ll> tmp(3*100000+1,0);
vector<ll> cnt(3*100000+1,0);
vector<pair<ll,ll>> p;

bool Compare(ll k, ll m){
    ll sum = 0;
    rep(i,0,p.size()) sum += min(p[i].fi, m) * p[i].se;
    return sum >= k*m;
}

int main(){
    ll n; cin >> n;
    
    // 枚数をカウント
    rep(i,0,n){ ll a; cin >> a; tmp[a]++; }

    // 同じ枚数のものが何種類あるかを管理
    rep(i,1,n+1) cnt[tmp[i]]++;

    // cntをpairで管理(0枚はいらないので切る)
    rep(i,1,n+1) if(cnt[i] != 0) p.pb(pair<ll,ll>(i, cnt[i]));

    rep(k, 1, n+1){
        //取り除ける回数を2分探索
        ll lb = 0, ub = (n/k)+1, mid;
        while(ub - lb > 1){
            mid = (lb + ub) / 2;
            if(Compare(k, mid)){
                lb = mid;
            }else{
                ub = mid;
            }
        }
      	cout << lb << endl;
    }
}

Measured memory_bytes: 7168
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;


int main(){
	double a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	double value = (a + b) / 2;
	ll ans = 0;
	if(value > c)	ans += min(x, y) * c * 2;
	else ans += min(x, y) * a + min(x, y) * b;
	
	ll extra = max(x, y) - min(x, y);
	if(x >= y){
		if(a <= c * 2) ans += extra * a;
		else ans += extra * c * 2;
	} else {
		if(b <= c * 2) ans += extra * b;
		else ans += extra * c * 2;
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  long[] a; readA(n, a);

  auto g = GraphW!(int, long, 10L^^18)(n+2);

  foreach (i; 1..n+1) {
    g.addEdge(0, i, a[i-1] > 0 ? 0 : -a[i-1]);
    g.addEdge(i, n+1, a[i-1] > 0 ? a[i-1] : 0);

    foreach (j; 2..n/i+1) g.addEdge(i, i*j, g.inf);
  }

  auto r = g.dinic(0, n+1);

  writeln(a.filter!"a>0".sum - r);
}

struct GraphW(N = int, W = int, W i = 10^^9)
{
  alias Node = N, Wt = W, inf = i;
  struct Edge { Node src, dst; Wt wt; alias cap = wt; }
  Node n;
  Edge[][] g;
  alias g this;
  this(Node n) { this.n = n; g = new Edge[][](n); }
  void addEdge(Node u, Node v, Wt w) { g[u] ~= Edge(u, v, w); }
  void addEdgeB(Node u, Node v, Wt w) { g[u] ~= Edge(u, v, w); g[v] ~= Edge(v, u, w); }
}

template Dinic(Graph)
{
  import std.algorithm, std.container, std.traits;
  alias Node = TemplateArgsOf!Graph[0], Wt = TemplateArgsOf!Graph[1];

  struct EdgeR { Node src, dst; Wt cap, flow; Node rev; }

  Wt dinic(ref Graph g, Node s, Node t)
  {
    auto n = g.n, adj = withRev(g, n), level = new int[](n);

    auto levelize()
    {
      level[] = -1; level[s] = 0;

      auto q = DList!Node(s);
      while (!q.empty) {
        auto u = q.front; q.removeFront();
        if (u == t) break;
        foreach (ref e; adj[u])
          if (e.cap > e.flow && level[e.dst] < 0) {
            q.insertBack(e.dst);
            level[e.dst] = level[u] + 1;
          }
      }

      return level[t];
    }

    Wt augment(Node u, Wt cur)
    {
      if (u == t) return cur;

      foreach (ref e; adj[u]) {
        auto r = &adj[e.dst][e.rev];
        if (e.cap > e.flow && level[u] < level[e.dst]) {
          auto f = augment(e.dst, min(cur, e.cap - e.flow));
          if (f > 0) {
            e.flow += f;
            r.flow -= f;
            return f;
          }
        }
      }

      return 0;
    }

    Wt flow = 0, f = 0;

    while (levelize >= 0)
      while ((f = augment(s, g.inf)) > 0)
        flow += f;

    return flow;
  }

  EdgeR[][] withRev(ref Graph g, Node n)
  {
    auto r = new EdgeR[][](n);

    foreach (gi; g)
      foreach (e; gi) {
        r[e.src] ~= EdgeR(e.src, e.dst, e.cap, 0, cast(Node)(r[e.dst].length));
        r[e.dst] ~= EdgeR(e.dst, e.src, 0, 0, cast(Node)(r[e.src].length) - 1);
      }

    return r;
  }
}
auto dinic(G, N)(G g, N s, N t) { return Dinic!G.dinic(g, s, t); }


Measured memory_bytes: 380
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

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

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

void Main()
{
    string s,t;cin>>s>>t;
    LL sn = SIZE(s);
    LL tn = SIZE(t);

    LL result = INF_LL;

    REP(i,sn){
        LL count = 0;
        bool f = true;
        REP(j,tn){
            if(s[i+j] != t[j]){
                count++;
            }
            if(i+j>=sn){
                f = false;
                break;
            }
        }
        if(f){
            result = min(result,count);
        }
    }
    cout<<result<<endl;
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 3616
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

// vector set 等
#include <map>
#include <set>
#include <vector>

//マクロ
// forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
// FORAは範囲for文(使いにくかったら消す)
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto& i : I)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000  // 10^12:∞
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange
//略記
#define PB push_back  //挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素

signed main() {
  //入力の高速化用のコード
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  string s1;

  vector<string> strs{
      "AC",
      "WA",
      "TLE",
      "RE"
  };
  map<string, int> m{};

  FORA(s, strs) { m[s] = 0; }

  // AC x 10 WA x 0 TLE x 0 RE x 0

      cin >>
      n;
  REP(i, n) {
    cin >> s1;
    FORA(s, strs) {
      if (s1 == s) {
        m[s] += 1;
      }
    }
  }
  FORA(s, strs) { cout << s << " x " << m[s] << endl; }

  return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

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

	int r, g, b, n;
	cin >> r >> g >> b >> n;

	int ans = 0;

	for (int i = 0; i <= 3000; i++) {
		for (int j = 0; j <= 3000; j++) {
			int rg = i * r + j * g;
			if ((n - rg) >= 0 && (n - rg) % b == 0) ans++;
		}
	}

	out(ans);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)
typedef long long ll;

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

Measured memory_bytes: 3592
A, B, C, K = list(map(int, input().strip().split()))
ans = 0
tmp = min(A, K)
ans += tmp
K -= tmp
if K <= 0:
  pass
else:
  tmp = min(B, K)
  K -= tmp
  if K <= 0:
    pass
  else:
    tmp = min(C, K)
    ans -= tmp
print(ans)

Measured memory_bytes: 9224
// :)
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <sstream>
#include <stack>
#include <set>
#include <cstdio>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <vector>

typedef long long ll;

using namespace std;

std::random_device rd_device;
std::mt19937 rng(rd_device());

int main() {
    ios::sync_with_stdio(false);
    cin.exceptions(ios_base::failbit);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(10);
    cout<<fixed;
    
    int y, m, d;
    scanf("%d/%d/%d", &y, &m, &d);
    string heisei = "Heisei";
    if (y < 2019) cout<<heisei<<endl;
    else if (y == 2019) {
        if (m < 4) cout<<heisei<<endl;
        else if (m == 4) {
            if (d <= 30) cout<<heisei<<endl;
            else cout<<"TBD"<<endl;
        } else {
            cout<<"TBD"<<endl;
        }
    } else {
        cout<<"TBD"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
INF=1000000007;
N=int(input())
A=[1]
for i in range(N-1):
  A.append(0)
ans=0
i=N-3
while i>=0:
  for j in range(i):
    A[j+1]+=A[j];
  ans+=A[i];
  i-=3
print(int(ans%INF))

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int N=100*r+10*g+b; // 3桁の数字Nを求める
  if (N%4==0) cout << "YES";
  else cout << "NO";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    map<ll, ll> mp;
    ll n, m; cin >> n >> m;
    REP(i, n) {
        ll key, value; cin >> key >> value;
        mp[key] += value;
    }

    ll tvalue = 0;
    ll left = m;
    for (auto elem : mp) {
        ll value = elem.first, count = elem.second;
        tvalue += value * min(left, count);
        left -= min(left, count);
        if (left == 0) {
            cout << tvalue << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 6528
from sys import stdin
import heapq


def main():
    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    As = []
    for i in [int(x) for x in stdin.readline().rstrip().split()]:
        heapq.heappush(As, -i)
    for _ in range(M):
        x = heapq.heappop(As)
        heapq.heappush(As, x / 2)
    print(sum([-1 * int(x) for x in As]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 14180