akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1<<10, mod = 1e9 + 7;
char mat[maxn][maxn], mat2[maxn][maxn];
int n, m, cnt = 0;
ll k;
int bp(int a, ll p) {
	int r = 1;
	while(p) {
		if(p&1) r = r * 1ll * a % mod;
		p >>= 1, a = a * 1ll * a % mod;
	}
	return r;
}
struct ctx {
	int c = 1, d = 0, p = 1;
	friend ctx operator*(const ctx &a, const ctx &b) {
		ctx res;
		res.p = a.p*1ll*b.p%mod;
		res.d = (b.d*1ll*a.p + b.c*1ll*a.d)%mod;
		res.c = a.c*1ll*b.c%mod;
		return res;
	}
};
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m >> k;--k;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin >> mat[i][j], cnt += mat[i][j] == '#';
	int v = 0, h = 0;
	for(int i = 1; i <= n; i++) h += mat[i][1] == '#' && mat[i][m] == '#';
	for(int i = 1; i <= m; i++) v += mat[1][i] == '#' && mat[n][i] == '#';
	if((h && v) || k < 0) return cout << 1, 0;
	if(!h && !v) return cout << bp(cnt, k), 0;
	if(v) {
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= m; j++)
				mat2[j][i] = mat[i][j];
		swap(n, m);
		swap(v, h);
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= m; j++)
				mat[i][j] = mat2[i][j];
	}
	int d = 0;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j < m; j++)
			d += mat[i][j] == mat[i][j+1] && mat[i][j] == '#';
	ctx ans, cur{cnt, d, h};
	while(k) {
		if(k&1) ans = ans*cur;
		cur = cur*cur, k>>=1;
	}
	cout << (mod + ans.c - ans.d)%mod;
	return 0;
}


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

int main() {
  int N;
  long sum = 0;
  cin >> N;
  for (int i = 1; i <= N; i++){
    if ( !(i % 3 == 0 || i % 5== 0) )
      sum += i;
  }
  cout << sum;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main(){
    int H,W;

    while(1) {
        cin >> H >> W;
        if (H == 0 && W == 0) break ;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cout << '#';
            }
            cout << "\n";
            
            
        }
        cout << endl;
    }
    
    // cout << min << " " << max << " " << sum << endl;
    
    
    return 0;
}

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

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

vector<ll> divisor(ll n)
{
	vector<ll> ret;

	ll res=n;
	for(ll i = 1; i * i <= n; i++)
	{
		if (res % i == 0)
		{
			ret.push_back(i);
			if (i != res / i)
			{
				ret.push_back(res / i);
			}
		}
	}

	sort(all(ret));  //O(\sprt(n)log(n))

	return ret;
}


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

	vector<ll> x = divisor(n);
	ll ans = 0;
	for(auto itr = x.begin(); itr != x.end(); ++itr){
		ll m = (*itr)-1;
		if(m != 0 && n/m==n%m) ans += m;
	}
	cout<<ans<<endl;

	return 0;
}

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

