akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(long long i=j;i<(n);++i)
#define bk(i,j,n)   for(long long i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define srt(x) sort(x.begin(),x.end());
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

ll dp[105][100005];

int main()
{
    run;
    ll n;
    cin>>n;
    ll w;
    cin>>w;
    ll wt[n],val[n];
    fr(i,0,n)
    {
        cin>>wt[i]>>val[i];
    }
    fr(i,0,101)
    {
        fr(j,0,100005)
        dp[i][j]=10000000000000ll;
    }
    dp[0][0]=0;

    fr(i,0,n)
    {
        fr(j,0,100005)
        {



            if(val[i]<=j)
            {
                dp[i+1][j]=min(dp[i+1][j],dp[i][j-val[i]]+wt[i]);
            }
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);





        }
    }
    ll ans=0;
    fr(i,1,100005)
    {
        if(dp[n][i]<=w)
        {
            ans=i;
           // break;
        }
    }
    cout<<ans;
    /*fr(i,1,n+1)
    {
        fr(j,1,w+1)
        {
            if(wt[i-1]>j)
            {
                dp[i][j]=dp[i-1][j];
            }else
            {
                dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-wt[i-1]]);

            }
        }
    }
    cout<<dp[n][w];*/





}


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

use proconio::input;
use std::cmp::Reverse;
use std::collections::BinaryHeap;

#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        M: usize,
        AB: [(usize, usize); M]
    }

    let mut graph = vec![Vec::<usize>::new(); N + 1];
    for i in 0..M {
        let (a, b) = AB[i];
        graph[a].push(b);
        graph[b].push(a);
    }

    // init dijkstra
    let mut dist = vec![std::usize::MAX; N + 1];
    dist[0] = 0;
    let mut heap = BinaryHeap::new();
    heap.push(Reverse((0, 1))); // cont, node

    let mut ans = vec![0; N + 1];

    while let Some(Reverse((cost, node))) = heap.pop() {
        if cost > dist[node] {
            continue;
        }

        for &node_ne in &graph[node] {
            let cost_ne = cost + 1;
            if cost_ne < dist[node_ne] {
                heap.push(Reverse((cost_ne, node_ne)));
                dist[node_ne] = cost_ne;
                ans[node_ne] = node;
            }
        }
    }

    println!("Yes");
    for i in &ans[2..] {
        println!("{}", i);
    }
}


Measured memory_bytes: 18472
#include <stdio.h>
#include <iostream>

using namespace std;

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

