akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

#define int long long
const int N = 1e5+5;
int n, ans = 0, par[N];

struct point
{
    int x,y,id;
};

struct edge
{
    int u,v,w;
};

bool cmp_x(point a, point b)
{
    return a.x < b.x;
}

bool cmp_y(point a, point b)
{
    return a.y < b.y;
}

bool cmp(edge a, edge b)
{
    return a.w < b.w;
}
int dist(point a, point b)
{
    return min(abs(a.x-b.x),abs(a.y-b.y));
}

void init()
{
    for (int i = 0; i < n; i++)
        par[i] = i;
}

int findSet(int i)
{
    if (i == par[i])
        return i;
    return (par[i] = findSet(par[i]));
}

bool isSameSet(int i, int j)
{
    return (findSet(i) == findSet(j));
}

void unionSet(int i, int j)
{
    if (!isSameSet(i,j))
    {
        par[findSet(i)] = findSet(j);
    }
}

point tmp_x[N], tmp_y[N];
vector<edge> ve;

signed main()
{
    int x,y;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        tmp_x[i] = tmp_y[i] = {x,y};
        tmp_x[i].id = i;
        tmp_y[i].id = i;
    }
    sort(tmp_x,tmp_x+n,cmp_x);
    sort(tmp_y,tmp_y+n,cmp_y);
    for (int i = 0; i < n-1; i++)
    {
        ve.push_back({tmp_x[i].id, tmp_x[i+1].id, dist(tmp_x[i],tmp_x[i+1])});
        ve.push_back({tmp_y[i].id, tmp_y[i+1].id, dist(tmp_y[i],tmp_y[i+1])});
    }
    sort(ve.begin(),ve.end(),cmp);
    init();
    for (auto e: ve)
    {
        int u = e.u, v = e.v, w = e.w;
        if (!isSameSet(u,v))
        {
            unionSet(u,v);
            ans += w;
        }
    }
    cout << ans;
}


Measured memory_bytes: 13296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

/* modとる */
inline ll modu(ll a){
    return(a % mod + mod) % mod;
}

/* modつき二項係数 前処理必要*/
const ll binomialmax = 510000;
ll fac[binomialmax], finv[binomialmax], inv[binomialmax];

void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < binomialmax; i++){
        fac[i] = modu(fac[i - 1] * i);
        inv[i] = modu(-inv[mod%i] * (mod / i));
        finv[i] = modu(finv[i - 1] * inv[i]);
    }
}

/* 二項係数計算 */
ll com(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return modu(fac[n] * (modu(finv[k] * finv[n - k])));
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    cominit();
    int N = in();
    int K = in();
    vector<ll> A(N);
    REP(i,N)A[i] = in<ll>();
    sort(ALL(A),greater<>());
    ll answer = 0;
    for(int i = 0;N-1-i >= K-1;i++){
        answer += modu((A[i]- A[N-1-i])*com(N-i-1,K-1));
        answer = modu(answer);
    }
    cout << answer << "\n";
}


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

int main(){
    
    double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    double x= (x1 - x2)*(x1 - x2);
    double y= (y1 - y2)*(y1 - y2);
    double d= x + y;
    
    printf("%f\n", sqrt(d));
    
    return 0;
}


Measured memory_bytes: 3184
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const llint INF = 100000000;

int main() {
	string s;
	cin >> s;
	int ans = 0;
	int cnt = 0;
	rep(i, 0, 3) {
		if (s[i] == 'R')cnt++;
		else cnt = 0;
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int r;
    cin >> r;
    
    if (r < 1200) cout << "ABC" << endl;
    else if (r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}

Measured memory_bytes: 256
S = input()
T = input()
s = len(S)
t = len(T)
l1 = [] 
l2 = []
n = 0
for i in range(n, s-t+1): 
    ss = S[n:t + n]
    n += 1
    m = 0
    for x in ss:       
        if x == T[m]:
            l1.append(1)
            m +=1
        elif x != T[m]:
            l1.append(0)
            m +=1   
    l2.append(sum(l1))
    l1 = [ ]
print(t - max(l2)) 

Measured memory_bytes: 9156
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
    int *A,*B;
    int C[VMAX+1];
    int n,i,j;
    scanf("%d",&n);
    A =(int *)malloc(sizeof(int)*n+1);
    B=(int *)malloc(sizeof(int)* n+1);
    
    for(i=0;i<VMAX+1;i++) C[i]=0;
    for( i=0;i<n;i++){
        scanf("%d",&A[i+1]);
        C[A[i+1]]++;
    }
    for( i=1;i<VMAX+1;i++){
        C[i] +=C[i-1];
    }
    for( j=n;j>0;j--){
        B[C[A[j]]]=A[j];
        C[A[j]]--;
    }
    for( j=1;j<=n;j++){
        if(j != 1)putchar(' ');
        printf("%d",B[j]);
    }
    putchar('\n');
    return 0;
}



Measured memory_bytes: 17456
<?php

    $X = intval(trim(fgets(STDIN)));
    
    for($i=$X;$i<INF;$i++){
        $flg=false;
        
        for($j=2;$j<=$i/2;$j++){
            if($i%$j==0){
                $flg=true;
                break;    
            }
        }
        if($flg==false){
            echo $i;
            exit;
        }
    }
?>

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

#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,m,n) for(int i = m;i < n;i++)
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n;
    cin>>n;

    map <string,int>st;

    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        st[s]++;
    }

    int m;
    cin>>m;

    for(int i=0;i<m;i++){
        string s;
        cin>>s;
        st[s]--;
    }

    int ans=0;
    for(auto itr = st.begin();itr!=st.end();itr++){
        ans=max(ans,itr->second);
    }

    cout<<ans<<endl;

    return 0;
}




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