int main(void){
    int a, b, c;
    int i;
    bool judge = false;
    
    cin >> a >> b >> c;
    
    for(i = 0; i <= b; i++){
        if(a * i % b == c){
            judge = true;
            cout << "YES\n";
            break;
        }
    }
    
    if(!judge)
        cout << "NO\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
const int mo=1e9+7;
int fac[200001],x[100001],y[100001];
int pow(int x,int n){
	int t=1,y=x;
	while (n){
		if (n&1) t=1ll*t*y%mo;
		y=1ll*y*y%mo;
		n>>=1;
	}
	return t;
}
int main(){
	int h,w,a,b,i,j,m,ans=0;
	scanf("%d%d%d%d",&h,&w,&a,&b);
	m=h+w;
	fac[0]=1;
	for (i=1;i<=m;++i) fac[i]=1ll*fac[i-1]*i%mo;
	for (i=b+1;i<=w;++i){
		x[i]=1ll*fac[h-a+i-2]*pow(1ll*fac[i-1]*fac[h-a-1]%mo,mo-2)%mo;
		y[i]=1ll*fac[a+w-i-1]*pow(1ll*fac[a-1]*fac[w-i]%mo,mo-2)%mo;
		ans=(ans+1ll*x[i]*y[i]%mo)%mo;
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
typedef long long ll;
#define all(v) ((v).begin()),((v).end())
#define clr(a, b)memset(a,b,sizeof(a))
#define sz(a) (int)(a).size()
#define el '\n';
#define loop(i, n) for(int i = 0;i < int(n);i++)
#define PI acos(-1)
#define pb push_back
#define F first
#define S second

void LOL() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

bool comp(double a, double b) {
    return abs(a - b) < 1e-9;
}

int LCM(int a, int b) {
    return a * b / (__gcd(a, b));
}

bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b) {
    return (a.second < b.second);
}

const int N = 1e6 + 7, E = 1e5 + 5, OO = 0x3f3f3f3f;
ll arr[N];

int main() {
    LOL();
    int t = 1;
    //cin >> t;
    while (t--) {
        string a,b;
        cin>>a>>b;
        loop(i,sz(a))if(a[i]!=b[i])return cout<<"No",0;
        cout<<"Yes";
    }
    return 0;
}


// CHECK THE FOLLOWING ONE MORE TIME BEFORE SUBMIT :
// the vector,arr,etc is redefined in multi cases
// the constraint N M OO etc ,,, The size of the array,vector etc
// the data type of variables ,,, int is enough ?
// the complexity of the code ? O(n)? O(n*n)? will fit ?
// Out of bond ? access an element out of size ? i-1>0 ? i+1 <n?
// CHECK ONE MORE TIME, IT'S OK TO GET WA,BUT NOT OK TO GET TLE OR RTE

Measured memory_bytes: 3628
#include<stdio.h>
#include <string.h>
#include <stdlib.h>


int main (){
    
  int a,b,t,tmp;
  int ans,n;
  int v[50];
  int c[50];
  
  scanf("%d %d",&n,&a);
  
  ans = n - a + 1;
  
  


	
  printf("%d",ans);
      return 0;
  
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,X,T;
    cin>>N>>X>>T;

    cout<<(N+X-1)/X*T<<endl;


    



}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, total = 0, ans = 0;
	cin >> n;
	vector<int> arr(n);

	for(int i = 0; i < n; i++) {
		cin >> arr[i];
		total += arr[i];
	}
	if(total % 10 != 0) {
		ans = total;
	} else {
		for(int i = 0; i < n; i++) {
			if(((total - arr[i]) % 10 != 0)&&(ans < total - arr[i])) {
				ans = total - arr[i];
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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

int head,tail,MAX,n,q,T=0;

struct process {
    string name;
    int time;
};

vector<process> Q(100000);

bool isEmpty(){
    return head==tail;
}

void enqueue(process x){
    Q.at(tail)=x;
    if(tail+1==MAX){
        tail=0;
    }
    else tail++;
}

process dequeue(){
    process x=Q.at(head);
    if(head+1==MAX){
        head=0;
    }
    else head++;
    return x;
}



int main(){
    cin>>n>>q;
    for(int i=0;i<n;i++){
        cin>>Q.at(i).name>>Q.at(i).time;
    }

    MAX=100000;
    head=0;
    tail=n;

    while(!isEmpty()){
        if(Q.at(head).time>q){
            T+=q;
            Q.at(head).time-=q;
            enqueue(dequeue());
        }
        else{
            T+=Q.at(head).time;
            cout<<Q.at(head).name<<' '<<T<<endl;
            dequeue();
        }
    }    
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll k,t,ma=0;
	cin >> k >> t;
	vll a(t);
	rep(i,t){
		cin >> a[i];
		chmax(ma,a[i]);
	}
	cout << max(0LL,ma-1-(k-ma)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
    ll n,m;cin >>n>>m;
    ll p[m];string s[m];rep(i,m)cin>>p[i]>>s[i];
    bool ac[n];ll wa[n],pe[n];rep(i,n)ac[i]=false,wa[i]=0,pe[i]=0;


    rep(i,m){
        if(s[i]=="AC" and ac[p[i]-1]==false)ac[p[i]-1]=true,pe[p[i]-1]+=wa[p[i]-1];
        else if(s[i]=="WA"){if(ac[p[i]-1]==false)wa[p[i]-1]++;}

    }

    ll count=0,wa1=0;
    rep(i,n)if(ac[i])count++;
    rep(i,n)wa1 +=pe[i];
    cout << count <<" "<<wa1<< endl;


    
    
    return 0;
}





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

long long mod = 1000000007;

int main(){
  long long S;
  cin >> S;
  
  vector<vector<long long>> C(S*2,vector<long long>(S*2,1));
  for(long long i=1;i<S*2;i++){
    for(long long j=1;j<i;j++){
      C[i][j] = C[i-1][j-1] + C[i-1][j];
      C[i][j] %= mod;
    }
  }
  
  long long ans = 0;
  for(long long i=1;;i++){
    if(i*3>S) break;
    long long x = S - i*3;
    long long count = C[x+i-1][i-1];
    count %= mod;
    ans += count;
    ans %= mod;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 128304
n = int(input())
c = 0
for i in range(1, (n // 2) + 1):
    if i ** 2 >= n:
        break
    if n % i == 0:
        a = n // i - 1
    else:
        a = n // i
    c += 2 * (a - i) + 1
print(c)

Measured memory_bytes: 62112
a, b, c, d, e, f = gets.chomp.split(" ").map(&:to_i)
na = f / (100 * a)
nb = f / (100 * b)
ans = []
0.upto(na) do |i|
  0.upto(nb) do |j|
    s = f - (100 * a * i + 100 * b * j)
    next if s < 0
    nc = s / c
    nd = s / d
    0.upto(nc) do |k|
      0.upto(nd) do |l|
        sugar =  c * k + d * l
        water = 100 * (a * i + b * j)
        if  sugar + water <= f && e * water >= 100 * sugar then
          ans << [sugar + water, sugar] if sugar + water != 0
        end
      end
    end
  end
end
puts ans.max_by{|x, y| y.to_f / x}.join(" ")


Measured memory_bytes: 39164
function main()
   N = pread(Int)
   ss = readvec(String, N)
   cab = 0
   fb = 0
   ea = 0
   ba = 0
   for i in 1:length(ss)
       cab += count(j -> ss[i][j] == 'B' && ss[i][j-1] == 'A', 2:length(ss[i]))
       if ss[i][1] == 'B'
           if ss[i][end] == 'A'
               ba += 1
           else
               fb += 1
           end
       elseif ss[i][end] == 'A'
           ea += 1
       end
   end
   bas = max(ba-1, 0)
   if ba != 0
       if fb != 0 
           fb -= 1
           bas += 1
       end
       if ea != 0 
           ea -= 1
           bas += 1
       end
   end
   fes = max(min(fb, ea), 0)
   println(bas + fes + cab)
end

import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str
isdelim(x::UInt8, xs::Set{UInt8}) = x in xs
const delimset = Set([0x0a, 0x20])

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        !isdelim(c, delims) && break
    end
    push!(out, c)
    eof(s) && return out
    while !eof(s)
        c = read(s, UInt8)
        isdelim(c, delims) && break
        push!(out, c)
    end
    return out
end

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

function readvec(tys::Tuple , len::Signed)::Tuple{map(x -> Vector{x},tys)...}
    rv = Tuple{map(x -> Vector{x},tys)...}(Vector{ty}(undef,len) for ty in tys)
    for i in 1:len
        for j in 1:length(tys)
            @inbounds rv[j][i] = pread(tys[j])
        end
    end
    rv
end

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i in 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

main()


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define sz(obj) ((int)(obj).size())
#define pb push_back

int a, b, f;
int main()
{
  cin >> a >> b;
  while (1){
    f = 1;
    FOR(i, a, b + 1){
      if (i % 4 == 0 && (i % 400 == 0 || i % 100 != 0)){
        cout << i << endl;
        f = 0;
      }
    }
    cin >> a >> b;
    if (f) cout << "NA" << endl;
    if (a + b == 0) break;
    else cout << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) {
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    int M = A[N-1];
    cout << M << " ";
    if (N == 2) {
        cout << A[0] << endl;
        return 0;
    }

    int a = M/2, b = M/2 + 1;
    auto x = lower_bound(A.begin(), A.end(), a);
    if (x != A.end() && (*x == a || (M % 2 == 1 && *x == b))) {
        cout << *x  << endl;
        return 0;
    }
    // lower_boundで等しい値が無かった場合、*xは常にaより大きい。

    int m = distance(A.begin(), x);
    if (M % 2 == 1) {
        if (abs(A[m] - b) < abs(A[m-1] - a)) {
            cout << A[m] << endl;
        } else {
            cout << A[m-1] << endl;
        }
    } else {
        if (abs(A[m] - a) < abs(A[m-1] - a)) {
            cout << A[m] << endl;
        } else {
            cout << A[m-1] << endl;
        }
    }
}

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

int n, m, ans;
int main()
{
	vector <int> v[100005];
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		int a, b; cin >> a >> b;
		if (a > m) {
			continue;
		} else {
			v[m-a].push_back(b);
		}
	}
	priority_queue<int> pq;
	for (int i = m-1; i >= 0; i--)
	{
		while(!v[i].empty())
		{
			pq.push(v[i].back());
			v[i].pop_back();
		}
		if (!pq.empty())
		{
			ans += pq.top();
			pq.pop();
		}
	}
	cout << ans;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants
#define INF 1e9

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Moving in a grid world (NESW)
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin


// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

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

  int H=in(); int W=in();
  int h=in(); int w=in();

  cout << (H-h)*(W-w) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cstdlib>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,m,n) for(int i = m; i < n; ++i)
#define RFOR(i,m,n) for(int i = n - 1; i >= m; --i)
#define CIN(a) cin >> a
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a << endl
#define COUT2(a, b) cout << a << " " << b << endl
#define COUT3(a, b, c) cout << a << " " << b << " " << c << endl
#define pb push_back
#define PB push_back
#define VINT(v, n) vector<int> v(n); REP(i, n) { v[i] = 0 }
#define VINT2(v, n, m) vector<vector<int> > v(n, vector<int>(m)); REP(i, n) { REP(j, m) { v[i][j] = 0 } }
#define VCHAR(v, n) vector<char>v(n)
#define MAX(a, b) a > b ? a : b
#define MIN(a, b) a < b ? a : b
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 100000000

using namespace std;
typedef pair<int, int> P;
int DX[4] = {1, 0, -1, 0};
int DY[4] = {0, 1, 0, -1};



int main() {
	long long N, M;
	CIN2(N, M);
	if(M <= 2 * N) {
		COUT(M / 2);
	}
	else {
		COUT(N + ((M - 2 * N) / 4));
	}
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	var s, t, u string
	fmt.Scan(&s, &t)
	fmt.Scan(&a, &b)
	fmt.Scan(&u)
	if s == u {
		a -= 1
	} else {
		b -= 1
	}

	fmt.Println(a, b)

}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
      	PrintWriter out = new PrintWriter(System.out);
        int a = Integer.parseInt(sc.next());
        int p = Integer.parseInt(sc.next());
        int aaa = a * 3;
        int pi = (aaa + p) / 2;
        out.println(pi);
      	out.flush();
    }
}

Measured memory_bytes: 23380
//Moh_K_Imar .......
//28/08/2020  ... 11,20.
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    string a;
    cin>>a;
    if(a[0]==a[1]&&a[0]!=a[2]&&a[2]==a[3]&&a[0]!=a[3])cout<<"Yes"<<endl;
    else if(a[0]==a[3]&&a[1]==a[2]&&a[0]!=a[1]&&a[0]!=a[2])cout<<"Yes"<<endl;
    else if(a[0]==a[2]&&a[1]==a[3]&&a[0]!=a[1]&&a[0]!=a[3])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 3620
S = list(input())
answer = 0
first = True
flag = ""
for i in range(len(S)):
    if(first):
        first = False
        flag = S[i]
    else:
        if(flag == S[i]):
            answer += 1
            if(S[i] == "0"):
                S[i] = "1"
            else:
                S[i] = "0"
            flag = S[i]
        else:
            flag = S[i]
print(answer)

Measured memory_bytes: 3956
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
    int n, i, r=0;
    scanf(" %d", &n);
    int a[n];
    for(i=0; i<n; i++){
        scanf(" %d", &a[i]);
    }
    for(i=0; i<n; i++){
        if(a[i]%2==1){
            r++;
        }
    }
    if(r%2==1){
        printf("NO");
    }
    else{
        printf("YES");
    }
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main(){

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

  if(x=='A'){
    a=1;
  } else if(x=='B'){
    a=2;
  } else if(x=='C'){
    a=3;
  } else if(x=='D'){
    a=4;
  } else if(x=='E'){
    a=5;
  } else if(x=='F'){
    a=6;
  }

  if(y=='A'){
    b=1;
  } else if(y=='B'){
    b=2;
  } else if(y=='C'){
    b=3;
  } else if(y=='D'){
    b=4;
  } else if(y=='E'){
    b=5;
  } else if(y=='F'){
    b=6;
  }

  if(x==y){
    cout << "=" << endl;
  } else if(x>y){
    cout << ">" << endl;
  } else {
    cout << "<" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <limits.h>

using namespace std;

void out(const int n, int* a)
{
    for(int i=0; i<n; i++){
        cout << a[i];
        if(i != n-1) cout << " ";
    }
    cout << endl;
}
/*
int SelectionSort(const int n, std::string* a)
{
    int cnt = 0;
    for(int i=g; i<n; i++){
        int min_index = i;
        for(int j=i+1; j<n; j++){
            if(a[min_index][1] > a[j][1]){
                min_index = j;
            }
        }
        if(min_index != i){
            std::string tmp = a[i];
            a[i] = a[min_index];
            a[min_index] = tmp;
            cnt++;
        }
    }
}
*/
int insertionSort(int n, int* a, int g, int& cnt)
{
    for(int i=g; i<n; i++){
        int v = a[i];
        int j = i-g;
        while(j>=0 && a[j]>v){
            a[j+g] = a[j];
            j = j-g;
            cnt++;
        }
        a[j+g] = v;
    }
}
int shellSort(const int n, int* a)
{
    int cnt = 0;
    int m = 0;
    int g[100];
    
    int i = 1;
    g[0] = (n/2);
    m++;
    while(1){
        if(g[i-1] <= 1) break;
        g[i] = (g[i-1]/2);
        m++; i++;
    }
    
    for(int i=0; i<m; i++){
        //cout << "insertionSort index " << g[i] << "(" << a[g[i]] << endl;
        insertionSort(n, a, g[i], cnt);
        //out(n, a);
    }
    cout << m << endl;
    for(int i=0; i<m; i++){
        cout << g[i];
        if(i != m-1) cout << " ";
    }
    cout << endl << cnt << endl;
}
int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    int cnt = shellSort(n, a);
    for(int i=0; i<n; i++){
        cout << a[i] << endl;
    }
}


Measured memory_bytes: 6984
A, B = map(int,input().split())

def ssb(n):
    a = {1}
    while n % 2 == 0:
        a.add(2)
        n /= 2
    i = 3
    while i ** 2 <= n:
        if n % i == 0:
            a.add(i)
            n /= i
        else:
            i += 2
    if n != 1:
        a.add(n)
    return a

a = ssb(A)
b = ssb(B)

print(len(a&b))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;



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

  cout<<n*n*n<<endl;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        String a = scanner.next();
        String b = scanner.next();
        String[] tmp = new String[3];
        tmp = a.split("");

        if (b.equals(tmp[2]+tmp[1]+tmp[0])) {
        	System.out.println("YES");
        }else {
        	System.out.println("NO");
        }

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

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

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

	scanf("%d %d %d", &a, &b, &c);

	if (a + b == c || b + c == a || a + c == b)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}

	return 0;
}

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (ll i = a; i >= b; i--)
#define ms(a,x)         memset(a,x,sizeof a)
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           (a)*(a)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)

int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        string s;
        cin>>s;
        if(s[sz(s)-1]=='s')
        {
            cout<<s<<"es";
        }
        else cout<<s<<"s";
    }
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using std::cout;
using std::cin;
using std::endl;

int main()
{
    int m, f, r, sum;
    while(1)
    {
        cin >> m >> f >> r;
        sum = m + f;
        if ((m==-1)&(f==-1)&(r==-1))
        {
            return 0;
        }
        else if (m*f<0)
        {
            cout<<"F"<<endl;
        }
        else
        {
            if(sum>=80)
                cout<<"A"<<endl;
            else if(sum>=65)
                cout<<"B"<<endl;
            else if(sum>=50)
                cout<<"C"<<endl;
            else if(sum>=30)
            {
                if(r>=50)
                    cout<<"C"<<endl;
                else
                    cout<<"D"<<endl;
            }
            else
                cout<<"F"<<endl;   
        }
    }
    return 0;
}


Measured memory_bytes: 3092
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Cryptography.X509Certificates;

namespace hello_world
{class Program
	{
		static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(" ");
			int s = int.Parse(input[0]);
			int w = int.Parse(input[1]);
			if (w >= s)
				Console.WriteLine("unsafe");
			else
				Console.WriteLine("safe");

		}

		
	}

}

	

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

using namespace std;

int main(){
    int n,m,c; cin >> n >> m >> c;
    vector<int> b(m);
    vector<vector<int>> a(n,vector<int>(m));
    for(int &i : b) cin >> i;
    for(auto &v : a)
        for(int &i : v)
            cin >> i;
    int cnt = 0;
    for(auto v : a){
        int val = 0;
        for(int i = 0;i < v.size();i++)
            val += v[i]*b[i];
        cnt += (val > -c);
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int a, b, c, d;
int main()
{
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
	return 0;
}

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

// 1を始点としてDFSでグラフ上を探索し条件を満たすパスを数え上げる

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool has_visited[nmax]) {
  bool has_visited_all = true;
  for (int i = 0; i < N; i++) {
    if (has_visited[i] == false) {
      has_visited_all = false;
    }
  }
  if (has_visited_all) {
    return 1;
  }

  int ret = 0;
  for (int i = 0; i < N; i++) {
    if (graph[v][i] == false) continue;
    if (has_visited[i]) continue;
    has_visited[i] = true;
    ret += dfs(i, N, has_visited);
    has_visited[i] = false;
  }
  return ret;
}

int main() {
  int N, M; cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int A, B; cin >> A >> B;
    graph[A-1][B-1] = graph[B-1][A-1] = true;
  }
  bool has_visited[nmax];
  for (int i = 0; i < N; i++) {
    has_visited[i] = false;
  }
  has_visited[0] = true;
  cout << dfs(0, N, has_visited) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cctype>
using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int n;
    cin>>n;
    map<ll,ll> mp;
    for(int i=0;i<n;i++){
        ll tmp;
        cin>>tmp;
        if(mp.count(tmp)){
            mp[tmp]++;
        }else{
            mp[tmp]=1;
        }
    }
    
    ll ans=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        if(itr->first==itr->second){
            continue;
        }else if(itr->first<itr->second){
            ans+=(itr->second-itr->first);
        }else{
            ans+=(itr->second);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6272
import math
a, b, C = map(float, input().split())
C = 2*math.pi/360*C

S = 0.5 * a * b * math.sin(C)
L = a + b + math.sqrt(a**2 + b**2 - 2*a*b*math.cos(C))
h = b * math.sin(C)
print(S, L, h)


Measured memory_bytes: 5692
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Reader.init(System.in);
		StringBuffer output=new StringBuffer("");
		PrintWriter out=new PrintWriter(System.out);
		int n=Reader.nextInt();
		int[][] happiness=new int[n][3];
		for(int i=0;i<n;i++) {
			for(int j=0;j<3;j++) happiness[i][j]=Reader.nextInt();
		}
		long[][] dp=new long[n][3];
		dp[0][0]=happiness[0][0];
		dp[0][1]=happiness[0][1];
		dp[0][2]=happiness[0][2];
		for(int i=1;i<n;i++) {
			dp[i][0]=happiness[i][0]+Math.max(dp[i-1][1], dp[i-1][2]);
			dp[i][1]=happiness[i][1]+Math.max(dp[i-1][0], dp[i-1][2]);
			dp[i][2]=happiness[i][2]+Math.max(dp[i-1][1], dp[i-1][0]);
		}
		long ans=0;
		for(int i=0;i<3;i++) ans=Math.max(ans, dp[n-1][i]);
		output.append(ans);
		out.write(output.toString());
		out.flush();
	}

}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
 
    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
 
    /** get next word */
    static String nextLine() throws IOException{
    	return reader.readLine();
    }
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }
    
    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}


Measured memory_bytes: 50912
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
const ld INF = 1e9+123;
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin()+1, v.end()-9
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll A,B;
    cin>>A>>B;
    
    int cnt=0;
    FOR(i,A,B){
        //sl(floor(i/10000),fmod(floor(i/1000),10),floor(fmod(i,100)/10),fmod(i,10))
        if(floor(i/10000)==fmod(i,10)&&
        fmod(floor(i/1000),10)==floor(fmod(i,100)/10))cnt++;
    }
    cout<<cnt;
    //cout<<fixed<<setprecision(15)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

top = []


def push(x):
    top.append(x)


def pop(x, cnt):
    a = int(top[cnt])
    top.pop(cnt)
    b = int(top[cnt - 1])
    top.pop(cnt - 1)

    if x == '+':
        top.append(b + a)
    elif x == '-':
        top.append(b - a)
    elif x == '*':
        top.append(b * a)


n = list(input().split())
cnt = -1

for i in n:
    if i.isdigit():
        push(i)
        cnt += 1
    else:
        pop(i, cnt)
        cnt -= 1

print(top[0])


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  string S;
  cin >> S;
  if(S=="ABC") cout << "ARC\n";
  else cout << "ABC\n";
}

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

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
#define CLR(a)     memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)    cerr << #x << " = " << (x) << endl;//debug
#define debug(x)   cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define EPS        1e-10//sample:if((double)>=(double)+EPS)
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);
int m[101][101];
int p[101];
int l=0,n;
void matrixchainorder(){

  for(int i=1;i<=n;i++)m[i][i]=0;
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j=i+l-1;
      m[i][j]=INT_MAX;
      for(int k=i;k<=j-1;k++){
	m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
}


int main(){

  int temp;
  cin>>n;
  rep(i,n+1)rep(j,n+1)m[i][j]=INT_MAX;
  for(int i=1;i<=n;i++)cin>>p[i-1]>>temp;
  p[n]=temp;
  matrixchainorder();
  cout<<m[1][n]<<endl;
  return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline ll read()
{
    ll x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
    return x*f;
}
const int N=2e5+7;
const ll INF=1e12;
ll n,m,A[N],F[N];
inline bool check(ll p)
{
    ll now=m;
    for(int i=1;i<=n;i++)
    {
        // af<=p , a<=p/f
        if(p/F[i]>=A[i]) continue;
        ll t=A[i]-p/F[i];
        if(t>now) return 0;
        now-=t;
    }
    return 1;
}
int main()
{
    n=read(),m=read();
    for(int i=1;i<=n;i++) A[i]=read();
    for(int i=1;i<=n;i++) F[i]=read();
    sort(A+1,A+n+1); sort(F+1,F+n+1);
    reverse(F+1,F+n+1);
    ll L=0,R=INF,ans=0;
    while(L<=R)
    {
        ll mid=L+R>>1;
        if(check(mid)) R=mid-1,ans=mid;
        else L=mid+1;
    }
    printf("%lld\n",ans);
    return 0;
}


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

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

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

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

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

    int a;
    string s;
    std::cin >> a >> s;
    std::cout << (3200 <= a ? s : "red") << std::endl;

    return 0;
}


Measured memory_bytes: 892
a,b,m=map(int, input().split(" "))
alist=list(map(int, input().split(" ")))
blist=list(map(int, input().split(" ")))

qlist=[list(map(int,list(input().split(" ")))) for i in range(m)]

ans = min(alist) + min(blist)

for q in qlist:
  ans = min([alist[q[0]-1] + blist[q[1]-1] - q[2],ans])

print(ans)

Measured memory_bytes: 38444
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 3010;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int a[MAXN], n;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    sort(a+1, a+n+1);
    stack<ld> s;
    FORE(i,n,1) {
        s.push(a[i]);
    }
    while (SZ(s) > 1) {
        ld g = s.top();
        s.pop();
        ld h = s.top();
        s.pop();
        s.push((g+h) / 2);
    }
    cout << fixed << setprecision(9) << s.top();
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# 数値の読み込み

h,w = list(map(int,input().split()))
m = [list(input()) for i in range(h)]

x=0
for i in range(h):
    for j in range(x,w):
        #print(i,j,m[i][j])
        if m[i][j] == '#':
            #print("find")
            m[i][j]='.'
            x=j
        else:
            break
result="Possible"
for i in range(h):
    for j in range(w):
        if m[i][j] == '#':
            result="Impossible"

print(result)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>
#include <cstring>

using namespace std;
typedef long long  ll;
const ll INF = 1000000007;
const ll mod = 1000000007;

vector<pair<long long, long long> > prime_factorize(long long N) {
	vector<pair<long long, long long> > res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0; // 指数

		// 割れる限り割り続ける
		while (N % a == 0) {
			++ex;
			N /= a;
		}

		// その結果を push
		res.push_back({ a, ex });
	}

	// 最後に残った数について
	if (N != 1) res.push_back({ N, 1 });
	return res;
}