float abs(float X, float Y) {
    return X > Y ? X - Y : Y - X;
}

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

    int T, A;
    cin >> T >> A;

    int H[N];
    REP(0, i, N) {
        cin >> H[i];
    }

    float TT = 0.0, tmp = 1e5 * 0.006;
    int ans = 0;
    REP(0, i, N) {
        TT = T - 0.006 * H[i];
        // cout << "TT = " << TT << endl;
        if (abs(TT, A) < tmp) {
            tmp = abs(TT, A);
            ans = i + 1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc065/tasks/abc065_b

def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N = INT()
a = []
for _ in range(N):
    a.append(INT() - 1)

light_idx = 0

ans = 0
while True:
    light_idx = a[light_idx]
    ans += 1

    if light_idx == 1:
        break

    if ans > N:
        ans = -1
        break

print(ans)


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{   
    int A;
    int B;

    cin >> A >> B;
    cout << max(0, A-2*B) << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;

    int min_l, max_l = N/2+1;
    while (min_l+1 < max_l) {
        auto l = (min_l + max_l) / 2;
        int[string] memo;
        bool ok;
        foreach (i; 0..N-l+1) {
            auto k = S[i..i+l];
            if (k in memo) {
                if (memo[k]+l-1 < i) {
                    ok = true;
                    break;
                }
            } else {
                memo[k] = i;
            }
        }
        if (ok) {
            min_l = l;
        } else {
            max_l = l;
        }
    }
    writeln(min_l);
}

Measured memory_bytes: 4732
program ABC_077_B_AroundSquare
   implicit none
   integer(8) N, i
   read(*, *) N
   do i = 1, N
      if( i ** 2 <= N .and. (i+1) ** 2 > N) then
	      write(*, *) i ** 2
	  end if
   end do
end program ABC_077_B_AroundSquare

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

const int INF = 2e9;

int main(){
    ll n,t;
    cin >> n >> t;
    vector<ll> s(n);
    rep(i,n) cin >> s[i];
    ll ans = t;
    for(int i = 1;i < n;i++){
        ll q = (s[i] - s[i-1]);
        if(q < t)ans += q;
        else ans += t;
    }
    cout << ans << endl;
}

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

using namespace std;
#define SIZE 262144
#define int long long
#define INF 1000000000000000000LL
class segtree{
public:
	int seg[SIZE * 2];
	void update(int a, int b){
		a += SIZE;
		seg[a] = b;
		while(true){
			a /= 2;
			if (a == 0)break;
			seg[a] = min(seg[a * 2], seg[a * 2 + 1]);
		}
	}
	int query(int beg, int end, int node, int lb, int ub){
		if (ub < beg || end < lb)return INF;
		if (beg <= lb&&ub <= end)return seg[node];
		return min(query(beg, end, node * 2, lb, (lb + ub) / 2), query(beg, end, node * 2 + 1, (lb + ub) / 2 + 1, ub));
	}
};
int dp[SIZE];
segtree tree1, tree2;
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n, q, a, b;
	cin >> n >> q >> a >> b;
	a--, b--;
	int curb = b;
	fill(dp, dp + n, INF);
	dp[a] = 0;
	for (int i = 0; i < n; i++){
		tree1.update(i, dp[i] + i);
	}
	for (int i = 0; i < n; i++){
		tree2.update(i, dp[i] - i);
	}
	int dif = 0;
	for (int p = 0; p < q; p++){
		int z;
		cin >> z;
		z--;
		int t1 = tree2.query(0, z, 1, 0, SIZE - 1) + dif + z;
		int t2 = tree1.query(z, n - 1, 1, 0, SIZE - 1) + dif - z;
		dif += abs(z - curb);
		if (dp[curb] + dif > min(t1, t2)){
			dp[curb] = min(t1, t2) - dif;
			tree1.update(curb, dp[curb] + curb);
			tree2.update(curb, dp[curb] - curb);
		}
		curb = z;
	}
	int mn = INF;
	for (int i = 0; i < n; i++){
		mn = min(mn, dp[i] + dif);
	}
	cout << mn;
}

Measured memory_bytes: 11544
#include <bits/stdc++.h>
#pragma GCC optimize(3,"Ofast","inline")
using namespace std;
int n,dp[2003][2003],a[6003],ans,tg,MX[2003],cur;
int A[100004],B[100004],C[100004],t;
void add(int x,int y,int z){A[t]=x,B[t]=y,C[t++]=z;}
int main(){
	cin>>n;
	for(int i=1;i<=3*n;i++)scanf("%d",&a[i]);
	memset(dp,-1,sizeof(dp));
	memset(MX,-1,sizeof(MX));
	dp[a[1]][a[2]]=dp[a[2]][a[1]]=MX[a[1]]=MX[a[2]]=cur=0;
	for(int i=3;i<3*n;i+=3){
		if(a[i]==a[i+1]&&a[i]==a[i+2]){tg++;continue;}
		t=0;
		if(a[i]>a[i+1])swap(a[i],a[i+1]);
		if(a[i+1]>a[i+2])swap(a[i+1],a[i+2]);
		if(a[i]>a[i+1])swap(a[i],a[i+1]);
		for(int j=1;j<=n;j++){
			if(a[i]==a[i+1])if(dp[j][a[i]]>=0)add(j,a[i+2],dp[j][a[i]]+1);
			if(a[i+1]==a[i+2])if(dp[j][a[i+1]]>=0)add(j,a[i],dp[j][a[i+1]]+1);
		}
		if(dp[a[i]][a[i]]>=0)add(a[i+1],a[i+2],dp[a[i]][a[i]]+1);
		if(dp[a[i+1]][a[i+1]]>=0)add(a[i],a[i+2],dp[a[i+1]][a[i+1]]+1);
		if(dp[a[i+2]][a[i+2]]>=0)add(a[i],a[i+1],dp[a[i+2]][a[i+2]]+1);
		add(a[i],a[i+1],cur),add(a[i+1],a[i+2],cur),add(a[i],a[i+2],cur);
		for(int k=1;k<=n;k++)if(MX[k]>=0)add(a[i],k,MX[k]),add(a[i+1],k,MX[k]),add(a[i+2],k,MX[k]);
		for(int j=0;j<t;j++)if(dp[A[j]][B[j]]<C[j])
			dp[A[j]][B[j]]=dp[B[j]][A[j]]=C[j],MX[A[j]]=max(MX[A[j]],C[j]),MX[B[j]]=max(MX[B[j]],C[j]),cur=max(cur,C[j]);
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++)ans=max(ans,dp[i][j]);
		if(dp[i][i]>=0)if(i==a[3*n])ans=max(ans,dp[i][i]+1);
	}
	printf("%d",ans+tg);
}

Measured memory_bytes: 19644
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define y1 yyyy

int n,m,x1,y1,x,y,dist[1010][1010];
string s[1010];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