int main(){
    int h,w;
    cin >> h >> w;
    char a[h][w];
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
        }
    }
    rep(i,w+2) cout << "#";
    cout << endl;
    rep(i,h){
        cout << "#";
        rep(j,w){
            cout << a[i][j];
        }
        cout << "#" << endl;
    }
    rep(i,w+2) cout << "#";
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

class Node {
public:
	int p, d = -1;
};

class Edge {
public:
	int v, u, d;
};

int n, V[100], e = 0;
Edge E[5000];

void Path() {
	V[0] = 0; for (int i = 1; i < n; i++)  V[i] = -1;
	for (int a = 1; a < e; a++) {
		for (int i = 0; i < e; i++) {
			if (V[E[i].u] == -1 && V[E[i].v] != -1 || V[E[i].u] > V[E[i].v] + E[i].d && V[E[i].v] != -1) {
				V[E[i].u] = V[E[i].v] + E[i].d;
			}
		}
	}
}

int main() {
	int u, k, v, c;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v >> c;
			E[e].v = u; E[e].u = v; E[e].d = c; e++;
		}
	}

	Path();

	for (int i = 0; i < n; i++) cout << i << " " << V[i] << endl;
}


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

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

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int k;
	cin>>k;
	int x=7%k;
	forn(i,1,k+10){
		if (x==0){
			cout<<i<<endl;
			return 0;
		}
		x=(10*x+7)%k;
	}
	cout<<-1<<endl;
	return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

template<class NUMBER>
struct Point {
    NUMBER x, y;
    Point (NUMBER x, NUMBER y) : x(x), y(y) {}
    Point () = default;

    Point operator + (const Point & point) const {
        return Point(x + point.x, y + point.y);
    }
    Point operator - (const Point & point) const {
        return Point(x - point.x, y, - point.y);
    }
    Point operator * (const NUMBER d) const {
        return Point(x * d, y * d);
    }
    Point operator / (const NUMBER d) const {
        return Point(x / d, y / d);
    }
    Point& operator += (const Point & point) {
        x += point.x;
        y += point.y;
        return *this;
    }
    Point& operator -= (const Point & point) {
        x -= point.x;
        y -= point.y;
        return *this;
    }
    Point& operator *= (const NUMBER d) {
        x *= d;
        y *= d;
        return *this;
    }
    Point& operator /= (const NUMBER d) {
        x /= d;
        y /= d;
        return *this;
    }
    bool operator < (const Point& point) const {
        return x < point.x && y < point.y;
    }
};

signed main(){
    int H, W, K;
    cin >> H >> W >> K;
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    vector<vector<char>> grids(H+1, vector<char>(W+1));
    rep(i,1,H+1) rep(j,1,W+1) cin >> grids[i][j];
    vector<vector<int>> distances(H+1, vector<int>(W+1, INT_MAX));
    priority_queue<pair<int, Point<int>>, vector<pair<int, Point<int>>>, greater<>> que;
    if (grids[x1][y1] != '@') {
        distances[x1][y1] = 0;
        que.push({0, {x1, y1}});
    }
    const auto isValid = [H, W](const Point<int>& point) -> bool { return point.x >= 1 && point.y >= 1 && point.x <= H && point.y <= W;};
    while (!que.empty()) {
        auto distance = que.top().first;
        auto base = que.top().second;
        que.pop();
        vector<Point<int>> directions = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
        for (const auto& direction : directions) {
            auto current = base;
            rep(i,0,K) {
                current += direction;
                if (!isValid(current) || grids[current.x][current.y] == '@') break;
                if (distances[current.x][current.y] <= distance) break;
                if (distances[current.x][current.y] > distance+1) {
                    distances[current.x][current.y] = distance+1;
                    que.push({distance+1, current});
                }
            }
        }
    }
    int answer = distances[x2][y2];
    cout << (answer == INT_MAX ? -1 : answer) << endl;
    return 0;
}


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


using namespace std;


unsigned long long lucas[90];