vector<ll> p;

int main()
{
	ll N;
	cin >> N;
	p = vector<ll>(101);
	p[0] = 0;
	for (ll i = 1; i <= 100; i++)
	{
		p[i] = i + p[i - 1];
	}
	const auto& res = prime_factorize(N);
	ll ans = 0;
	for (auto val : res)
	{
		ll sisu = val.second;

		for (ll i = 1; i < 101; i++)
		{
			if (sisu < p[i])
			{
				ans += i - 1;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
// setprecision(n)
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
int main() {
    int n,m;
    cin >> n >> m;
    vector <int> x(m);
    rep(i,0,m){cin >> x[i];}
    sort(x.begin(),x.end());
    vector <int> a(m-1);
    rep(i,0,m-1) {
        a[i] = x[i+1] - x[i];
    }
    sort(a.begin(),a.end());
    int ans = 0;
    rep (i,0,m-1-n+1) {
        ans += a[i];
    }
    cout << ans << endl;


}

Measured memory_bytes: 3544
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;

int main(){
    int n, x, a[101];
    cin>>n>>x;
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a, a+n);
    int sum=0, ans=0;
    for(int i=0; i<n; i++){
        sum+=a[i];
        if(sum>x) break;
        ans++;
    }
    if(sum-x) ans=min(ans, n-1);
    cout<<ans<<endl;
    
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  int sum = 0;
  for(int i=0;i<N;i++){
    sum += a[i];
  }
  sort(a.rbegin(),a.rend());
  int ok = 0;
  for(int i=0;i<N;i++){
    if(a[i]*4*M>=sum) ok++;
  }
  if(ok>=M){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
void solve()
{
    ll a,b,x,y,k;cin>>a>>b>>x>>y>>k;
    ll ii=0;
    ii=abs(a-x);
    ll oo=0;
    oo=60*(ii);
    ll ans=(oo+y-b)-k;
    //cout<<ii<<" "<<jj<<" "<<oo<<" "<<ans+k<<" ";
    if(ans<=0)
        cout<<"0";
    else
        cout<<ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
        solve();
    return 0;
}

Measured memory_bytes: 3648
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

for i in range(n-1):
    a[i+1] = a[i] + a[i+1]
a.insert(0, 0)
for i in range(m-1):
    b[i+1] = b[i] + b[i+1]
b.insert(0, 0)

x = 0
jmax = m
for i in range(n+1):
    for j in range(jmax, -1, -1):
        if b[j] > k-a[i]:
            pass
        else:
            jmax = j
            if jmax + i > x:
                x = jmax + i
            break
print(x)

Measured memory_bytes: 40680