bool chk(int x, int y){
  if(x>=n || x<0 || y>=m || y<0)return true;
  return false;
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n >> m;
  cin >> x >> y;x--;y--;
  cin >> x1 >> y1;x1--;y1--;
  for(int i=0;i<n;i++){
    cin >> s[i];
    for(int j=0;j<m;j++){
      dist[i][j]=1e9;
    }
  }
  priority_queue<pair<int,pi>> q;
  q.push({0,{x,y}});
  dist[x][y]=0;
  while(!q.empty()){
    pair<int,pi> cur = q.top();q.pop();
    x = cur.sc.fs;
    y = cur.sc.sc;
    for(int i=0;i<4;i++){
      int l = x+dx[i];
      int r = y+dy[i];
      if(chk(l,r))continue;
      if(s[l][r]!='.')continue;
      if(dist[l][r]>dist[x][y]){
        dist[l][r] = dist[x][y];
        q.push({-dist[l][r],{l,r}});
      }
    } 
    for(int dxx=-2;dxx<=2;dxx++){
      for(int dyy=-2;dyy<=2;dyy++){
        int l = x+dxx;
        int r = y+dyy;
        if(chk(l,r))continue;
        if(s[l][r]!='.')continue;
        if(dist[l][r]>dist[x][y]+1){
          dist[l][r] = dist[x][y]+1;
          q.push({-dist[l][r],{l,r}});
        }
      }
    }
  }
  if(dist[x1][y1]>1e8){
    dist[x1][y1]=-1;
  }
  cout << dist[x1][y1] << endl;

return 0;
}
///....


Measured memory_bytes: 12772
X,Y,A,B,C = map(int,input().split())
pList = [int(x) for x in input().split()]
qList = [int(x) for x in input().split()]
rList = [int(x) for x in input().split()]

pList.sort(reverse=True)
qList.sort(reverse=True)
rList.sort(reverse=True)

stackX=[]
stackY=[]
stackR=[]

for i in range(X):
    stackX.append(pList[i])

for i in range(Y):
    stackY.append(qList[i])

for i in range(C):
    if len(stackX)>0:
        x = stackX[-1]
    else:
        x = pow(10,10)

    if len(stackY)>0:
        y = stackY[-1]
    else:
        y = pow(10,10)

    r = rList[i]

    if r <= x and r <= y:
        break
    elif x < y:
        stackX.pop()
        stackR.append(r)
    else:
        stackY.pop()
        stackR.append(r)
print(sum(stackX) + sum(stackY) + sum(stackR))


Measured memory_bytes: 107600
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cfloat>
#include<queue>
using namespace std;
#define SQ(x) ((x)*(x))

struct B { 
	long long x,y,r; 
	double dist(B b) {
		long long sqd = SQ(b.x - x) + SQ(b.y - y);
		if (sqd <= SQ(b.r + r)) return 0;
		return sqrt(sqd) - b.r - r;
	}
};
typedef pair<double, int> P;//cost, to

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long xs, ys, xt, yt, n;
	cin >> xs >> ys >> xt >> yt >> n;
	vector<B> bar(n + 2);
	bar[0] = { xs,ys,0 };
	bar[n+1] = { xt,yt,0 };
	long long xi, yi, ri;
	for (int i = 1; i <= n; ++i) {
		cin >> xi >> yi >> ri;
		bar[i] = { xi,yi,ri };
	}

	vector<vector<double>> g(n + 2,vector<double>(n+2));
	for (int i = 0; i < n + 2; ++i) {
		for (int j = i + 1; j < n + 2; ++j) {
			double d = bar[i].dist(bar[j]);
			g[i][j] = d;
			g[j][i] = d;
		}
	}

	vector<double> d(n+2, DBL_MAX);
	priority_queue<P> que;
	d[0]=0;que.push({0,0});
	while(que.size())
	{
		P p = que.top();que.pop();
		double dist1 = d[p.second];
		if (dist1 < -p.first) continue;
		for (int i = 0; i < n + 2; ++i) {
			if (i == p.second) continue;
			double dist2 = g[p.second][i];
			if (d[i] > dist1 + dist2) {
				d[i] = dist1 + dist2;
				que.push({ -d[i],i });
			}
		}
	}
	cout<<fixed<<setprecision(15)<<d[n+1]<<endl;
	return 0;
}

Measured memory_bytes: 14196
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

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

    int ans = (A * 3 + P) / 2;
 
    cout << ans << endl;

    return 0;
}


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