int main() {

	int n;
	cin >> n;
	lucas[0] = 2;
	lucas[1] = 1;
	for(int i=2;i<=n;i++)
		lucas[i] = lucas[i-1]+lucas[i-2];
	cout << lucas[n];


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	int mi = 0;
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		cin>>a[i];
		sum += abs(a[i]);

		if (a[i] < 0) {
			mi++;
		}
	}

	if (mi % 2 == 0) {
		cout << sum << endl;
	} else {
		int mn = 1010101010;
		for (int i = 0; i < n; i++) {
			mn = min(mn, abs(a[i]));
		}
		cout << sum - mn * 2 << endl;
	}

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
vector <double> p;
double ans;
int main()
{
    int n;
    cin>>n;
    p.resize(n+1);
    for(int i=1;i<=n;i++)
        cin>>p[i];
    vector < vector<double> >dp(n+1,vector <double> (n+1));
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
        dp[i][0]=dp[i-1][0]*(1-p[i]);
    for(int i=1;i<=n;i++)
        dp[0][i]=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
    for(int i=(n+1)/2;i<=n;i++)
        ans+=dp[n][i];
    printf("%0.10f\n",ans);
}


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

int main() {
    int r, c, t[101][101];

    cin >> r >> c;
    rep(i,r)
        rep(j,c) cin >> t[i][j];

    for (int i = 0; i <= r; i++) t[i][c] = 0;
    for (int j = 0; j <= c; j++) t[r][j] = 0;

    rep(i,r) {
        rep(j,c) {
            t[i][c] += t[i][j];
            t[r][j] += t[i][j];
            t[r][c] += t[i][j];
        }
    }

    for (int i = 0; i <= r; i++) {
        for (int j = 0; j <= c; j++) {
            if (j) cout << ' ';
            cout << t[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3144
#include <stdio.h>
int n, x, y, ans;
int p[6];
int t[10][10];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		x = i;
		y = 0;
		while (x) {
			p[y] = x % 10;
			x /= 10;
			y++;
		}
		t[p[0]][p[y - 1]]++;
	}
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			ans += t[i][j] * t[j][i];
		}
	}
	printf("%d\n", ans);
}

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

int main() {
  string s;
  
  vector<vector<int> > data(26); //26*0のジャグ配列data
  for (int i=0; ; ){
    if (cin.eof()) break;
    getline(cin, s);
    for (int i=0; i<s.size(); i++) {
      if (isalpha(s.at(i)) && isupper(s.at(i))) {
        char a = tolower(s.at(i));
        int number = a - 'a';
        data.at(number).push_back(number);
      }
      else if (isalpha(s.at(i)) && islower(s.at(i))) {
        int number = s.at(i) - 'a';
        data.at(number).push_back(number);
      }
    }
  }
  
  string alpha = "abcdefghijklmnopqrstuvwxyz";
  vector<string> alist(26); //アルファベット倉庫
  for (int i=0; i<26; i++) {
    alist.at(i) = alpha.at(i);
  }
  
  for (int i=0; i<26; i++) {
    cout << alist.at(i) << " : " << data.at(i).size() << endl;
  }
  
  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}

ll* bun;
ll* paty;
int n;
ll x;

ll f(int a, ll b){
	if(a==0) return 1;
	if(b==1) return (a==0)? 1: 0;
	ll m=bun[a-1];
	if(b <=m+1) return f(a-1,b-1);
	else if(b == m+2) return f(a-1,b-1)+1;
	else return  paty[a-1]+1+f(a-1,b-m-2);
	
}
// BBBPPPBPBPPPBBPBBPP 50 4321098765432109PBPBPPPBB B

