akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
int d[100];
int main()
{
	int i;
	for(i=0;i<3;i++)
	cin>>d[i];
	sort(d,d+3);
	if(d[0]==d[1]&&d[1]!=d[2])
	printf("Yes\n");
	else if(d[1]==d[2]&&d[1]!=d[0])
	printf("Yes\n");
	else
	printf("No\n");






}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

public class Program
{

    public static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        string ans = "No";
        if (s[0] == "2" || s[1] == "2") ans = "No";
        if (s[0] == "1" || s[0] == "3" || s[0] == "5" || s[0] == "7" || s[0] == "8" || s[0] == "10" || s[0] == "12")
        {
            if (s[1] == "1" || s[1] == "3" || s[1] == "5" || s[1] == "7" || s[1] == "8" || s[1] == "10" || s[1] == "12") ans = "Yes";
        }
        if (s[0] == "4" || s[0] == "6" || s[0] == "9" || s[0] == "11")
        {
            if (s[1] == "4" || s[1] == "6" || s[1] == "9" || s[1] == "11") ans = "Yes";
        }
        Console.WriteLine(ans);
    }

    static int[] s_to_i(string[] s)
    {
        int[] ret = Array.ConvertAll<string, int>(s, delegate (string value) { return int.Parse(value); });
        return ret;
    }
}

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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int n, m;
int a[100001], b[100001];

struct UnionFind {
    // 根を保存する（根のみ負値で木の大きさが保存される）
    vector<int> Parent;
 
    // 要素数Nで初期化
    UnionFind(int N) { Parent = vector<int>(N, -1); }

    // 根を求める
    int root(int A) {
        if (Parent[A] < 0) return A;
        else return Parent[A] = root(Parent[A]);
    }

    // 属する木の大きさ
    int size(int A) { return -Parent[root(A)]; }
 
    // 統合
    void unite(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) return;
 
        if (size(A) < size(B)) swap(A, B);
 
        Parent[A] += Parent[B];
        Parent[B] = A;
    }
 
    // 同値類判定
    bool same(int A, int B) { return root(A) == root(B); }
};

signed main() {
    cin >> n >> m;
    for (int i=0;i<m;i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    UnionFind island(n);

    int useful[m] = {};
    for (int i=m-1;i>=0;i--) {
        if (!island.same(a[i], b[i])) useful[i] = island.size(a[i])*island.size(b[i]);
        island.unite(a[i],b[i]);
    }

    int ans[m] = {};
    ans[m-1] = n*(n-1)/2;
    for (int i=m-1;i>=1;i--) {
        if (ans[i] > 0) ans[i-1] = ans[i] - useful[i];
    }

    for (int i=0;i<m;i++) cout << ans[i] << endl;
}

// i番目の橋が落ちた直後の不便さ = i-1番目の不便さ + i番目の橋の崩落による不便さの増分
// i番目の橋の崩落の不便さの増分 = i番目の橋ができたときの便利さの増分
// 便利さの増分はi=m(橋がない状態),m-1,m-2,…と計算して行けば良い(繋がる島の数の積)
// 漸化式を逆向きにして全て崩落した場合から考えていく
// 不便さ[i] = 不便さ[i-1] + 便利さの増分[i] → 不便さ[i-1] = 不便さ[i] - 便利さの増分[i] ;i-1=0,1,,,m-1
// 全部落ちたときの不便さ = n_C_2
// 配列は不便さ[i], 便利さの増分[i]


Measured memory_bytes: 5248
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,L = LI()
a = LI()

for i in range(N-1):
    if a[i]+a[i+1] >= L:
        print('Possible')
        for j in range(1,i+1):
            print(j)
        for j in range(i+2,N)[::-1]:
            print(j)
        print(i+1)
        exit()
    else:
        continue

print('Impossible')

Measured memory_bytes: 63856
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = Math.abs(sc.nextLong());
        long k = sc.nextLong();
        long d = sc.nextLong();
        
        long straight = Math.min(k, x/d);
        long y = x - (straight * d);
        k -= straight;
        
        if (k > 0) {
            if (k%2 == 1) y = Math.abs(y - d);
        }

        System.out.println(y);
    }
}

Measured memory_bytes: 35608
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int N,ret,Ans;
int main(){
	scanf("%d",&N);int x=N;
	while(x)x/=10,ret++;
	for(int i=1;i<=ret-1;i+=2)
		Ans+=pow(10,i-1)*9;
	if(ret%2==1)Ans+=N-pow(10,ret-1)+1;
	printf("%d\n",Ans);
}

Measured memory_bytes: 128
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<i64>();

    let m = (n as f64).log10() as i64 + 1;
    let mut ans = 0;
    for i in 3..m + 1 {
        ans += dfs(0, 0, 0, 0, 0, n, i);
    }
    println!("{}", ans);
}