int main() {
	long long N;
	pair<double, double> P[8];
	double ANS = 0;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> P[i].first >> P[i].second;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j) continue;
			ANS += sqrt((P[i].first - P[j].first) * (P[i].first - P[j].first) + (P[i].second - P[j].second) * (P[i].second - P[j].second));
		}
	}
	printf("%.12lf\n", ANS / (double)N);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    int N;
    cin >> N;
    vector<int> a(N+1);
    int count =0;
    for(int i=1; i<N+1; i++){
        cin >> a.at(i);
        if(i%2==1 && a.at(i)%2==1) count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
int dish[6];
bool compare(int a, int b)
{
	if(a%10 == 0)
		return a%10 > b%10;
	else
		return a%10 < b%10;
}
int main()
{
	for(int i = 0; i < 5; i ++)
		cin >> dish[i];
	sort(dish,dish+5,compare);
	int res = 0;
	res = dish[0];
	for(int i = 1; i < 5; i++)
	{
		if(dish[i]%10 == 0)
			res += dish[i];
		else 
			res += (dish[i]/10 + 1)*10;
	}
	cout << res;
	return 0;
	
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char s[5][5];
	int i, j;
	for (i = 0; i <3; i++)
	{
		for (j = 0; j <= 3; j++)
		{
			scanf("%c",&s[i][j]);
		}
	}
	for (i = 0, j = 0; i < 3; i++, j++)
	{
		printf("%c", s[i][j]);
	}

	return 0;
}

Measured memory_bytes: 128
import Control.Monad
import System.IO

main = do
    eof <- isEOF
    unless eof $ do
        n <- readLn
        print $ length $ do
            a <- [0 .. 9]
            b <- [0 .. 9]
            c <- [0 .. 9]
            d <- [0 .. 9]
            guard (a + b + c + d == n)
            return ()
        main

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

int main() {
	long long int N,i = 1,D,tmp1,tmp2,a,b;
	cin >> N;
	a = 1;
	b = N;
	D = sqrt(N + 1);
	for (i = 2; i <= D; i++) {
		if (N % i == 0) {
			tmp1 = i;
			tmp2 = N / i;
			if (a == 1 && tmp1 - 1 + tmp2 - 1 < a + b - 1) {
				a = tmp1;
				b = tmp2;
			}
			if (a != 1 && tmp1 - 1 + tmp2 - 1 < a - 1 + b - 1) {
				a = tmp1;
				b = tmp2;
			}
		}
	}
	if (a == 1) {
		cout << b - 1 << endl;
	}
	else cout << a - 1 + b - 1 << endl;

    return 0;
	}






Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n = 5;
    vector<int> v(n);
    for(int i=0; i<n; ++i)
        cin >> v[i];

    int k;
    cin >> k;
    if(v[n-1] - v[0] > k)
        cout << ":(" << endl;
    else
        cout << "Yay!" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
multiset<int> Set;
int res=0,n;
int main()
{
	int i,a;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		Set.insert(a);
	}
	while(!Set.empty())
	{
		multiset<int> ::iterator it=Set.end();
		it--;
		int x=*it;
		Set.erase(it);
		for(i=1;i<=x;i*=2);
		if(Set.find(i-x)!=Set.end())
		{
			Set.erase(Set.find(i-x));
			res++;
		}
	}
	cout<<res;
	return 0;
}


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