int main(){
	startTime=clock();
	cin >> n >> x;
	
	bun=new ll[n+1];
	paty=new ll[n+1];
	bun[0]=1;
	paty[0]=1;
	for(int i=1;i < n+1;i++){
		bun[i]=bun[i-1]*2+3;
		paty[i]=paty[i-1]*2+1;
	}	
	
	cout << f(n,x);

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _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 rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main() {
    int n;
    cin >> n;
    if (n == 1) {
        cout << 1 << endl;
        exit(0);
    }
    vector<int> x(n), y(n);
    rep (i, n) {
        cin >> x[i] >> y[i];
    }
    map<P, int> cand;
    rep (i, n) {
        rep (j, n) {
            if (i == j) continue;
            int p = x[i] - x[j];
            int q = y[i] - y[j];
            cand[make_pair(p, q)]++;
        }
    }
    int ans = 1e9+7;
    for (auto au: cand) {
        P p = au.first;
        int q = au.second;
        chmin(ans, n - q);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
    int N,T;
    int c,t;
    int BEST = 1001;
    cin >> N >> T;
    for(int i=0;i<N;i++){
        cin >> c >> t;
        if(t<=T){
            if(c<BEST){
                BEST = c;
            }    
        }
    }
    if(BEST == 1001){
        cout << "TLE" << endl;
    }
    else{
        cout << BEST << endl;
    }
    return 0;
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 1e5+5;
struct query { int i,v,ans; } Q[maxn];

bool cmp1(const query& a, const query& b)
{ return a.v < b.v; }

bool cmp2(const query& a, const query& b)
{ return a.i < b.i; }

int main()
{
/* #ifdef foo_ */
/*     freopen("foo", "rt", stdin); */
/* #endif */
/*     ios::sync_with_stdio(false); */
    int h,a;
    while (cin >> h >> a) {
        const int ans = (h+a-1)/a;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[110000];
int c[110000];
int d[110000];
int z[110000];
int bit[110000];
int sum(int a,int b){
	if(a)return sum(0,b)-sum(0,a-1);
	int ret=0;
	for(;b>=0;b=(b&(b+1))-1)ret+=bit[b];
	return ret;
}
void add(int a,int b){
	for(;a<110000;a|=a+1)bit[a]+=b;
}
int e[110000];
int f[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",b+i);
		e[i]=b[i];
	}
	std::sort(e,e+a);
	for(int i=0;i<a;i++)f[i]=lower_bound(e,e+a,b[i])-e;
	for(int i=0;i<a;i++){
		b[i]=f[i]%2;
	}
	/*
	int C=0;
	int D=0;
	for(int i=0;i<a;i++){
		if(i%2==0)c[C++]=b[i];
		else d[D++]=b[i];
	}
	std::sort(c,c+C);
	std::sort(d,d+D);
	for(int i=0;i<a;i++){
		if(i%2==0)b[i]=c[i/2];
		else b[i]=d[i/2];
	}
	for(int i=0;i<a;i++)z[i]=b[i];
	std::sort(z,z+a);
	for(int i=0;i<a;i++)b[i]=lower_bound(z,z+a,b[i])-z;
	*/
	long long ret=0;
	int at=0;
	for(int i=0;i<a;i++){
	//printf("%d\n",b[i]);
		if(b[i]==0&&i%2){
		ret++;
		}
	//	ret+=sum(b[i]+1,109999);
	//	add(b[i],1);
	}
	printf("%lld\n",ret);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int factor[114], two, four, onefour, twofour, sevenfour;

// 素因数分解
void prime_factor(int n){
	for(int i=2; i*i<=n; ++i){
		if(n%i!=0){
			continue;
		}
		while(n%i==0){
			++factor[i];
			n/=i;
		}
	}
	if(n!=1){
		++factor[n];
	}
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	FOR(i, 2, n+1){
		prime_factor(i);
	}
	FOR(i, 2, n+1){
		if(factor[i]>=2){
			++two;
		}
		if(factor[i]>=4){
			++four;
		}
		if(factor[i]>=14){
			++onefour;
		}
		if(factor[i]>=24){
			++twofour;
		}
		if(factor[i]>=74){
			++sevenfour;
		}
	}
	int ans=0;
	// (1+74)
	ans+=sevenfour;
	// (1+2)*(1+24)
	ans+=twofour*(two-1);
	// (1+4)*(1+14)
	ans+=onefour*(four-1);
	// (1+2)*(1+4)*(1+4)
	ans+=four*(four-1)/2*(two-2);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
#include <sstream>
 
#include <algorithm>
#include <cmath>
 
#include <string>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <valarray>

#include<cassert>//assert();
//#include <random>//xAOJ
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
/////////
using namespace::std;
/////////
/////////

int num2(int lim,int sum){
	//2数の場合
	int ret;
	if(2*lim < sum ){
		ret = 0;
	}else if( lim >= sum ){
		ret = sum + 1;
	}else{
		ret = 2*lim-sum+1;
	}
	return ret;
}

void solve(){
	int lim,sum;
	cin >> lim >> sum;
	int count = 0;
	for(int A=0;A<=lim;A++){
		if( sum-A < 0 ){break;}
		count += num2(lim,sum-A);
	}
	cout << count << endl;
}

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(16);//
	
	solve();
	
	return 0;
}


Measured memory_bytes: 384
/* MaTb3aa */
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
const int N = 100005;
vector<int>v;
ll dp[100005][4];
int A[N], B[N], C[N];
ll solve(int i,int lst) {
	if (i == n)return 0;
	ll& ret = dp[i][lst];
	if (~ret)return ret;
	if (lst != 1)ret = max(ret, solve(i + 1, 1) + A[i]);
	if (lst != 2)ret = max(ret, solve(i + 1, 2) + B[i]);
	if (lst != 3)ret = max(ret, solve(i + 1, 3) + C[i]);
	return ret;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> A[i] >> B[i] >> C[i];
	memset(dp, -1, sizeof dp);
	cout << solve(0, 0);
	
		 
}

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <deque>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
const int MAX = 1e5;
const int INF = 1e8;
int K;
int d[MAX];

int bfs() {
	deque<int> deq;
		rep(i, K) d[i] = INF;
	deq.push_front(1);
	d[1] = 1;

		while (true) {
			int p = deq.front();
			deq.pop_front();

			if (p == 0)break;

			int pt = (10 * p) % K;
			if (d[pt] >d[p]) {
				deq.push_front(pt);
				d[pt] = d[p];
			}

			int pp = (p + 1) % K;
			if (d[pp] >d[p]) {
				deq.push_back(pp);
				d[pp] = d[p] + 1;
			}
		}
	return d[0];
}

int main() {
	cin >> K;

	int res = bfs();
	cout << res;
}

Measured memory_bytes: 896
#include <stdio.h>

#include <iostream>
#include <vector>
using namespace std;
int main() {
    int N;
    cin >> N;

    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int counter = 0;
    int current = 1;
    for (int i = 0; i < N; i++) {
        if (a[i] != current) {
            counter++;
        } else {
            current++;
        }
    }
    if (current == 1) {
        cout << -1 << endl;
    } else {
        cout << counter << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

#define WIDTH 6
#define HEIGHT 12

enum { YET, ALREADY };

int deleteBlock( void );
int findGroup( int, int );
int findGroup_body( int, int, int );
void fallBlock( void );

typedef struct {
	int color;
	int state;
} FIELD;

FIELD field[ WIDTH ][ HEIGHT ];
const int dx[ 4 ] = { -1, 0, 1, 0 }, dy[ 4 ] = { 0, -1, 0, 1 };

int stack[ WIDTH * HEIGHT ];
int sp;

int main( void ) {
	int x, y, n, chain;

	scanf( "%d%*c", &n );
	while ( n-- ) {
		for ( y = 0; y < HEIGHT; y++ ) {
			for ( x = 0; x < WIDTH; x++ ) {
				scanf( "%c", &field[ x ][ y ].color );
				field[ x ][ y ].state = YET;
			}

			scanf( "%*c" );
		}

		for ( chain = 0; deleteBlock(); chain++ )
			fallBlock();

		printf( "%d\n", chain );
	}

	return 0;
}

int deleteBlock( void ) {
	int x, y, del;

	del = 0;
	for ( x = 0; x < WIDTH; x++ )
		for ( y = 0; y < HEIGHT; y++ )
			if ( field[ x ][ y ].color != '.' && field[ x ][ y ].color != 'O' && field[ x ][ y ].state == YET ) {
				sp = 0;
				if ( findGroup( x, y ) >= 4 ) {
					while ( sp-- )
						field[ stack[ sp ] / HEIGHT ][ stack[ sp ] % HEIGHT ].color = '.';

					del = 1;
				}
			}

	return del;
}

int findGroup( int x, int y ) {
	return findGroup_body( x, y, field[ x ][ y ].color );
}

int findGroup_body( int x, int y, int color ) {
	int i, sum;

	stack[ sp++ ] = x * HEIGHT + y;
	field[ x ][ y ].state = ALREADY;

	sum = 0;
	for ( i = 0; i < 4; i++ ) {
		int nx = x + dx[ i ], ny = y + dy[ i ];

		if ( nx >= 0 && nx < WIDTH && ny >= 0 && ny < HEIGHT && field[ nx ][ ny ].state == YET && ( field[ nx ][ ny ].color == color || field[ nx ][ ny ].color == 'O' ) )
			if ( field[ nx ][ ny ].color == 'O' )
				stack[ sp++ ] = nx * HEIGHT + ny;
			else
				sum += findGroup_body( nx, ny, color );
	}

	return sum + 1;
}

void fallBlock( void ) {
	int x, y, cnt;

	for ( x = 0; x < WIDTH; x++ ) {
		cnt = 0;
		for ( y = HEIGHT - 1; y >= 0; y-- )
			if ( field[ x ][ y ].color == '.' )
				cnt++;
			else {
				field[ x ][ y + cnt ].color = field[ x ][ y ].color;
				field[ x ][ y + cnt ].state = YET;
			}

		for ( y = cnt - 1; y >= 0; y-- )
			field[ x ][ y ].color = '.';
	}
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int n,m,ans,A,B,C;
int main()
{
	scanf("%d%d%d%d",&A,&B,&C,&n);
	m=min(A,n);
	ans+=m;
	n-=m;
	m=min(B,n);
	n-=m;
	m=min(C,n);
	ans-=m;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
#include <stack>


int main (void){
	std::string s;

	std::cin >> s;


	int ans = 0;
	bool flag = true;
	for (size_t i = 1; i < s.length(); i++)
	{
		ans += 9;
		if (s[i] != '9') {
			flag = false;
		}
	}
	
	if (flag) {
		ans += s[0] - '0';
	}
	else {
		ans += s[0] - '1';
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))

s=sorted(p)
cnt=0

def jud(p,s,n,cnt):
    # print(p,s)
    for i in range(n):
        if s[i]!=p[i]:
            cnt+=1
        if cnt>2:
            return "NO"
    return "YES"

print(jud(p,s,n,cnt))

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

int gcd(int x,int y){
	int num;
	while(x % y != 0){
		num = x%y;
		x = y;
		y = num;
	}
	return y;
}


int main(){
	int a,b,c,d;
	while(cin >> a >>b){
		c = gcd(a,b);
		d = a / c * b;
		cout << c<<" "<<d<<endl;
	}
	
}

Measured memory_bytes: 1160
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		Arrays.setAll(h, i -> sc.nextInt());
		
		long[] dp = new long[n];
		dp[0] = 0;
		dp[1] = Math.abs(h[0] - h[1]);
		for (int i = 2; i < n; i++)
			dp[i] = Math.min(dp[i-2] + Math.abs(h[i-2] - h[i])
			               , dp[i-1] + Math.abs(h[i-1] - h[i]));
		
		System.out.println(dp[n-1]);
		
		sc.close();
	}
}



Measured memory_bytes: 51248
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAXN 100004
int N, K;
int H[MAXN];

const int INF = 1000000010;
int memo[MAXN];
int go(int n) {
   if (n == N)
      return 0;
   int& res = memo[n];
   if (res < 0) {
      res = INF;
      FOR(k, 1, K) {
         if (n+k > N) break;
         res = min(res, go(n+k) + abs(H[n]-H[n+k]));
      }
   }
   return res;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   cin >> N >> K;
   FOR(i, 1, N)
      cin >> H[i];

   memset(memo, -1, sizeof(memo));
   int res = go(1);
   cout << res << '\n';

   return 0;
}


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

int main() {
  double x, h;
  while (cin >> x >> h) {
    if (x == 0 && h == 0) break;
    cout << fixed << setprecision(8)
         << x * x + x * hypot(h, x / 2) * 2 << "\n";
  }
}


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

int cnt[200010];

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

  int a;
  for (int i=0; i<n; i++) {
    scanf("%d",&a);
    cnt[a]++;
  }

  sort(cnt,cnt+200000,greater<int>());

  int sum=0;
  for (int i=0; i<k; i++) {
    sum += cnt[i];
  }

  cout << n-sum << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>
#include <map>

using namespace std;


int main() {

	//input
	string S;
	cin >> S;

	string ans = "";

	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == '9') {
			ans.push_back('1');
		}
		else if (S[i] == '1') {
			ans.push_back('9');
		}
	}

	cout << ans << endl;

	return 0;
}

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

signed main() {
    int n,m;
    cin >> n >> m;

    priority_queue<int> que;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        que.push(a);
    }

    for(int i = 0; i < m; i++){
        int x = que.top();
        que.pop();
        x /= 2;
        que.push(x);
    }

    int ans = 0;
    while(!que.empty()){
        int x = que.top();
        que.pop();
        ans += x;
    }
    cout << ans << endl;

}

Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL INF=1e18;
LL N,P,ans,i,j,cnt;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N>>P;
    ans=1;
    for(i=2;i*i<=P;i++)
    {
        cnt=0;
        while(P%i==0)
        {
            cnt++;
            P/=i;
        }
        cnt/=N;
        for(j=0;j<cnt;j++)
            ans*=i;
    }
    if(N==1)
        ans*=P;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans = 0;
    if(a!=0)
    ans = b/x - (a-1)/x;
    else ans = b/x + 1;
    cout << ans << endl;
    return 0;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int n, ma, mb;

struct Info {
  int a;
  int b;
  int cost;
};


// asc sort
bool cmp(const Info &x, const Info &y)
{
  return x.cost < y.cost;
}

vector<Info> v;
int dp[100][401][401];

int res = INT_MAX;

void dp_init(){
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 401; j++) {
      for (int k = 0; k < 401; k++) {
        dp[i][j][k] = INT_MAX;
      }
    }
  }
  dp[0][0][0] = 0;
}

void dfs(int step, int a, int b, int sum){
  if(step == n) return;
  if(a * mb == b * ma && a != 0 && b != 0){
    res = min(res, sum);
    return;
  }
  dfs(step+1, a, b, sum);
  dfs(step+1, a + v[step].a, b + v[step].b, sum + v[step].cost);
}


int main(){
  dp_init();

  cin >> n >> ma >> mb;
  for (int i = 0; i < n; i++) {
    int tmp1, tmp2, tmp3;
    cin >> tmp1 >> tmp2 >> tmp3;
    Info tmp = {tmp1, tmp2, tmp3};
    v.push_back(tmp);
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 400; j++) {
      for (int k = 0; k < 400; k++) {
        if(dp[i][j][k] == INT_MAX) continue;
        dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
        dp[i+1][j+v[i].a][k+v[i].b] =
          min(dp[i+1][j+v[i].a][k+v[i].b], dp[i][j][k] + v[i].cost);
      }
    }
  }

  for (int i = 1; i < 401; i++) {
    for (int j = 1; j < 401; j++) {
      if(i * mb == j * ma)
        res = min(res, dp[n][i][j]);
    }
  }

  if(res != INT_MAX) cout << res << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 63104
package main

import "fmt"

func main() {
	var s string
	_, _ = fmt.Scan(&s)
	
	var answer string
	if s == "Rainy" {
		answer = "Sunny"
	} else if s == "Sunny" {
		answer = "Cloudy"
	} else {
		answer = "Rainy"
	}
	
	fmt.Println(answer)
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K,Q=MI()
    L=[K-Q]*N
    for i in range(Q):
        a=I()
        a-=1
        L[a]+=1
        
    for i in range(N):
        if L[i]>0:
            print("Yes")
        else:
            print("No")

main()


Measured memory_bytes: 75908
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let _n = it.next().unwrap().parse::<usize>().unwrap();
    let s = it.next().unwrap().as_bytes();
    let mut res = 0;
    for i in 0..1000 {
        let mut m : u32 = i;
        let mut cnt = 0;
        for &c in s {
            if c == b'0' + (m%10) as u8 {
                cnt += 1;
                m /= 10;
            }
        }
        if cnt >= 3 { res += 1; }
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
import itertools


n = int(input())
geo = [tuple(map(int, input().split())) for _ in range(n)]

def get_dist(town1, town2):
    return ((town1[0]-town2[0]) ** 2 + (town1[1]-town2[1]) ** 2) ** 0.5

ans = 0
for root in itertools.permutations([i for i in range(n)]):
    root_dist = 0
    for i in range(1, len(root)):
        root_dist += get_dist(geo[root[i-1]], geo[root[i]])
    ans += root_dist
print(ans / len(list(itertools.permutations([i for i in range(n)]))))






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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

//拡張ユークリッドの互除法
int extgcd(int a, int b, int& x, int& y) {
    int d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

// mod逆元
int mod_inverse(int a, int m) {
    int x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

// 階乗、階乗逆元テーブル
int fact[1100000], fact_inv[1100000];
int mod_fact(int n, int m) {
    fact[0] = fact_inv[0] = 1;
    for (int i = 1; i <= n; i++) {
        (fact[i] = fact[i - 1] * i) %= m;
        fact_inv[i] = mod_inverse(fact[i], m);
    }
}

int N;
int mod = 1e9 + 7;
int f[1100000];

signed main() {
    cin >> N;
    mod_fact(N, mod);
    int K = N / 2 + N % 2;
    for (int i = K; i <= N - 1; i++) {
        f[i] = fact[i - 1] * fact[i] % mod * fact_inv[2 * i - N] % mod;
    }
    int ans = f[K] * K % mod;
    for (int i = K + 1; i <= N - 1; i++) {
        (ans += (f[i] - f[i - 1] + mod) % mod * i) %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 23168
//--------------------------------------------------template----------------------------------------//
//c
#include <stdio.h>
#include <time.h>
#include <math.h>
//c++
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <complex>
#include <cmath>
//c++11
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.rbegin(),v.rend())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
double a, b, c, d, e, f;
double x, y;
int main() {
	while (cin >> a >> b >> c >> d >> e >> f) {
		x = (c*e - b*f) / (a*e - b*d);
		y = (c - a*x) / b;
		if (x == -1 * x)x = 0.000;
		if (y == -1 * y)y = 0.000;
		printf("%.3f %.3f\n", x, y);
	}
}

Measured memory_bytes: 3236
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
use whiteread::parse_line;
use std::collections::HashMap;

struct Obs {
    h: usize,
    is_toll: bool,
}

fn main() {
    // N 展望台の数 M ルートの数
    let (n, m): (usize, usize) = parse_line().unwrap();
    // H[N] 展望台の高さ
    let h_list: Vec<usize> = parse_line().unwrap();
    let mut obs_list: Vec<Obs> = Vec::with_capacity(n);

    // 構造体の初期化
    for idx in 0..n {
        obs_list.push(Obs{ 
            h: h_list[idx],
            is_toll: true,
        });
    }

    // 高さの算出
    for _ in 0..m {
        let (a, b): (usize, usize) = parse_line().unwrap();
        if obs_list[a - 1].is_toll {
            obs_list[a - 1].is_toll = obs_list[a - 1].h > obs_list[b - 1].h;
        }
        if obs_list[b - 1].is_toll {
            obs_list[b - 1].is_toll = obs_list[b - 1].h > obs_list[a - 1].h;
        }
    }

    let mut count = 0;
    for obs in obs_list {
        if obs.is_toll {
            count = count + 1;
        }
    }

    print!("{}", count);
}

Measured memory_bytes: 4344
S = "0" + input()

digits = [int(c) for c in S.rstrip("0")]
N = len(digits)

# Track number of bills necessary to create digits[:i]
# Can either pay exact or overpay by one bill to flip the sign of the balance
dpPos = [None] * len(digits)
dpNeg = [None] * len(digits)

dpPos[-1] = digits[-1]
dpNeg[-1] = 10 - digits[-1]

for place in reversed(range(len(digits) - 1)):
    # Positive balance case
    exact = digits[place]
    overpay = exact + 1
    dpPos[place] = min(exact + dpPos[place + 1], overpay + dpNeg[place + 1])
    # Negative balance case
    exact = 10 - digits[place] - 1
    overpay = exact + 1
    dpNeg[place] = min(exact + dpNeg[place + 1], overpay + dpPos[place + 1])
print(dpPos[0])


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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1L<<62)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  ll x, y;
  cin >> x >> y;

  ll cnt = 0;
  if (abs(x) < abs(y)) {
    cnt = abs(y) - abs(x);
    if (x * y < 0LL)
      cnt++;

    if (x == 0 && y < 0)
      cnt++;

    if (x < 0 && y < 0)
      cnt += 2;

  } else {
    cnt = abs(x) - abs(y);

    if (x * y < 0LL)
      cnt++;

    if (x > 0 && y == 0)
      cnt++;

    if (x > 0 && y > 0)
      cnt += 2;
  }

  cout << cnt << endl;
  return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b,c,d,p;
    int xcost,ycost;
    scanf("%d %d %d %d %d", &a,&b,&c,&d,&p);
    
    
    xcost = p*a;
    
    
    if(p <= c){
        ycost = b;
    }
    else{
        ycost = b + (p-c)*d;
    }
    
    
    if(xcost < ycost){
        printf("%d\n", xcost);
    }
    else{
        printf("%d\n", ycost);
    }
    return 0;
}

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

int main() {
  int h=0,w=0;
  cin >> h >> w;
  
  for (int i=0; i < w+2; i++) cout << '#';
  cout << endl;
  
  string s;
  
  for (int i=0; i < h; i++) {
    cout << '#';
    cin >> s;
    cout << s;
    cout << '#' << endl;
  }
  
  
  for (int i=0; i < w+2; i++) cout << '#';
  cout << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;


int upstairs(int in)
{
	int out = 1;
	for (int i = 1; i < in; i++)
		out *= i + 1;
	return out;
}

int get_num(vector<int> data)
{
	vector<int> rank = data;
	sort(rank.begin(), rank.end());

	int num = -1;
	for (int i = 0; i < rank.size(); i++) {
		if (data[0] == rank[i]) {
			num = i;
			break;
		}
	}

	data.erase(data.begin());
	if (data.size() == 0)
		return 1;
	else
		return num * upstairs(data.size()) + get_num(data);
}

int main(int argc, char *argv[])
{
	int N;
	cin >> N;

	vector<int> P(N) , Q(N);
	for (int i = 0; i < N; i++)
		cin >> P[i];
	for (int i = 0; i < N; i++)
		cin >> Q[i];

	cout << fabs(get_num(P) - get_num(Q)) << endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<list>

int main(){
    int n;
    std::cin >> n;
    std::list<int> out;
    for(int i = 0; i < n; i++){
        int a;
        std::cin >> a;
        if(i % 2 == 0){
            out.push_back(a);
        }else{
            out.push_front(a);
        }
    }

    std::size_t size = out.size();
    // 偶数は頭から、奇数は後ろから読む
    if(size % 2 != 0){
        auto iter = out.end();
        while(1){
            iter--;
            if(iter == out.begin()){
                std::cout << *iter << std::endl;
                break;
            }else{
                std::cout << *iter << " ";
            }
        }
    }else{
        auto iter = out.begin();
        while(1){
            std::cout << *iter;
            iter++;
            if(iter == out.end()){
                std::cout << std::endl;
                break;
            }else{
                std::cout << " ";
            }
        }
    }

    return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

    
int l, r, d;

void solve()
{
    cin >> l >> r >> d;
    nout(r/d - (l-1)/d);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3536
#include<iostream>

using namespace std;

int main(){

	int n;
	int inp;
	int sum,max,min;

	while(1){

		cin>>n;
		if(n==0) break;

		cin>>inp;
		min=inp,max=inp,sum=inp;
		for(int i=1;i<n;i++){
			cin>>inp;
			sum+=inp;
			if(min>inp) min=inp;
			if(max<inp) max=inp;
		}
		cout<<(sum-min-max)/(n-2)<<endl;
	}

	return 0;
}

Measured memory_bytes: 1156
input_data = input().split()

k=int(input_data[0])
s=int(input_data[1])
count=0

for i in range(k+1):
  for j in range(k+1):
    z = s - i - j
    if (0 <= z and z <= k):
      count= count +1
    else:
      pass

print(count)

Measured memory_bytes: 3060