fn dfs(depth: i64, cur: i64, cnt7: i64, cnt5: i64, cnt3: i64, n: i64, m: i64) -> i64 {
    if depth == m {
        if cnt7 > 0 && cnt5 > 0 && cnt3 > 0 && cur <= n {
            1
        } else {
            0
        }
    } else {
        let mut cnt = 0;
        cnt += dfs(
            depth + 1,
            cur + 7 * 10i64.pow(depth as u32),
            cnt7 + 1,
            cnt5,
            cnt3,
            n,
            m,
        );
        cnt += dfs(
            depth + 1,
            cur + 5 * 10i64.pow(depth as u32),
            cnt7,
            cnt5 + 1,
            cnt3,
            n,
            m,
        );
        cnt += dfs(
            depth + 1,
            cur + 3 * 10i64.pow(depth as u32),
            cnt7,
            cnt5,
            cnt3 + 1,
            n,
            m,
        );
        cnt
    }
}


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
string s;
string t;
int N;
int main()
{
    cin >> N >> s >> t;
    for(int i=N; i>=0; --i)
    {
        bool flag = true;
        for(int j=0; j<i; ++j)
            if(s[N-i+j] != t[j])
                flag = false;
        if(flag)
        {
            cout << 2*N-i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) (n); i++)
#define ll long long
ll INF = 9e17;
ll mod = 1e9 + 7;

int main() {
	int n; cin >> n;
	ll ans = 0;
	for(int i=1;i<=n-1;i++) {
		ans+=i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N, P = map(int, input().split())
res = {}


def pf(n):
    c = 2
    while c * c <= n:
        while not n % c:
            res[c] = res.get(c, 0) + 1
            n //= c
        c += 1

    if n != 1:
        res[n] = 1


def main():
    pf(P)

    ans = 1
    for d in res:
        ans *= pow(d, res[d]//N)

    print(ans)


if __name__ == '__main__':
    main()


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


int main() {
  int n,m;
  cin>>n>>m;
  if(n==1 && m==1){
    cout<< 1<<endl;
    return 0;
  }
  if(n==1){
    cout<< m-2<<endl;
    return 0;
  }
  if(m==1){
    cout<< n-2<<endl;
    return 0;
  }
  long ans =long(max(n-2,0))* long(max(m-2,0));
  cout<< ans<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9 + 7;
const long long LLINF = 1e18;

int main() {
    ll h, w;
    string c[101];
    cin>>h>>w;
    REP(i, 0, h) cin>>c[i];

    REP(i, 0, h){
        cout<<c[i]<<endl;
        cout<<c[i]<<endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  unordered_map<ll, ll> mp;
  mp[0]++;
  ll pre = 0;
  for (int i = 0; i < n; ++i) {
    ll a;
    cin >> a;
    pre += a;
    mp[pre % m]++;
  }
  ll ans = 0;
  for (auto p : mp) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
}

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

int main() {
  int N;
  int sum = 0;
  cin >> N;
  
  for(int i = 0;i < N;i++){
    int l,r;
    cin >> l >> r;
    int customers = r - l + 1;
    sum += customers;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <cmath>
#define PI 3.14159265359
using namespace std;

int main()
{
	long long int n, m;
	cin >> n >> m;
	if (m - n * 2 >= 0)
		cout << n + (m - n * 2) / 4 << endl;
	else 
cout << m / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<double>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<vector<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

ll h, w;
VecS s;
VecVec dist;

void init(){
	rep(i, h) fill(all(dist[i]), LINF);
}

void wfs(ll x, ll y){
	queue<P> que;
	que.push({x*w+y, 0});
	while(!que.empty()){
		P p = que.front(); que.pop();
		ll x1 = p.fs/w, y1 = p.fs%w;
		dist[x1][y1] = p.sc;
		if(x1-1 >= 0 && s[x1-1][y1] == '.' && dist[x1-1][y1] == LINF) que.push({(x1-1)*w+y1, p.sc+1});
		if(y1-1 >= 0 && s[x1][y1-1] == '.' && dist[x1][y1-1] == LINF) que.push({x1*w+y1-1, p.sc+1});
		if(x1+1 < h && s[x1+1][y1] == '.' && dist[x1+1][y1] == LINF) que.push({(x1+1)*w+y1, p.sc+1});
		if(y1+1 < w && s[x1][y1+1] == '.' && dist[x1][y1+1] == LINF) que.push({x1*w+y1+1, p.sc+1});
	}
}

ll maxDist(){
	ll res = 0;
	rep(i, h){
		rep(j, w) if(dist[i][j] != LINF) chmax(res, dist[i][j]);
	}
	return res;
}

int main(void){
	cin >> h >> w;
	s.resize(h);
	rep(i, h) cin >> s[i];
	dist.resize(h);
	rep(i, h) dist[i].resize(w);
	bool flg = true;
	rep(i, h) rep(j, w) if(s[i][j] == '#'){
		flg = false;
		break;
	}
	if(flg){
		co(w+h-2);
		return 0;
	}

	ll ans = 0;
	rep(i, h){
		rep(j, w) if(s[i][j] == '.'){
			init();
			wfs(i, j);
			chmax(ans, maxDist());
		}
	}
	co(ans);

	return 0;
}


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

#define int long long

const int N = 1e5 + 10;
int q, mark[N], psum[N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	mark[1] = 1;
	for (int i = 2; i < N; i++)
		if (!mark[i])
			for (int j = 2 * i; j < N; j += i)
				mark[j] = 1;
				
	for (int i = 1; i < N; i += 2)
		psum[i] = (!mark[i] && !mark[(i + 1) / 2]);
	for (int i = 1; i < N; i++)
		psum[i] += psum[i - 1];
	
	cin >> q;
	while (q--) {
		int l, r;
		cin >> l >> r;
		cout << psum[r] - psum[l - 1] << '\n';
	}
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
string a,b;
long long n,ans,k;
long long ds(int u){
    int now=0;
    for(int s=u;s<n;s++){
        if(a[s]!=b[now])break;now++;
    }
    return now;
}
int main(){
    cin>>n>>a>>b;
    ans=n*2;
    for(int s=0;s<n;s++){k=ds(s);ans=min(ans,n*2-k);}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
 
using namespace std;
 
bool a[5][5][5][2];
int M1,M2;
int alpha[30], beta[30];
 
inline bool isValid(int x,int y,int z) { return 0 <= x && x < 5 && 0 <= y && y < 5 && 0 <= z && z < 5; }
 
bool ok(bool type,int v){
  if( !type ) rep(i,M1) if( alpha[i] == v ) return true;
  if(  type ) rep(i,M2) if(  beta[i] == v ) return true;
  return false;
}
 
void print(int type){
  rep(z,5) {
    if( z ) puts("");
    rep(y,5) {
      rep(x,5) {
    cout << a[z][y][x][type];
      } puts("");
    }
  }
}
 
int main(){
  int N,CNT=1;
  bool fu = 1;
  while( cin >> N, N ){
    if( !fu ) puts("");
    fu = false;
    rep(z,5) rep(y,5) {
      string s;
      cin >> s;
      rep(x,5) a[z][y][x][0] = (s[x]=='0'?false:true);
    }
 
    //print(0);
 
    cin >> M1; rep(i,M1) cin >> alpha[i];
    cin >> M2; rep(i,M2) cin >> beta[i];
    printf("Case %d:\n",CNT++);
    rep(i,5) rep(j,5) rep(k,5) a[i][j][k][1] = false;
 
    int phase = 0;    
    rep(day,N) { 
      rep(z,5) rep(y,5) rep(x,5) {
    int cur = phase&1;
    int next = (phase+1)&1;
    bool type = a[z][y][x][cur];
    int cnt = 0;
    for(int dz=-1;dz<=1;dz++){
      for(int dy=-1;dy<=1;dy++){
        for(int dx=-1;dx<=1;dx++){
          if( dz == 0 && dy == 0 && dx == 0 ) continue;
          int nz = z + dz, ny = y + dy, nx = x + dx;
          if( !isValid(nx,ny,nz) ) continue;
          bool v = a[nz][ny][nx][cur];
          //cout << "(" << nx << "," << ny << "," << nz << ") " << a[nz][ny][nx][cur] << "!!" << endl;
          if( v ) ++cnt;
          /*
          if( !type &&  v ) ++cnt;
          if(  type && !v ) ++cnt;
          */
        }   
 
      } 
    }
 
    if( !type ) a[z][y][x][next] = ( ok(type,cnt) ) ? true : false;
    if(  type ) a[z][y][x][next] = ( ok(type,cnt) ) ? true : false;
 
      }
      ++phase;
    }
 
    print(phase&1);
 
  }
  return 0;
}

Measured memory_bytes: 1236
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include <boost/any.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
struct SEG{
    lint n=1;
    vec node,lazy;
    SEG(lint size){
        while(n<size)n<<=1;
        n*=2;
        node.resize(2*n-1,0);
        lazy.resize(2*n-1,0);
    }
    //0-indexed [a,b)
    void add(lint a,lint b,lint x,lint k=0,lint l=0,lint r=-1){
        if(r<0)r=n;
        if(a<=l&&r<=b){
            node[k]+=(r-l)*x;
            if(k<n-1){
                lazy[2*k+1]+=x;
                lazy[2*k+2]+=x;
            }
        }else if(l<b&&a<r){
            node[k]+=(min(b,r)-max(a,l))*x;
            add(a,b,x,2*k+1,l,(l+r)/2);
            add(a,b,x,2*k+2,(l+r)/2,r);
        }
    }
    //0-indexed [a,b)
    lint get(lint a,lint b,lint k=0,lint l=0,lint r=-1){
        if(r<0)r=n;
        if(b<=l||r<=a)return 0;
        if(a<=l&&r<=b)return lazy[k]*(r-l)+node[k];
        if(k<n-1){
            lazy[2*k+1]+=lazy[k];
            lazy[2*k+2]+=lazy[k];
        }
        lazy[k]=0;
        return get(a,b,2*k+1,l,(l+r)/2)+get(a,b,2*k+2,(l+r)/2,r);
    }
};
int main(){
    lint n;
    cin>>n;
    cout<<800*n-(n/15)*200;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}

signed main() {
    capi(n);
    vi va;
    rep(i, n) {
        capi(a);
        va.push_back(a);
    }

    sort(all(va), std::greater());

    int ans = 0;

    for (int i = 1; i < va.size(); ++i) {
        ans += va[i / 2];
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 4812
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let k: u64 = sc.read();
    let mut a: Vec<u64> = sc.vec(n);
    let sum = a.iter().fold(0, |sum, a| sum + a);
    if sum <= k {
        println!("{}", 0);
        return;
    }
    a.sort();
    a.reverse();
    let mut f: Vec<u64> = sc.vec(n);
    f.sort();

    let mut left = 0;
    let mut right = 1 << 60;
    while right - left > 1 {
        let med = (right + left) / 2;
        let mut tmp_k = k;
        let mut ok = true;
        for i in 0..n {
            if a[i] * f[i] > med {
                let tmp = a[i] - med / f[i];
                if tmp_k < tmp {
                    ok = false;
                    break;
                }
                tmp_k -= tmp;
            }
        }
        if ok {
            right = med;
        } else {
            left = med;
        }
    }
    println!("{}", right);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 14716
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b,c; cin>>a>>b>>c;
	a-=c;
	cout<<a/(b+c);
	
	return 0;
}

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

int main() {
	int n,m; cin >> n >> m;
	vint h(n);
	vint ma(n);
	rep(i,n) {
		cin >> h[i];
		ma[i]=0;
	}
	rep(i,m) {
		int a,b; cin >> a >> b;
		ma[a-1]=max(h[b-1],ma[a-1]);
		ma[b-1]=max(h[a-1],ma[b-1]);
	}
	int ans=0;
	rep(i,n) {
		if(ma[i]<h[i]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4032
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define M_PI 3.14159265358979
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


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

	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= N; ++j) {
			int t = N - i * j;
			if (t >= 1) ans++;
			else break;
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3556
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n,a,b,c,d;cin>>n>>a>>b>>c>>d;
  bool flag=true;
  string s;cin>>s;
  bool tag=true;
  for (int i = b; i < d; i++)
  {
    if(s[i-1]=='.'&&s[i]=='.'){
      if(s[i-2]=='.'){
        tag=false;
      }
    }
    if(s[i]=='#'&&s[i-1]=='#'){
      flag=false;
    }
  }
  if(tag)s[d-1]='#';
  for (int i = a; i < c; i++)
  {
    if(s[i]=='#'&&s[i-1]=='#'){
      flag=false;
    }
  }
  	if(flag){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

struct tree {
  int n;
  tree(int n) : n(n) {}
  vector<int> pos, tour, depth;
  vector<vector<int>> table;
  int argmin(int i, int j) { return depth[i] < depth[j] ? i : j; }
  void rootify(int r, Graph &adj) {
    pos.resize(n);
    function<void (int,int,int)> dfs = [&](int u, int p, int d) {
      pos[u] = depth.size();
      tour.push_back(u);
      depth.push_back(d);
      for (auto &v: adj[u]) {
        if (v.dst != p) {
          dfs(v.dst, u, d+1);
          tour.push_back(u);
          depth.push_back(d);
        }
      }
    }; dfs(r, r, 0);
    int logn = sizeof(int)*__CHAR_BIT__-1-__builtin_clz(tour.size()); // log2
    table.resize(logn+1, vector<int>(tour.size()));
    iota(table[0].begin(), table[0].end(), 0);
    for (int h = 0; h < logn; ++h) 
      for (int i = 0; i+(1<<h) < tour.size(); ++i)
        table[h+1][i] = argmin(table[h][i], table[h][i+(1<<h)]);
  }
  int lca(int u, int v) {
    int i = pos[u], j = pos[v]; if (i > j) swap(i, j);
    int h = sizeof(int)*__CHAR_BIT__-1-__builtin_clz(j-i); // = log2
    return i == j ? u : tour[argmin(table[h][i], table[h][j-(1<<h)])];
  }
};

int main(){
	int k,i,V,E,s,t,e;
	//for(scanf("%d",&T);T;putchar(--T?' ':'\n')){
		scanf("%d",&V);
		Graph g(V);
		for(i=0;i<V;i++)for(scanf("%d",&k);k--;)
			scanf("%d",&t),g[i].push_back(Edge(i,t,1)),g[t].push_back(Edge(t,i,1));
		tree tr(V);tr.rootify(0,g);
		for(scanf("%d",&k),i=0;i<k;i++){
			scanf("%d%d",&s,&t);
			printf("%d\n",tr.lca(s,t));
		}
	//}
}

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

int main() {
	while (1) {
		int M, N; cin >> M >> N;
		if (!M)break;
		vector<bool>oks(7368793);
		int used = 0;
		int ans = -1;
		for (int i = M; i < 1e7; ++i) {
			if (!oks[i]) {
				if (used == N) {
					ans = i;
					break;
				}
				for (int j = i; j < 7368793; j += i) {
					oks[j] = true;
				}
				used++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc118_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, M;
  cin >> N >> M;

  map<int, int> m;
  rep(i, N) {
    int k;
    cin >> k;
    rep(j, k) {
      int a;
      cin >> a;
      m[a]++;
    }
  }

  ll ans = 0;
  for (auto kv : m) {
    if (kv.second == N) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions

import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
D = list(map(int, input().split()))

times = [0]*13
times[0] = 1
for i in range(N):
	times[D[i]] += 1
	if times[D[i]] == 3:
		print(0)
		exit()
if times[0] > 1 or times[12] > 1:
	print(0)
	exit()

base_time = [0]
add_time = []
for i in range(1, 12):
	if times[i] == 2:
		bisect.insort(base_time, -i)
		bisect.insort(base_time, i)
	elif times[i] == 1:
		add_time.append(i)
if times[12] == 1:
	bisect.insort(base_time, 12)

def min_diff(A):
	min_times = 50
	for i in range(len(A) - 1):
		min_times = min(min_times, A[i + 1] - A[i])
	min_times = min(min_times, A[0] + 24 - A[-1])
	return min_times

if len(add_time) == 0:
	print(min_diff(base_time))
	exit()

ans = 0
for i in range(2**len(add_time)):
	base_time2 = copy.deepcopy(base_time)
	for bit in range(len(add_time)):
		mask = ((2**bit)&i)//(2**bit)
		bisect.insort(base_time2, add_time[bit]*(1 - 2*mask))
	ans = max(ans, min_diff(base_time2))
	#print(base_time2)

print(ans)

Measured memory_bytes: 68324
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void sortBy(int a[], int v[]) {
		int n = a.length;
		if (n == 0) {
			return;
		}
		for (int i = 1; i < n; i++) {
			int j = i;
			int ca = a[i];
			int cv = v[ca];
			do {
				int nj = (j - 1) >> 1;
				int na = a[nj];
				if (cv <= v[na]) {
					break;
				}
				a[j] = na;
				j = nj;
			} while (j != 0);
			a[j] = ca;
		}
		int ca = a[0];
		for (int i = n - 1; i > 0; i--) {
			int j = 0;
			while ((j << 1) + 2 + Integer.MIN_VALUE < i + Integer.MIN_VALUE) {
				j <<= 1;
				j += (v[a[j + 2]] > v[a[j + 1]]) ? 2 : 1;
			}
			if ((j << 1) + 2 == i) {
				j = (j << 1) + 1;
			}
			int na = a[i];
			a[i] = ca;
			ca = na;
			int cv = v[ca];
			while (j != 0 && v[a[j]] < cv) {
				j = (j - 1) >> 1;
			}
			while (j != 0) {
				na = a[j];
				a[j] = ca;
				ca = na;
				j = (j - 1) >> 1;
			}
		}
		a[0] = ca;
	}

	static void solve() throws Exception {
		int h = scanInt();
		scanInt();
		int n = scanInt();
		int x[] = new int[n], y[] = new int[n], idx[] = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = scanInt() - 1;
			y[i] = scanInt() - 1;
			idx[i] = i;
		}
		sortBy(idx, x);
		int cx = 0, cmax = 0;
		boolean ctrim = false;
		for (int i: idx) {
			int xi = x[i], yi = y[i];
			if (xi != cx) {
				if (ctrim) {
					--cmax;
					ctrim = false;
				}
				cmax += xi - cx;
				cx = xi;
			}
			if (yi < cmax) {
				out.print(cx);
				return;
			} else if (yi == cmax) {
				ctrim = true;
			}
		}
		out.print(h);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

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

int main() {
  int h, w;
  cin >> h >> w;
  for (int i = 0; i <= w+1; i++) {
    cout << '#';
  }
  cout << endl;
  for (int i = 0; i < h; i++) {
    cout << '#';
    for (int j = 0; j < w; j++) {
      char a;
      cin >> a;
      cout << a;
    }
    cout << '#' << endl;
  }
  for (int i = 0; i <= w+1; i++) {
    cout << '#';
  }
  cout << endl;
}

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

using namespace std;

//# define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;

# define S second
# define F first
# define kill(x) return(cout << x << endl, 0)
# define debug(x) cerr<< #x << " : " << x << endl
# define ddebug(x, y) cerr<< #x << " : " << x  << ", " << #y << " : " << y << endl
# define sz(s) (int)s.size()
# define sq(x) (x) * (x)
# define PB(x) push_back(x)
# define smax(x, y) (x) = max((x), (y))
# define smin(x, y) (x) = min((x), (y))
# define all(x) x.begin(), x.end()
# define SP fixed << setprecision(10)
# define UB upper_bound

bool d[100 * 1000 + 10];

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

	int n, m;
	cin >> n >> m;
	while (m --)
	{
		int u, v;
		cin >> u >> v;
		u --, v --;
		d[u] ^= 1;
		d[v] ^= 1;
	}

	for (int i = 0; i < n; i ++)
		if (d[i])
			kill("NO");
	cout << "YES" << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!

  int N;
  int counter =0;
  cin  >> N;
  
  vector<int> M(N);
  for(int i=0;i<N;i++)cin >> M[i];
 
  for(int j=0;j<N-2;j++){
  if(M[j]>M[j+1]&&M[j+1]>M[j+2]||M[j]<M[j+1]&&M[j+1]<M[j+2])counter++;
  }
  
  cout <<counter;
  
}


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

int main() {
  ll x,w;
  cin >>x;
  vector<ll> a;
  rep(i,100000){
    w=pow(i,5);
    a.push_back(w);
    for(int j=0;j<a.size();j++){
      if(w+a[j]==x){
        cout << i <<" "<< j*-1;
        return 0;
      }else if(w-a[j]==x){
        cout << i <<" "<< j;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 4060
# https://atcoder.jp/contests/abc127/submissions/5606400

from functools import reduce


def mod_mul(a, b):
    return (a * b) % MOD


def mod_add(a, b):
    return (a + b) % MOD


def cmb(n, r):
    r = min(r, n - r)
    if r == 0:
        return 1
    if r == 1:
        return n

    f = reduce(mod_mul, range(n - r + 1, n + 1))  # n!/(n-r)!
    d = reduce(mod_mul, range(2, r + 1))  # r!
    return (f * pow(d, MOD - 2, MOD)) % MOD


MOD = 10 ** 9 + 7

N, M, K = map(int, input().split())

ans_x = reduce(mod_add, (i * (M - i) for i in range(M))) * N ** 2
ans_y = reduce(mod_add, (i * (N - i) for i in range(N))) * M ** 2
ans = ans_x + ans_y
pat = cmb(N * M - 2, K - 2)
ans = (ans * pat) % MOD

print(ans)


Measured memory_bytes: 3572
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

int find(vector<int> r, int a)
{
    // cout << a << endl;
    int left = 0, right = r.size();
    while(right - left > 1){
        int mid = (left + right) / 2;
        // cout << mid << endl;
        if(r[mid] < a) left = mid;
        else right = mid;
    }
    // cout << right << endl;
    return right;
}

int main()
{
    int n;
    cin >> n;
    int a[100001];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<int> result;
    for(int i = 0; i < n; i++){
        int l = result.size();
        if(l == 0 || result[l - 1] < a[i]){
            result.push_back(a[i]);
        } else if(a[i] <= result[0]){
            result[0] = a[i];
        } else {
            int tmp = find(result, a[i]);
            result[tmp] = a[i];
        }
        // for(int j = 0; j < result.size(); j++){
        // cout << result[j] << " ";
        // }
        // cout << endl;
    }
    cout << result.size() << endl;
    return 0;
}

Measured memory_bytes: 2192
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  int a,b,c,d;
  cin >> a >>b >>c >> d;
  if(abs(c-a)<=d || abs(b-a)<=d && abs(c-b)<=d){cout << "Yes" << endl;}else{cout << "No" << endl;}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define em emplace
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i <= n; i++)
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr int INF = 1<<30;
constexpr ll LINF = 1LL<<58;
constexpr int mod = 1000000007;

ll dp[3030][3030];

int main(){
    int n;
    cin >> n;
    vector<ll> A(n);
    for (int i = 0; i < n; i++) cin >> A[i];
    if(n % 2 == 1){
        for (int i = 0; i < n; i++) dp[i][i] = A[i];
        for (int w = 1; w < n; w++) {
            for (int i = 0; i < n - w; i++) {
                if(w % 2 == 1) dp[i][i + w] = min(dp[i][i + w - 1] - A[i + w], dp[i + 1][i + w] - A[i]);
                else dp[i][i + w] =  max(dp[i][i + w - 1] + A[i + w], dp[i + 1][i + w] + A[i]);
            }
        }
    }
    else {
        for (int i = 0; i < n; i++) dp[i][i] = -A[i];
        for (int w = 1; w < n; w++) {
            for (int i = 0; i < n - w; i++) {
                if(w % 2 == 1) dp[i][i + w] =  max(dp[i][i + w - 1] + A[i + w], dp[i + 1][i + w] + A[i]);
                else dp[i][i + w] = min(dp[i][i + w - 1] - A[i + w], dp[i + 1][i + w] - A[i]);
            }
        }
    }
    cout << dp[0][n - 1] << endl;
}


Measured memory_bytes: 71936
#include <iostream>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdarg>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(){
    long long H;
    cin >> H;
    long long count = 0;
    while (H){
        H >>= 1;
        count += 1;
    }
    long long S = pow(2, count) - 1;
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

const int MAX = 500000;
const int NIL = -1;

class Point {
public:
	int id, x, y;
	Point(int id, int x, int y) :
			id(id), x(x), y(y) {
	}
	Point() {
	}
	bool operator <(const Point &p) const {
		return id < p.id;
	}
	void print() {
		printf("%d\n", id);
	}
};
class Node {
public:
	int location, l, r;
};

bool lessX(const Point &p1, const Point &p2) {
	return p1.x < p2.x;
}
bool lessY(const Point &p1, const Point &p2) {
	return p1.y < p2.y;
}
Point P[MAX];
Node T[MAX];
int np = 0;
int makeKdTree(int l, int r, int depth) {
	if (!(l < r))
		return NIL;
	if (depth % 2 == 0) {
		sort(P + l, P + r, lessX);
	} else {
		sort(P + l, P + r, lessY);
	}
	int mid = (l + r) / 2;
	int t = np++;
	T[t].location = mid;
	T[t].l = makeKdTree(l, mid, depth + 1);
	T[t].r = makeKdTree(mid + 1, r, depth + 1);

	return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
	int x = P[T[v].location].x;
	int y = P[T[v].location].y;
	if (sx <= x && x <= tx && sy <= y && y <= ty)
		ans.push_back(P[T[v].location]);

	if (depth % 2 == 0) {
		if (T[v].l != NIL && sx <= x)
			find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
		if (T[v].r != NIL && x <= tx)
			find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
	} else {
		if (T[v].l != NIL && sy <= y)
			find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
		if (T[v].r != NIL && y <= ty)
			find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
	}
}

int main() {

	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x, y;
		scanf("%d %d", &x, &y);
		P[i] = Point(i, x, y);
		T[i].location = T[i].l = T[i].r = NIL;
	}
	int root = makeKdTree(0, n, 0);

	int q;
	scanf("%d", &q);
	vector<Point> ans;
	for (int i = 0; i < q; ++i) {
		int sx, tx, sy, ty;
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
		ans.clear();
		find(root, sx, tx, sy, ty, 0, ans);
		sort(ans.begin(), ans.end());
		for (int i = 0; i < ans.size(); ++i) {
			ans[i].print();
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 14028
#include <bits/stdc++.h>
using namespace std;
#define pussy push_back
#define mod 1000000007
const int N = 1e3 + 10;
#define int long long int
int n , m ;
vector<int> v[N];
int c[N];
int ans = 1e18;
int dd[1010][(1 << 13) + 5];

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for(int i = 1  ; i <= m ;i ++) {
		cin >> c[i];
		int x ; cin >> x;
		for(int j = 0 ;j < x ; j ++) {
			int y ; cin >> y;
			v[i].pussy(y);
		}
	}
	int _mask = 0;
	for(int i = 1 ;i <= n ; i ++) _mask |= (1 << i);
	for(int i = 0 ; i < 1010 ; i ++) 
		for(int j = 0 ; j < (int)((1 << 13) + 5) ; j ++) 
			dd[i][j] = 1e18;


	for(int i = 0 ; i <= m ; i ++) dd[i][0] = 0;

	for(int i = 1 ; i <= m ; i ++) {
		int can = 0;
		for(auto j : v[i]) can |= (1 << j);
		for(int j = 1 ; j <= _mask ; j ++) {
			int mask = 0;
			for(int k = 1 ; k <= n ; k ++) {
				if((j & (1 << k)) && ((can & (1 << k)) == 0)) {
					mask |= (1 << k);
				}
			}
			if(dd[i - 1][mask] != 1e18) {
				dd[i][j] = min(dd[i - 1][j] , c[i] + dd[i - 1][mask]);
			} else dd[i][j] = dd[i - 1][j];
		}
	}
	if(dd[m][_mask] == 1e18) cout << -1;
	else
	cout << dd[m][_mask];
}


Measured memory_bytes: 65152
#include "iostream"
using namespace std;
int main()
{
	int a, b, t,count=0;
	cin >> a >> b >> t;
	for (int i = 0; i < t + 0.5; i++)
	{
		if (i%a == 0)
		{
			if (i != 0)
			{
				count += b;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <unordered_map>
#include <iomanip>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<pair<T, T> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	long long n, k;
	cin >> n >> k;

	long long curr = n % k;
	cout << min(curr, abs(curr - k)) << "\n";

	return 0;

}

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

using namespace std;

//0027
int main(){
	int days[] = {31,29,31,30,31,30,31,31,30,31,30,31};
	string week[7] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	int m, d;
	while(cin >> m >> d, m||d){
		int ans = 0;
		for(int i=1; i<m; ++i){
			ans += days[i-1];
		}
		ans += d;

		ans = ans % 7;
		cout << week[ans] <<endl;

	}
}

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

const int N = 202020;
typedef long long ll;

inline char get(void) {
  static char buf[100000], *S = buf, *T = buf;
  if (S == T) {
    T = (S = buf) + fread(buf, 1, 100000, stdin);
    if (S == T) return EOF;
  }
  return *S++;
}
template<typename T>
inline void read(T &x) {
  static char c; x = 0; int sgn = 0;
  for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
  for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
  if (sgn) x = -x;
}

int a[N], g[N], c[N];
ll s[N], f[N], mp[N];
ll ans;
int n, m, k;

inline void Add(int x) {
  for (; x <= m; x += x & -x) ++c[x];
}
inline int Sum(int x) {
  int sum = 0;
  for (; x; x -= x & -x) sum += c[x];
  return sum;
}

int main(void) {
  read(n); read(k);
  for (int i = 1; i <= n; i++) {
    read(a[i]); s[i] = s[i - 1] + a[i];
  }
  for (int i = 0; i <= n; i++)
    mp[i] = f[i] = s[i] - (ll)k * i;
  sort(mp, mp + n + 1);
  m = unique(mp, mp + n + 1) - mp;
  for (int i = 0; i <= n; i++)
    g[i] = lower_bound(mp, mp + m, f[i]) - mp + 1;
  for (int i = 0; i <= n; i++) {
    ans += Sum(g[i]); Add(g[i]);
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
   long long X;
   cin >> X;
   long long P = 100, step = 0;
   while(P < X)
   {
      P += P / 100;
	  step++;
   }
   
   cout << step << endl;
   return 0;
}
 

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop") 
#define ll long long int
#define ps push_back
#define pb pop_back
#define fs first
#define sc second
#define mkp make_pair
#define mod 1000000007
const int N=1e5;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll i,j,k,l,n;
	cin>>n>>k;
	ll ar[n+1];	
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	
	ll an[n+1];
	an[1]=0; 
	for(i=2;i<=n;i++){
		ll mn=1000000000000;
		for(j=i-1;j>=1&&j>=i-k;j--){
			l=an[j]+abs(ar[j]-ar[i]);
			//cout<<i<<" "<<l<<endl;
			if(l<mn) mn=l;
		}
		an[i]=mn;
	}
	cout<<an[n];
	return 0;
}

Measured memory_bytes: 1792
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2441

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

typedef long long ll;

const ll INF = 1e18;

ll normal_count(ll cur, ll prev) {
	return cur - (cur / 3 + cur / 5 - cur / 15) - (prev - (prev / 3 + prev / 5 - prev / 15));
}

ll fizzbuzz_count(ll cur, ll prev) {
	return cur / 3 + cur / 5 - prev / 3 - prev / 5;
}

ll word_count(ll cur, ll prev, ll digit) {
	ll normal =  digit * normal_count(cur, prev);
	ll fizzbuzz = 4 * fizzbuzz_count(cur, prev);
	return normal + fizzbuzz;
}

int main() {
	ll s;
	cin >> s;
	
	ll total = 0;
	ll cur = 0, prev = 0, digit = 1;
	while(true) {
		cur = pow(10, digit) - 1; 
		ll len = word_count(cur, prev, digit); //n桁の区間の文字数を取得
		if(total + len >= s) break;
		total += len;
		prev = cur;  digit += 1;
	}

	ll left = prev + 1, right = cur;
	ll mid, len;
	while(right > left) {
		mid = (left + right) / 2;
		len = word_count(mid, prev, digit) + total;
		if(len < s) {
			left = mid + 1;
		} 
		else if(len > s) {
			right = mid - 1;
		}
		else {
			right = left = mid;
		}
	}

	len = word_count(left, prev, digit) + total;
	if(left % 3 == 0) len -= 4;
	if(left % 5 == 0) len -= 4;
	if(left % 3 != 0 && left % 5 != 0) len -= digit;

	ll base = s - len - 1;
	string ans=""; 
	
	for(ll i = left; ans.size() < 20 + base; ++i) {
		if(i % 3 == 0) ans += "Fizz";
		if(i % 5 == 0) ans += "Buzz";
		if(i % 3 != 0 && i % 5 != 0) ans += to_string(i);
	}

	cout << ans.substr(base, 20) << endl;

	return 0;
}

Measured memory_bytes: 1276