int main(){
  char c; cin >> c;
  char in[] = {'A', 'C', 'G', 'T'}, ot[] = {'T', 'G', 'C', 'A'};
  for (int i = 0; i < 4; i++){
    if (c == in[i]) cout << ot[i] << endl;
  }
  return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
//ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
//ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}


template <typename T>
class Seg_Tree{
public: // 0-index
  vector<T> dat;
  T initial,M;
  int n;
  T unite(T a,T b){//
    return max(a,b);
  }
  Seg_Tree(int n0_=1,T initial_=1,T M_=1){
    initsize(n0_,initial_,M_);
  }
  void initsize(int n0,T initial_,T M_){
    M = M_;
    initial = initial_;
    int k=1;
    while(1){
      if(n0<=k){
        n=k;
        dat.resize(2*n-1);
        for(int i=0;i<2*n-1;i++)dat[i]=initial;
        break;
      }
      k*=2;
    }
  }
 
  //i banme wo x nisuru
  void update(int i,T x){
    i += n-1;
    dat[i] = x;
    while(i>0){
      i = (i-1) / 2;
      dat[i] = unite(dat[i*2+1],dat[i*2+2]);
    }
  }
 
  //[a,b)
  T query0(int a,int b,int k,int l,int r){
    if(r<=a || b<=l)return initial;
    if(a<=l && r<=b)return dat[k];
    else{
      T vl = query0(a,b,k*2+1,l,(l+r)/2);
      T vr = query0(a,b,k*2+2,(l+r)/2,r);
      return unite(vl,vr);
    }
  }
 
  //return [a,b)
  T query(int a,int b){
    return query0(a,b,0,0,n);
  }
};

int main(){

  int n;
  cin >> n;
  vector<P> x(n);
  map<ll,ll> cnt;
  for(int i=0;i<n;i++){
    cin >> x[i].first;
    x[i].second = i;
    cnt[x[i].first]++;
  }

  sort(x.begin(), x.end());

  Seg_Tree<ll> sg(n,0,MOD);

  for (int i = 0; i < n; ++i){
    queue<ll> ind,v;
    for(int j = 0; j < cnt[x[i].first]; ++j){
      ind.push(x[i+j].second);
      v.push(sg.query(0,x[i+j].second)+1);
    }
    for(int j = 0; j < cnt[x[i].first]; ++j){
      sg.update(ind.front(),v.front());
      ind.pop();
      v.pop();
    }
    i += cnt[x[i].first] - 1;
  }

  cout << sg.query(0,n) << endl;

}



Measured memory_bytes: 12556
import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
import std.numeric;

alias lread = () => readln.chomp.to!long;
alias aryread = () => readln.split.to!(long[]);

void main()
{
    auto hw = aryread();
    long H = hw[0];
    long W = hw[1];
    auto a = new long[][](H, W);
    long[] queue;

    foreach (i; 0 .. H)
    {
        a[i][] = aryread().array();
    }

    long[][] result;

    foreach (y; 0 .. H)
        foreach (x; 0 .. W)
        {
            if (a[y][x] % 2 != 0)
            {
                if (y == H - 1 && x == W - 1)
                {
                    continue;
                }
                else if (y == H - 1)
                {
                    a[y][x]--;
                    a[y][x + 1]++;
                    result ~= [y + 1, x + 1, y + 1, x + 2];
                }
                else
                {
                    a[y][x]--;
                    a[y + 1][x]++;
                    result ~= [y + 1, x + 1, y + 2, x + 1];
                }
            }
        }
    result.length.writeln;
    foreach (r; result)
        "%d %d %d %d".writefln(r[0], r[1], r[2], r[3]);
}


Measured memory_bytes: 18812
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>

#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
using P = std::pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvP = vector<vector<P>>;
using vP = vector<P>;
//using bint = boost::multiprecision::cpp_int;



// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};




int main(){
    
    int h,n;
    cin >> h >> n;
    rep(i,n){
        int a;
        cin >> a;
        h-=a;
    }
    if (h<=0) cout << "Yes";
    else cout << "No";
}



Measured memory_bytes: 256
import bisect
N, M = map(int, input().split())
P, Y = [], []
pref = [[] for _ in range(N+1)] # non-0-indexed
for m in range(M):
    p,y = map(int, input().split())
    P.append(p)
    Y.append(y)
    pref[p].append(y)
for i, p in enumerate(pref):
    pref[i] = sorted(p)
    
for p,y in zip(P,Y):
    ans = "{:0>6}".format(p)
    i = bisect.bisect(pref[p], y)
    ans += "{:0>6}".format(i)
    print(ans)




Measured memory_bytes: 24116
between :: String -> [Int] -> String
between s [a,b] = take (b - a + 1) $ drop a s

print' :: String -> [Int] -> String
print' s x = between s x

reverse' :: String -> [Int] -> String
reverse' s [a,b] = (take a s) ++ (reverse $ between s [a,b]) ++ drop (b + 1) s

replace' :: String -> [Int] -> String -> String
replace' s [a,b] c = (take a s) ++ c ++ drop (b + 1) s

solve :: String -> [[String]] -> [String] -> [String]
solve _ [] plist = plist
solve s ((op:args):xs) plist
  | op == "print"   = solve s xs (print' s (map read args) : plist)
  | op == "reverse" = solve (reverse' s (map read args)) xs plist
  | op == "replace" = solve (replace' s ((map read . init) args) (last args)) xs plist

main = getContents >>= mapM_ putStrLn . reverse . (\(s:_:xs) -> solve s (map words xs) []) . lines

Measured memory_bytes: 5624
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main(){

	int R;
	scanf("%d", &R);
	if (R < 1200){
		printf("ABC\n");
	}
	else if (R < 2800){
		printf("ARC\n");
	}
	else{ printf("AGC\n"); }

	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint W,H,x,y;
  cin>>W>>H>>x>>y;
  cout<<(double)(H*W)/2.0<<" "<<((2*x==W and 2*y==H)?1:0)<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
dp = list(range(N+1))
price = [1]
base = 1
while base<=100000:
    base *= 6
    price.append(base)
base = 1
while base<=100000:
    base *= 9
    price.append(base)

for i in range(1,N+1):
    for p in price:
        if p == i:
            dp[i] = 1
            break
        elif p < i:
            temp = dp[i-p]
            if temp+1 < dp[i]:
                dp[i] = temp+1
print(dp[N])


Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N;
    cin >> N;
    ll div = 2;
    ll cnt = 0;
    while(N / div > 0){
        div *= 2;
        cnt++;
    }
    cout << pow(2,cnt) << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[] arr=new int[] {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};
		long ans=1;
		int[] h=new int[1001];
		for(int j=2;j<=n;j++){
			ans=1;
			int k=j;
			while(true){
				for(int i=0;;i++){
					if(k==arr[i]){h[arr[i]]++;goto f;}
					else if(k%arr[i]==0){
						k/=arr[i];
						h[arr[i]]++;
						break;
					}
				}
			}
			f:;
		}
		foreach(int i in h){if(i>0){ans=((i+1)*ans)%1000000007;}}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
   
   int n;
   cin >> n;

   if(n%1000==0)
   cout << 0 << endl;
   else 
   cout << 1000-(n%1000) << endl;

}

Measured memory_bytes: 3620
#include<stdio.h>

int main(){
    int h, w, a, b;
    scanf("%d %d %d %d", &h, &w, &a, &b);
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if((i<=b&&j<=a)||(i>b&&j>a)){
                printf("1");
            }else{
                printf("0");
            }
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 1152
#include <vector>
#include <iostream>
#define M 1000000007
using namespace std;
long long dp[301][301][301];

int main() {
    int n, m; cin >> n >> m;
    vector<pair<int, int> > cst[301];
    while (m--) {
        int l, r, x; cin >> l >> r >> x;
        cst[r].push_back(make_pair(l, x));
    }
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < max(1, i); j++)
            for (int k = 0; k < max(1, j); k++) {
                bool ok = true;
                for (auto c : cst[i+1]) {
                    int l = c.first, x = c.second;
                    if ((x == 1 && l <= j) ||
                        (x == 2 && (l <= k || l > j)) ||
                        (x == 3 && l > k)) {
                        ok = false;
                        break;
                    }
                }
                if (ok) dp[i+1][j][k] += dp[i][j][k];
                if (dp[i+1][j][k] >= M) dp[i+1][j][k] -= M;

                ok = true;
                for (auto c : cst[i+1]) {
                    int l = c.first, x = c.second;
                    if ((x == 1 && l <= i) ||
                        (x == 2 && l <= k) ||
                        (x == 3 && l > k)) {
                        ok = false;
                        break;
                    }
                }
                if (ok) dp[i+1][i][k] += dp[i][j][k];
                if (dp[i+1][i][k] >= M) dp[i+1][i][k] -= M;

                ok = true;
                for (auto c : cst[i+1]) {
                    int l = c.first, x = c.second;
                    if ((x == 1 && l <= i) ||
                        (x == 2 && (l <= j)) ||
                        (x == 3 && l > j)) {
                        ok = false;
                        break;
                    }
                }
                if (ok) dp[i+1][i][j] += dp[i][j][k];
                if (dp[i+1][i][j] >= M) dp[i+1][i][j] -= M;
            }

    long long ans = 0;
    for (int j = 0; j < n; j++)
        for (int k = 0; k < max(1, j); k++)
            ans += dp[n][j][k];
    cout << ans % M << endl;
}


Measured memory_bytes: 211328
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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


int N, M;
vector<bool> ok;
vector<ll> res;

ll ans(int n) {
  if (!ok[n]) return 0;

  if (n <= 1) {
    return 1;
  } else {
    if (res[n-2] == -1) {
      res[n-2] = ans(n-2);
    }
    if (res[n-1] == -1) {
      res[n-1] = ans(n-1);
    }
    res[n] = (res[n-2] + res[n-1]) % MOD;
    return res[n];
  }
}

int main () {
  cin >> N >> M;
  ok.assign(N+1, true);

  Rep(i, M) {
    int tmp;
    cin >> tmp;
    ok[tmp] = false;
  }

  res.assign(N+1, -1);

  //Rep(i, N+1) {
  //  cout << ans(i) << "\n";
  //}

  cout << ans(N) << "\n";
}

Measured memory_bytes: 3584
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
const double EPS = 1e-12;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define EQ(a,b) (abs((a)-(b)) < EPS)
typedef complex<double> P;
typedef vector<P> G;

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}

double calc(int N){
  int sd = 0.0;
  double sum = 0.0;
  REP(i, N - 1){
    int d; cin >>d;
    sd += d;
    sum += sin(d * M_PI / 180.0);
  }
  sum += sin((360.0 - sd) * M_PI / 180.0);
  return sum;
}

int main() {
  int N;
  while(cin >>N && N){
    double a = calc(N);
    cin >>N;
    double b = calc(N);
    cout <<(EQ(a, b) ? 0 : (a > b ? 1 : 2)) <<endl;
  }
  return 0;
}

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

int main() {
    string s;
    cin >> s;

    bool pass = s.length() % 2 == 0;
    if (pass) {
        for (int i = 0; i + 2 <= s.length(); i += 2)
            pass = pass && s.substr(i, 2) == "hi";
    }

    cout << (pass ? "Yes" : "No");
    return 0;
}


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

int main() {
    int a,b;
    cin >> a >> b;
    if (a > b + 1) {
        cout << a + a - 1 << endl;
    }else if(b > a + 1){
        cout << b + b - 1 << endl;
    }else if(a > b || b > a) {
        cout << a + b << endl;
    }else{
        cout << a + b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef long long ll;

int main(void) {
  ll N,A,B;
  ll out = 0;
  ll i;

  scanf("%lld %lld %lld", &N, &A, &B);

  if (A == 0) goto exit;

  out = (N / (A + B)) * A;
  i = N % (A + B);
  out += ((A - i) < 0) ? A : i;

  exit:
    printf("%lld\n", out);
    return (0);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int i, j, k, n, m, ac, tle, wa, re;
char c[5];
int main(){
    scanf("%d", &n);
    for(i=1; i<=n; i++){
        scanf("%s", c+1);
        if(c[1]=='A'&&c[2]=='C') ac++;
        else if(c[1]=='T'&&c[2]=='L'&&c[3]=='E') tle++;
        else if(c[1]=='W'&&c[2]=='A') wa++;
        else if(c[1]=='R'&&c[2]=='E') re++;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", ac, wa, tle, re);
    return 0;
}

Measured memory_bytes: 3820
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int c[3][3];
	rep(i, 0, 3) rep(j, 0, 3) cin >> c[i][j];

	int a[3], b[3];
	memset(a, 0, sizeof(a));
	memset(b, 0, sizeof(b));

	rep(a1, 0, 101) {
		a[0] = a1;
		b[0] = c[0][0] - a[0];
		rep(a2, 0, 101) {
			a[1] = a2;
			b[1] = c[1][1] - a[1];
			rep(a3, 0, 101) {
				a[2] = a3;
				b[2] = c[2][2] - a[2];
				bool flag = true;
				rep(i, 0, 3) rep(j, 0, 3) {
					if(a[i] + b[j] != c[i][j]) flag = false;
				}
				if(flag) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}

	cout << "No" << endl;
}


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

int main() {
    ll n; cin >> n;
    double d = sqrt((double)n);

    ll minv = n, i;
    //cout << (ll)d << endl;
    for (i = 1; i <= (ll)d; i++) {
        if ( n % i != 0)
            continue;
        
        minv = min((ll)minv, (i + (n / i)) -2);
    }

    if (i == d)
        cout << (n - 1) << endl;
    else
        cout << minv << endl;    
    return 0;
}

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

#define pb push_back
#define ff first
#define ss second

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

int a;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a;
	if (a == 7 || a == 5 || a == 3)
		cout << "YES";
	else
		cout << "NO";
	return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
#define PR pair<double,int>
#define mp make_pair
#define fr first
#define sc second
#define pb push_back
#define lc (x<<1)
#define rc ((x<<1)|1)
const int N=40005;
const double one=1.0;
const double eps0=1e-13,inf=1e9,cinf=8.0;
struct line{
    double k,b,y;
};
double fabs(double x){if (x<0.0) x=-x;return x;}
bool cmp1(line a,line b){
    if (fabs(a.y-b.y)>eps0) return a.y<b.y;
     else return a.k<b.k;
}
line L[N];
int B[N];
int query(int x){int ans=0;while (x) {ans+=B[x];x-=(x&-x);}return ans;}
void modify(int x,const int &n){while (x<=n) {B[x]++;x+=(x&-x);}}
PR A[N];
int cal(const double &mid,const int &n,int ff){
    int i;LL ans=0;
    for (i=1;i<=n;i++) L[i].y=L[i].k*mid+L[i].b;
    sort(L+1,L+n+1,cmp1);
    for (i=1;i<=n;i++) A[i].fr=L[i].k,A[i].sc=i;
    sort(A+1,A+n+1);
    for (i=1;i<=n;i++) B[i]=0;
    for (i=1;i<=n;i++){
        ans+=((LL)query(A[i].sc));
        modify(A[i].sc,n);
    }
    return ans;
}
double work(int n,int ff){
    if (ff==2){
        for (int i=1;i<=n;i++){
            L[i].k=one/L[i].k;
            L[i].b=-L[i].k*L[i].b;
        }
    }
    int T=80;LL nn=n;nn=(nn)*(nn-1)/2;nn=(nn+1)/2;
    double l=-inf,r=inf,mid;
    while (T--){
        mid=(l+r)/2;
        if (cal(mid,n,ff)<nn) l=mid; else r=mid;
    }
    return r;
}
int main(){
   // freopen("in.txt","r",stdin);
   // freopen("out.txt","w",stdout);
    int i,n;
    scanf("%d",&n);
    for (i=1;i<=n;i++){
        double A,B,C;
        scanf("%lf%lf%lf",&A,&B,&C);
        L[i].k=-A/B;L[i].b=C/B;
    }
    double ansx=work(n,1),ansy=work(n,2);
    printf("%.11f %.11f\n",ansx,ansy);
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;


int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    int l = 0;
    int r = INF;
    ll c = a-b;
    while (r-l>1) {
        ll x = (l+r)/2;
        vector<ll> v(n);
        ll num = 0;
        //debug(x);
        rep(i, n) {
            v[i] = h[i] - b*x;
            //debug(v[i]);
            if (v[i]>0) num += (v[i]-1)/c+1;
        }
        //debug(num);
        if (num<=x) r = x;
        else l = x;
    }
    int ans = r;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
int INF=1e9+7;
int main(){
  int M;cin>>M;
  vector<int>A(M+1,1);
  for(int i=1;i<=M;i++){
    int s=i;
    for(int j=2;j<=M;j++){
      while(s%j==0){
        A[j]++;
        s/=j;
      }
    }
  }
  long long ans=1;
  for(int i=1;i<=M;i++){
    ans*=A[i];
    ans%=INF;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int n;
char s[1505][1505];
int rpos[1505][1505],minn[2][1505][1505],maxn[2][1505][1505],tp;
long long sum[1505][1505],ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(int i=n;i>=1;i--)
	{
		tp^=1;
		for(int j=n;j>=1;j--)
		{
			if(s[i][j]!='#')
			{
				sum[i][j]=sum[i+1][j]+sum[i][j+1]+(s[i][j]-'0');
				rpos[i][j]=max(max(rpos[i+1][j],rpos[i][j+1]),i);
				minn[tp][j][i]=j;
				for(int k=i+1;k<=rpos[i+1][j];k++) minn[tp][j][k]=minn[tp^1][j][k];
//				for(int k=i;k<=rpos[i][j+1];k++) minn[tp][j][k]=min(minn[tp][j][k],minn[tp][j+1][k]);
				for(int k=max(rpos[i+1][j],i)+1;k<=rpos[i][j+1];k++) minn[tp][j][k]=minn[tp][j+1][k];
				maxn[tp][j][i]=j;
				for(int k=i;k<=rpos[i][j+1];k++) maxn[tp][j][k]=maxn[tp][j+1][k];
//				for(int k=i+1;k<=rpos[i+1][j];k++) maxn[tp][j][k]=max(maxn[tp][j][k],maxn[tp^1][j][k]);
				for(int k=max(rpos[i][j+1],i)+1;k<=rpos[i+1][j];k++) maxn[tp][j][k]=maxn[tp^1][j][k];
				int d=i+1,r=min(rpos[i+1][j],rpos[i][j+1]);
				while(d<=r)
				{
					if(maxn[tp^1][j][d]>=minn[tp][j+1][d])
					{
						sum[i][j]-=sum[d][minn[tp][j+1][d]];
						d=rpos[d][minn[tp][j+1][d]];
					}
					d++;
				}
				ans+=(s[i][j]-'0')*(sum[i][j]-(s[i][j]-'0'));
			}
		}
	}printf("%lld\n",ans);
}

Measured memory_bytes: 67796
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define pi 3.14159265358979323846
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    int n;
    cin>>n;
    int cnt=0;

    for(int i=1;i<n;i++)
    {
        cnt+=(n-1)/i;
    }
    cout<<cnt<<endl;
    return 0;
}


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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  string s;

  void init() {
    cin >> s;
  }

  void solve() {
    if(s[0] == '7' || s[1] == '7' || s[2] == '7') printf("Yes\n");
    else printf("No\n");
  }
}

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

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define min(a, b) (a > b ? b : a)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll nck(int n, int k) { ll ret = 1; rep(i, k) {ret *= n - i; ret /= i + 1; } return ret; } // n <= 60
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int n;
vector<vector<pii> > v;
int color[100001];

void bfs() {
    queue<pii> q;
    q.push(pii{0, 1});
    while (!q.empty()) {
        int now = q.front().F;
        int cost = q.front().S;
        q.pop();
        
        for (auto vi : v[now]) {
            if (color[vi.F]) continue;
            int newcost = (cost + vi.S) % 2;
            q.push(pii{vi.F, newcost});
            color[vi.F] = (newcost == 0 ? 1 : 2);
        }
    }
    
}
void solve() {
    
    bfs();
    
    rep(i, n) out(color[i] - 1);
    
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    v.resize(n);
    
    rep(i, n - 1) {
        int u, V, w;
        cin >> u >> V >> w;
        u--; V--;
        v[u].eb(pii{V, w});
        v[V].eb(pii{u, w});
    }
    
    
    solve();
}



Measured memory_bytes: 6784
#include <iostream>
using namespace std;
int main(){
    int x,count=0;
    while(cin>>x){
    if(x==0)break;
    count+=x/5;
    count+=x/25;
    count+=x/125;
    count+=x/625;
    count+=x/3125;
    count+=x/15625;
    cout<<count<<endl;
    count=0;
    }
}

Measured memory_bytes: 3068
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    s = S()

    if 'A' <= s <= 'Z':
        return 'A'

    return 'a'


print(main())




Measured memory_bytes: 10944