akhauriyash/Code-Regression huggingface dataset:
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 01/03/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

constexpr double eps = 1e-9;

struct Point {
  double x,y;
  Point(double _x, double _y) : x(_x), y(_y) {}
  double norm() const { return sqrt(x*x+y*y); }
  Point operator+(const Point& o) const { return {x+o.x, y+o.y}; }
  Point operator-(const Point& o) const { return {x-o.x, y-o.y}; }
  Point operator*(double t) const { return {x*t, y*t}; }
  friend Point operator*(double t, Point p) { return p*t; }
  Point operator/(double t) const { return {x/t, y/t}; }
  Point rot90() { return {-y, x}; }
};
struct Circle {
  Point p;
  double r;
  Circle(Point _p, double _r) : p(_p), r(_r) {}
  bool is_inside(Point o) const { return (p-o).norm() < r+eps; }
};
struct Meet {
  double x,y,c;
};

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

  int N,K; cin>>N>>K;
  vector<Meet> X(N);
  for (int i = 0; i < N; i++) {
    cin>>X[i].x>>X[i].y>>X[i].c;
    X[i].x+=1000;
    X[i].y+=1000;
  }

  auto is_ok_time = [&](double t) -> bool {
    vector<Circle> C;
    transform(X.begin(), X.end(), back_inserter(C), [&](auto m) { return Circle{{m.x,m.y},t/m.c}; });
    auto check = [&](Point p) {
      int cnt = 0;
      for (auto c : C) {
        if (c.is_inside(p))
          cnt++;
      }
      return cnt >= K;
    };
    for (auto c : C)
      if (check(c.p))
        return true;
    for (int i = 0; i < N; i++) {
      for (int j = i+1; j < N; j++) {
        auto a = C[i], b = C[j];
        auto d = (a.p-b.p).norm();
        if (d - a.r - b.r > eps) // not overlap
          continue;
        if (a.r > b.r)
          swap(a,b);
        if (b.r-d-a.r > eps) { // completely overlap
          continue;
        } else { // semi overlap
          auto atb = b.p-a.p;
          auto latx = (a.r*a.r - b.r*b.r + d*d)/(2.0*d);
          auto atx = atb*(latx/d);
          auto xtp = atb.rot90()/atb.norm() * sqrt(a.r*a.r-latx*latx);
          if (check(a.p+atx+xtp) or
              check(a.p+atx-xtp))
            return true;
        }
      }
    }
    return false;
  };

  double l=0, h=300000;
  for (int i = 0; i < 80; i++) {
    auto c = (l+h)/2;
    if (is_ok_time(c)) {
      h = c;
    } else {
      l = c;
    }
  }
  cout << fixed << setprecision(7) << l << endl;

  return 0;
}


Measured memory_bytes: 256
#ALDS1_6_C Quick Sort
import sys
# sys.setrecursionlimit(10000)
def partition(A, p, r):
    q = A[r][1]
    j = p
    for i in range(p, r):
        if A[i][1] <= q:
            A[i], A[j] = A[j], A[i]
            j += 1
    A[j], A[r] = A[r], A[j]
    return j


def quick_sort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quick_sort(A, p, q - 1)
        quick_sort(A, q + 1, r)


def merge(A, left, mid, right):
    l = A[left: mid]
    r = A[mid: right]

    l.append([None, float('inf')])
    r.append([None, float('inf')])

    i = 0
    j = 0

    for k in range(left, right, 1):
        if l[i][1] <= r[j][1]:
            A[k] = l[i]
            i += 1
        else:
            A[k] = r[j]
            j += 1


def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)


n = int(input())
A = []
for i in range(n):
    suit, num = input().split()
    A.append([suit, int(num)])
A1 = A.copy()

quick_sort(A, 0, n-1)
merge_sort(A1, 0, n)

if A != A1:
    print('Not stable')
else:
    print('Stable')

for i in range(n):
    print(' '.join(map(str, A[i])))


Measured memory_bytes: 19172
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  long N;
  std::cin >> N;
  std::vector<long> P(N+1, 0);

  for (size_t i=0; i<N; i++) {
    long p;
    std::cin >> p;

    P[p] = P[p-1]+1;
  }

  decltype(P)::const_iterator i=std::max_element(P.begin(), P.end());
  long soted_chunk_size=*i;

  std::cout << (N-soted_chunk_size) << std::endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> time_to_take(n);
    for (int i = 0; i < n; i++) {
        cin >> time_to_take.at(i);
    }

    long sum = accumulate(time_to_take.begin(), time_to_take.end(), 0);
    int m;
    cin >> m;
    vector<int> kinds(m);
    vector<int> times(m);

    for (int i = 0; i < m; i++) {
        cin >> kinds.at(i);
        cin >> times.at(i);
    }

    for (int i = 0; i < m; i++) {
        int kind, time;
        kind = kinds.at(i);
        time = times.at(i);
        cout << sum - time_to_take.at(kind - 1) + time << endl;
    }
    return 0;
}


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

#define ll long long

int main() {
    ll n,r;
    cin>>n>>r;
    if(n>=10)
    {
        cout<<r;
    }
    else {
        cout<<r+100*(10-n)<<"\n";
    }
        
    
    return 0;
}

Measured memory_bytes: 3624
#coding: UTF-8

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

Ans = 0

for num in range(N):
    Ans += min(A[num], B[num])
    if A[num] >= B[num]:
        pass
    else: # A[num] < B[num]
        B[num] -= A[num]
        Ans += min(A[num+1], B[num])
        if A[num+1] >= B[num]:
            A[num+1] -= B[num]
        else:
            A[num+1] = 0
print(Ans)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {
    sws;

    int n;
    cin >> n;

    vi p(n);

    fo(i, n) {
        cin >> p[i];
    }

    int count = 0;
    for ( int i = 1; i < n - 1; i++ ) {
        if ( (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]) ) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N=0;
cin >> N;
vector<int> v(110, 200);
for(int i=0; i<N; i++) cin >> v.at(i);
//
sort(v.begin(), v.end());
int hold=v.at(0), count=1;
for(int i=0; i<N; i++){
    if(hold!=v.at(i)){
        hold=v.at(i);
        count++;
        // cout << hold << " " << count << endl;
    }
}
cout << count << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
int main(){
    int n,l;
    cin >> n >> l;
    vector<int> a(n);
    rep(i,n) {
        a[i] = l+i;
    }
    int s = 0;
    rep(i,n) s += a[i];//りんごの味の合計を求める。
    int ans = 1e9;
    rep(i,n) {//一個食べた後の味の合計を全パターン求める。
    int t = s-a[i];
    if(abs(t-s) < abs(ans-s)) ans= t;//最小の値がでたらそれを上書きする。
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
 
    for(int loop = 0; loop < min(k, 100); ++loop){
        vector<int> S(n + 1, 0);
        for(int i = 0; i < n; ++i){
            int l = max(0, i - a[i]);
            int r = min(n, i + a[i] + 1);
            ++S[l], --S[r];
        }
        for(int i = 0; i < n; ++i)  S[i + 1] += S[i], a[i] = S[i];
    }
    for(int i = 0; i < n; ++i){
        cout << a[i];
        cout << ((i == n - 1) ? '\n' : ' ');
    }
}

Measured memory_bytes: 4928
'use strict';
function isGoodTriangle(l){
  l.sort((a, b) => b - a);
  return l[0] - l[1] < l[2] && l[0] !== l[1] && l[1] !== l[2];
}

function Main(inputs) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  const input = inputs.split("\n");
  const n = Number(input[0]);
  const l = input[1].split(' ').map(Number);

  let num = 0;
  for(let a = 0; a < n; a++){
    for(let b = a + 1; b < n; b++){
      for(let c = b + 1; c < n; c++){
        if(isGoodTriangle([l[a], l[b], l[c]])){
          num++;
        }
      }
    }
  }
  console.log(num);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 36068
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI acos(-1)
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int MAXN = 1e7;

typedef long long int ll;

using namespace std;

int main(){
    FIN;
    //freopen("../../input.txt", "r", stdin);freopen("../../output.txt", "w", stdout);
    string s;cin>>s;
    int ans = 0;
    if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R')ans = 1;
    if(s[0] == s[1] && s[0] == 'R')ans=2;
    if(s[1] == s[2] && s[1] == 'R')ans=2;
    if(s[0] == s[1] && s[1] == s[2] && s[0] == 'R')ans=3;
    
    cout<<ans<<"\n";
    return 0;
}

// ============== Notes =============== //
// common bugs
// - remove reader 
// - fastio
// - int overflow (especially intermediate expressionns)
// - array bounds (indices bigger than MAXN?, is MAXN correct?)
// - special cases (n=1, graph not connected?)
// - re-initialize efficiently between test cases

Measured memory_bytes: 3596
n = int(input())
S = list(input())

p = ord("Z") - ord("A")
for i in range(len(S)):
  k = ord(S[i]) + n
  if k > ord("Z"):
    S[i] = chr(ord(S[i])+n-p-1)
  else:
    S[i] = chr(ord(S[i])+n)
    
print("".join(S))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
/// check for test case before submitting
void vfun()
{
    ll n,k;
    cin>>n;
    vector <ll> v(n);
    fo(i,n)
    cin>>v[i];

}
const int siz=401;
vector <ll> v(siz,0);
ll t[siz][siz];
ll solve(ll i, ll j)
{
    if(i>=j)
        return 0;
    if(t[i][j]!=-1)
        return t[i][j];
    ll ans=LLONG_MAX;
    for(ll k=i;k<j;k++)
    {
        ll sum=0;
        for(ll x=i;x<=j;x++)
            sum+=v[x];
        ll temp_ans=sum+((t[i][k]!=-1)?(t[i][k]):solve(i,k))+((t[k+1][j]!=-1)?(t[k+1][j]):solve(k+1,j));
        ans=min(ans,temp_ans);
    }
    t[i][j]=ans;
    return ans;
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("inputh.txt", "r", stdin);
    freopen("outputh.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
    memset(t,-1,sizeof(t));
    //cin>>test;
    while(test--)
    {

            ll n;
            cin>>n;
            fo(i,n)
            cin>>v[i];
//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
           cout<< solve(0,n-1);
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not





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

def main():
    n, x, m = map(int, input().split())
    cycle = [False]*m
    next_list = [-1]*m
    cycle[x] = True
    
    now = x
    count = 1
    for i in range(m):
        nex = pow(now, 2, m)
        if count == n:
            break
        if cycle[nex]:
            next_list[now] = nex
            break
        next_list[now] = nex
        cycle[nex] = True
        now = nex
        count += 1
    
    ans = 0
    if count == n:
        for i in range(m):
            if cycle[i]:
                ans += i
        
    else:
        judge = x
        while judge != now:
            ans += judge
            judge = next_list[judge]
            n -= 1
        
        key = judge
        judge = next_list[judge]

        count = 1
        while judge != now:
            key += judge
            judge = next_list[judge]
            count += 1
        
        ans += n//count * key
        n %= count
        while n > 0:
            n -= 1
            ans += judge
            judge = next_list[judge]
    

        

    print(ans)

    
    
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 66748
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] s = new char[h][w];
		for (int i = 0; i < h; i++) {
			s[i] = sc.next().toCharArray();
		}
		sc.close();

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i][j] == '#') {
					boolean flg = false;
					if (i > 0 && s[i - 1][j] == '#') flg = true;
					if (i < h - 1 && s[i + 1][j] == '#') flg = true;
					if (j > 0 && s[i][j - 1] == '#') flg = true;
					if (j < w - 1 && s[i][j + 1] == '#') flg = true;
					if (!flg) {
						System.out.println("No");
						return;
					}
				}
			}
		}
		System.out.println("Yes");
	}
}


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

using namespace std;

int main()
{
	int n, temp, lastmin;
	vector<int> a;

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		scanf("%d", &temp);
		a.push_back(temp);
	}

	sort(a.begin(), a.end());
	lastmin = a[0];

	while (true)
	{
		for (int i = 1; i < n; i++)
		{
			a[i] %= a[0];
			if (a[i] == 0) a[i] = a[0];
		}
		sort(a.begin(), a.end());
		if (lastmin == a[0]) break;
		lastmin = a[0];
	}

	printf("%d\n", a[0]);

	return 0;
}

Measured memory_bytes: 892
import sys
readline = sys.stdin.readline
def insertionSort(n, A):
    print(*A)
    for i in range(1, n):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        print(*A)
n = int(readline())
A = [int(j) for j in readline().split(" ")]
insertionSort(n, A)

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  string a, b, c, n, x, y;
  cin >> a >> b >> c;
  // cin >> a >> b >> c;
  if ((a[a.length() - 1] == b[0]) && (b[b.length() - 1] == c[0]))
    YES();
  else
    NO();
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int MAX_N = 101000;
int n;
int pre[MAX_N], col[MAX_N];
vector<int> G[MAX_N];
int bfs()
{
    bool used[n + 1];
    memset(used, false, sizeof(used));
    queue<P> que;
    que.push(P(0, 0));
    while(!que.empty())
    {
        P p = que.front(); que.pop();
        int now = p.first;
        int cost = p.second;
        if(now == n - 1) return cost;
        if(used[now]) continue;
        used[now] = true;
        for(int next : G[now])
        {
            if(used[next]) continue;
            pre[next] = now;
            que.push(P(next, cost + 1));
        }
    }
}
void bfs2()
{
    int used[n + 1];
    memset(used, false, sizeof(used));
    queue<P> que;
    que.push(P(0, 0));
    while(!que.empty())
    {
        P p = que.front(); que.pop();
        int now = p.first;
        int cost = p.second;
        if(used[now]) continue;
        used[now] = true;
        col[now] = 1;
        for(int next : G[now])
        {
            if(used[next]) continue;
            if(col[next] == 2) continue;
            que.push(P(next, cost + 1));
        }
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int num = bfs();
    int now = n - 1;
    int cnt = 0;
    while(1)
    {
        if(cnt < (num + 1) / 2) col[now] = 2;
        else col[now] = 1;
        cnt++;
        if(now == 0) break;
        now = pre[now];
    }
    bfs2();
    int f = 0;
    for(int i = 0; i < n; i++) if(col[i] == 1) f++;
    cout << (f > (n - f) ? "Fennec" : "Snuke") << endl;
    return 0;
}

Measured memory_bytes: 7100
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int t = (c - 1) / b + 1;
	int k = (a - 1) / d + 1;
	cout << ((t <= k) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int x;
    cin >> x;
    COUT(x*x*x);
}



Measured memory_bytes: 3092
n = gets.to_i
hash = Hash.new(0)
1.upto(101) do |x|
  1.upto(101) do |y|
    1.upto(101) do |z|
      hash[x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x] += 1
    end
  end
end
1.upto(n) do |i|
  puts hash[i]
end


Measured memory_bytes: 16676
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(int i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1<<30;
//typedef long double ld;
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; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
int main(){
  int h,w,a,b;  cin>>h>>w>>a>>b;
  int d[h][w];
  rep(i,0,b)rep(j,0,a) d[i][j] = 0;
  rep(i,0,b)rep(j,a,w) d[i][j] = 1;
  rep(i,b,h)rep(j,0,a) d[i][j] = 1;
  rep(i,b,h)rep(j,a,w) d[i][j] = 0;
  rep(i,0,h){
    rep(j,0,w){
      cout << d[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 5120
s = input()
n = len(s)

a = [0]*n
ans = [0]*n

for i in range(n):
    x = 0
    if s[i] == 'R':
        if i > 0 and a[i-1] > 0:
            x = a[i-1] - 1
        else:
            while s[i+x] == 'R':
                x += 1
    if s[i] == 'L':
        if i > 0 and a[i-1] < 0:
            x = a[i-1] - 1
        else:
            while s[i+x] == 'L':
                x -= 1
    a[i] = x

    if a[i] == 1 or a[i] == -1:
        ans[i] += 1
    elif a[i] % 2 == 0:
        ans[i+ a[i]] += 1
    elif a[i] > 0:
        ans[i+ a[i] - 1] += 1
    elif a[i] < 0:
        ans[i+ a[i] + 1] += 1
        
ans = [str(i) for i in ans]
print(' '.join(ans))

Measured memory_bytes: 84244
h, w = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]

if h == 1 and w == 1:
    print(0)
    exit()

cnt = 0
ans = []
for i in range(h):
    for j in range(w):
        a = A[i][j]
        if a%2 == 1:
            for dy, dx in (-1, 0), (0, -1), (0, 1), (1, 0):
                ni = i+dy
                nj = j+dx
                if 0 <= ni < h and 0 <= nj < w:
                    ni_ = ni
                    nj_ = nj
                    if A[ni][nj]%2 == 1:
                        A[ni][nj] += 1
                        A[i][j] -= 1
                        cnt += 1
                        ans.append([i+1, j+1, ni+1, nj+1])
                        break
            else:
                A[ni_][nj_] += 1
                A[i][j] -= 1
                cnt += 1
                ans.append([i+1, j+1, ni_+1, nj_+1])

print(cnt)
for i in range(cnt):
    print(*ans[i])


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

int main() {
  int A, B;
  cin >> A >> B;
  int count = 0;
  for (int i = A; i <= B; i++) {
    string S = to_string(i);
    if (S[0] == S[4] && S[1] == S[3]) count += 1;
  }
  cout << count << endl;
}

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

using namespace std;

int solve(int x, int y) {
	int a, b;
	a = max(x, y);
	b = min(x, y);
	if (a%b > 0)return solve(a%b, b);
	else return b;
}

int main(){
	int x, y;
	cin >> x >> y;
	cout << solve(x, y) << endl;
	return 0;
}

Measured memory_bytes: 3100
// Grid Repainting 2

#include <iostream>

using namespace std;

int main(){
	int H, W;
	cin >> H >> W;
	char s[H][W];
	for (int i = 0; i < H; ++i)
		for (int j = 0; j < W; ++j)
			cin >> s[i][j];

	for (int i = 0; i < H; ++i)
		for (int j = 0; j < W; ++j){
			if (s[i][j] == '#'){
				if (i-1 >= 0 && s[i-1][j] != '#' &&
					i+1 < H && s[i+1][j] != '#' &&
					j-1 >= 0 && s[i][j-1] != '#' &&
					j+1 < W && s[i][j+1] != '#'){
					cout << "No" << endl;
					return 0;
				}
			}
		}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;

vector<int> cost(1000000);
vector<vector<int>> data(1000000);


int main(){
    int n;
    cin >> n;
    if(n >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n;

main() {
    cin >> n;
    ct(48-n)
}






Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;

#define FOR(i,c) for (__typeof((c).begin())i=(c).begin(); i!=(c).end(); ++i)

int main() {
    int n, m , L;
    cin >> n >> m >> L;
    int v[n];
    double t[n][m+1], p[n][m+1], sump[n][m+1];
    for (int i=0; i<n; ++i) {
        double pp, tt;
        cin >> pp>>tt>>v[i];
        pp/=100;
        
        for (int k=0; k<=m; ++k) {
            p[i][k] = 1;
            for (int l=0; l<=m; ++l) {
                if (l < k) p[i][k] *= m-l;
                if (k-l >= 1) {
                    p[i][k] /= k-l;
                }
                if (l<k) p[i][k] *= pp;
                if (l<m-k) p[i][k] *= (1.0-pp);
            }
            t[i][k] = (double)L/v[i] + k*tt;
//            printf("i=%d, k=%d %f\n", i,k,p[i][k]);
            if (k>0)
                sump[i][k] = sump[i][k-1] + p[i][k];
            else
                sump[i][k] = p[i][k];
        }
    }
    
    double ans[n];
    for (int i=0;i<n;++i) ans[i] = 0;

    for (int i=0; i<n; ++i) {
        for (int j=0; j<=m; ++j) {           
            double tmp = p[i][j];
            for (int k=0; k<n; ++k) {
                if (i==k) continue;
                if (upper_bound(t[k], t[k]+m+1, t[i][j])-t[k] == 0) {
                    
//                    printf("zero %d %d\n", i, j);
                    // tmp = 0;
                    // break;
                }
                else 
                    tmp *= (1.0 - sump[k][upper_bound(t[k], t[k]+m+1, t[i][j])-t[k]-1]);
            }
//            printf("%d,%d %f\n", i,j,tmp);
            ans[i] += tmp;
        }
    }

    for (int i=0;i<n;++i)
        printf("%.12f\n", ans[i]);
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAXN = 500100;

int N;
ll L;
ll t[MAXN], v[MAXN];

vector <pair <ld, ld> > hull;

int main()
{
	cin >> N >> L;
	for (int i = 0; i < N; i++)
		cin >> t[i] >> v[i];
	cout << fixed << setprecision(9);

	hull.push_back(make_pair(0, 0));
	int chull = 0;
	for (int i = 0; i < N; i++)
	{
		ld vtot = v[i] + hull.back().first;
		ld ttot = t[i] * v[i] + hull.back().second;
		hull.push_back(make_pair(vtot, ttot));

		while (chull + 1 < hull.size() && hull[chull + 1].first + L <= vtot)
			chull++;
		ld vlo = hull[chull].first - (vtot - L), vhi = hull[chull + 1].first - (vtot - L);
		ld ttemp = (vhi * hull[chull].second - vlo * hull[chull + 1].second) / (vhi - vlo);
		hull[chull] = make_pair(vtot - L, ttemp);
		cout << (ttot - ttemp) / L << "\n";

		hull.pop_back();
		while (hull.size() > chull + 1)
		{
			ld v1 = hull[hull.size() - 2].first, t1 = hull[hull.size() - 2].second;
			ld v2 = hull[hull.size() - 1].first, t2 = hull[hull.size() - 1].second;
			if (t1 * (vtot - v2) + ttot * (v2 - v1) < (vtot - v1) * t2)
				hull.pop_back();
			else
				break;
		}
		hull.push_back(make_pair(vtot, ttot));
	}
}

Measured memory_bytes: 34020
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 1; ; i++) {
            int x = sc.nextInt();
            if(x==0) break;
            System.out.println("Case " + i + ": " + x);

        }
    }
}



Measured memory_bytes: 43372
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  cin >> A;
  cin >> B;
  cin >> C;
  if (A<C && C<B) {
    cout << "Yes" << endl;
    return 0;
  }
  if (B<C && C<A) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}
  

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	m := map[int]int{}
	for i := 1; i <= n; i++ {
		tmp := nextInt()
		m[tmp] = i
	}
	for i := 1; i <= n; i++ {
		fmt.Printf("%d ", m[i])
	}
	fmt.Println("")
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 8208
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

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

const int MOD = 1000000007;

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


    //! 9 * numDigts + digitsSum gets 9 less than the prev value 
    LL digits = 0;
    LL digitsSum = 0;

    int M;
    cin >> M;
    rep(i, M) {
        LL d, c;
        cin >> d >> c;
        digits += c;
        digitsSum += d * c;
    }

    LL x = 9 * digits + digitsSum;
    LL r = x % 9;
    LL last = r + (r ? 9 : 18);
    LL ans = (x - last) / 9;

    cout << ans << endl;

    return 0;
}


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

def canMakeNumber(k, s):
    k = str(k).zfill(3)
    dic = {0: False, 1: False, 2: False}
    for t in s:
        if dic[0] is False:
            if t == k[0]:
                dic[0] = True
        else:
            if dic[1] is False:
                if t == k[1]:
                    dic[1] = True
            else:
                if dic[2] is False:
                    if t == k[2]:
                        dic[2] = True
                        return True
                else:
                    return True
    return False


N = int(input())
S = input()
ans = 0
for i in range(0, 1000):
    if canMakeNumber(i, str(S)):
        ans += 1
print(ans)


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int a[10];
int k;

signed main() {
  rep (i, 5) {
    cin >> a[i];
  }
  cin >> k;

  rep (i, 5) {
    rep (j, 5) {
      if (abs(a[i] - a[j]) > k) {
        puts(":(");
        return 0;
      }
    }
  }

  puts("Yay!");

  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int main() {
  int n;

  cin >> n;

  vector<vector<int>> v;
  v.resize(n);
  for(int i = 0; i < n; i++){
    int w;
    cin >> w;

    v[i].push_back(1);
    v[i].push_back(2);
    v[i].push_back(3);
    for(int j = 0; j < w; j++){
      int a;
      cin >> a;
      if(a == 0){
        if(v[i][0] == 1){
          v[i][0] = 2;
        }
        else if(v[i][0] == 2){
          v[i][0] = 1;
        }
        if(v[i][1] == 1){
          v[i][1] = 2;
        }
        else if(v[i][1] == 2){
          v[i][1] = 1;
        }
        if(v[i][2] == 1){
          v[i][2] = 2;
        }
        else if(v[i][2] == 2){
          v[i][2] = 1;
        }
      }
      else{
        if(v[i][0] == 2){
          v[i][0] = 3;
        }
        else if(v[i][0] == 3){
          v[i][0] = 2;
        }
        if(v[i][1] == 2){
          v[i][1] = 3;
        }
        else if(v[i][1] == 3){
          v[i][1] = 2;
        }
        if(v[i][2] == 2){
          v[i][2] = 3;
        }
        else if(v[i][2] == 3){
          v[i][2] = 2;
        }
      }
    }
  }

  int cnt[3]={0,0,0};
  rep(i,n){
    if(v[i][0] == 1 && v[i][1] == 2 && v[i][2] == 3){
      cout << "yes" << endl;
      return 0;
    }
    if(v[i][0]==1&&v[i][1]!=2)cnt[0]++;
    if(v[i][1]==2&&v[i][2]!=3)cnt[1]++;
    if(v[i][2]==3&&v[i][0]!=1)cnt[2]++;
  }
  rep(j,3){
    if(cnt[j]>=2){
      cout<<"yes"<<endl;
      return 0;
    }
  }

  int cnt2[2]={0,0};
  rep(i,n){
    if(v[i][0] == 2 && v[i][1] == 3 && v[i][2] == 1){
      cnt2[0]++;
    }
    if(v[i][0] == 3 && v[i][1] == 1 && v[i][2] == 2){
      cnt2[1]++;
    }
  }
  rep(j,2){
    if(cnt[j]>=3){
      cout<<"yes"<<endl;
      return 0;
    }
  }

  vector<int> idx;
  rep(i,n)idx.push_back(i);

  do{
    vector<int> y = {1, 2, 3}, tmp = {0, 0, 0};
    rep(i,n){
      int j=idx[i];
      tmp[v[j][0]-1] = y[0];
      tmp[v[j][1]-1] = y[1];
      tmp[v[j][2]-1] = y[2];
      if(tmp[0] == 1 && tmp[1] == 2 && tmp[2] == 3){
        cout << "yes" << endl;
        return 0;
      }
      else{
        y[0] = tmp[0];
        y[1] = tmp[1];
        y[2] = tmp[2];
      }
    }
  }while(next_permutation(all(idx)));

  cout<<"no"<<endl;

  return 0;
}



Measured memory_bytes: 3168
#include <stdio.h>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,a,b) for(int i=(a);i>=(b);i--)

using namespace std;
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;


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


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

  vi L(N);

  rep(i, 0, N-1) cin >> L[i];

  ll D = 0;
  int i = 0;
  int ll = 0;
  while(D  <= X) {
    ll++;
    if (i >= N) break;
    D += L[i];
    i++;
  }

  cout << ll << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

long A[100000];

long b[60];

void init(){
    long m = 1;
    for(int i = 0; i < 60; i++){
        b[i] = m;
        m = m<<1;
    }
}

void sweep(long A[], int N){
    int cur = 0;
    for(int i = 0; i < 60 && cur < N ; i++){
        if(!(A[cur]&b[59-i])){
            for(int j = cur; j < N; j++){
                if(A[j]&b[59-i]) {
                    swap(A[cur], A[j]);
                    break;
                }
            } 
        }
        if(A[cur]&b[59-i]){
            for(int j = 0; j < N; j++){
                if(j == cur) continue;
                if(A[j]&b[59-i]){
                    A[j] = A[j]^A[cur];
                }
            }
            cur++;
        }
    }
}

int main(){
    init();
    int N;
    cin >> N;
    long total = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        total ^= A[i];
    }
    for(int i = 59; i >= 0; i--){
        long m = (long)1<<i;
        if(m&total){
            for(int j = 0; j < N; j++){
                if(A[j]&m) A[j] ^= m;
            }
        }
    }
    
    sweep(A, N);
    
    int cur = 0;
    long ans = 0;
    long tmp = 0;
    
    for(int i = 0; i < N; i++) ans ^= A[i];
    ans *= 2;
    ans += total;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <fstream>
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>

using namespace std;
#define ALL(c) (c).begin(), (c).end()
#define REP(i,n) for(ll i=0; i < (n); ++i)
using ll = long long;
using vl = vector<ll>;
int main(){
#ifdef _WIN32
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cout << fixed << setprecision(8);
	ll n, m; cin >> n >> m;
	vl a(m); REP(i, m) cin >> a[i];
	REP(i, m) a[i]--;

	sort(ALL(a));
	ll mi = 0;
	REP(i, n){
		auto it = lower_bound(ALL(a), i);
		ll mii = 100000;
		if(it != a.end()) mii = min<ll>(mii, abs(*it - i));
		if (it != a.begin()) mii = min<ll>(mii, abs(*--it - i));
		mi = max(mi, mii);
	}

	cout << mi << endl;
}

Measured memory_bytes: 3176
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define int long long
void read (int &x) {
    char ch = getchar(); x = 0;
    while (!isdigit(ch)) ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} const int N = 2e5 + 5;
int h, w;
#define ls (p << 1)
#define rs (p << 1 | 1)
struct tree {
    int c[N << 2], tag[N << 2];
    void push_down (int p) {
        tag[ls] += tag[p], tag[rs] += tag[p];
        c[ls] += tag[p], c[rs] += tag[p], tag[p] = 0;
    }
    void add (int p, int l, int r, int ql, int qr, int v) {
        if (ql <= l && r <= qr) { c[p] += v, tag[p] += v; return; }
        int mid (l + r >> 1); if (ql != 2 || qr != 2) push_down (p);
        if (ql <= mid) add (ls, l, mid, ql, qr, v);
        if (qr > mid) add (rs, mid + 1, r, ql, qr, v);
        c[p] = min (c[ls], c[rs]);
    }
    int query (int p, int l, int r, int ql, int qr) {
        if (ql <= l && r <= qr) return c[p];
        int mid (l + r >> 1), res = 1e15; push_down (p);
        if (ql <= mid) res = query (ls, l, mid, ql, qr);
        if (qr > mid) res = min (res, query (rs, mid + 1, r, ql, qr));
        return res;
    }
} A, B;
signed main() {
    read (h), read (w);
    for (int i = 1; i <= w; ++i)
        B.add (1, 1, w, i, i, -i);
    for (int i = 1, l, r, R; i <= h; ++i) {
        read (l), read (r); R = r + 1;
        if (R <= w) {
            int mn = B.query (1, 1, w, 1, R) + R;
            int a = A.query (1, 1, w, R, R), b = B.query (1, 1, w, R, R);
            A.add (1, 1, w, R, R, mn - a), B.add (1, 1, w, R, R, mn - R - b);
        }
        A.add (1, 1, w, l, r, 1e9); B.add (1, 1, w, l, r, 1e9);
        A.add (1, 1, w, 1, w, 1); B.add (1, 1, w, 1, w, 1);
        A.c[1] > h + w ? puts ("-1") : printf ("%lld\n", A.c[1]);
    }
    return 0;
}


Measured memory_bytes: 20096
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

ll d[1001]={};
int a[100001]={};
int main() {
	int n;
	string s;
	cin>>n;
	int a1;
	for(int i=0;i<n;i++){
		cin>>a1;
		a[a1]++;
	}
	int maxa=100000;
	int mina=1;
	int res;
	for(mina=1;mina<=maxa;++mina){
		if(a[mina]>1){
			res=a[mina]-1;
			a[mina]=1;
			res=res%2;
			for(;(mina<maxa)&&(res>0);maxa--){
				if(a[maxa]>1){
						res=0;
						a[maxa]-=1;
						break;
				}
			}
		}
	}
	int total=0;
	for(int i=1;i<100001;++i){
		total+=a[i];
	}
		cout<<total-res<<endl;
	return 0;
}


Measured memory_bytes: 640
from copy import deepcopy


def solve(N, abc):
    dp = [[0, 0, 0] for i in range(N+1)]

    for i in range(1, N+1):
        for j in range(3):
            tmp = deepcopy(dp[i-1])
            tmp.pop(j)
            dp[i][j] = max(tmp) + abc[i-1][j]

    return(max(dp[N]))


if __name__ == "__main__":
    N = int(input())
    abc = [list(map(int, input().split())) for _ in range(N)]
    print(solve(N, abc))


Measured memory_bytes: 50224
#include <iostream>
#include <map>

using namespace std;

int main(){
  int N, A, B;
  cin >> N >> A >>B;
  string S;
  cin >> S;
  //入力終わり

  int sum = 0;
  //海外の人の予選通過
  int bn = 1; 

  for(int i=0; i<N; i++){
    //学生でなければ飛ばす
    if(S[i] == 'c'){
      cout << "No" << endl;
      continue;
    }
    //予選通過人数がA+B人に満たない
    if(sum < A+B){
      if(S[i] == 'a'){
	cout << "Yes" << endl;
	sum++;
      }
      else if(S[i] == 'b'){
	//海外の予選通過人数がB人以下
	if(bn <= B){
	  cout << "Yes" << endl;
	  bn++;
	  sum++;
	}
	else
	  cout << "No" << endl;
      }
    }
    //A+B人の予選通過が決定した状態
    else
      cout << "No" << endl;
    
  }


  return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int n,m,a[100010],f[100010];
int get(int x)
{
	if (f[x]==x) return x;else f[x]=get(f[x]);
	return f[x];
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		f[i]=i;
	}
	for (int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		f[get(x)]=get(y);
	}
	int ans=0;
	for (int i=1;i<=n;i++)
		if (get(i)==get(a[i])) ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
E = []
for _ in range(N - 1):
    u, v = sorted(list(map(int, input().split())))
    E.append((u, v))
ans = 0
for v in range(1, N+1):
    ans += (N - v + 1) * v
for u, v in E:
    ans -= (N - v + 1) * u
print(ans)

Measured memory_bytes: 36048
// AtCoder AGC095 C - Many Medians
// 2020.1.22 bal4u

#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0; int c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void outs(char *s) { while (*s) pc(*s++); }

char *out(char *b, int n) { // 非負整数の表示（出力）
	int i;
	i = 15, b[i] = 0;
	b[--i] = '\n';
	while (n) b[--i] = n % 10 + '0', n /= 10;
	return b+i;
}

// n番目に小さい値を算出する n:0-index
int selection(int *a, int sz, int n) {
  int i, j, p, l, r, t;
  l = 0, r = sz-1;
  while (l < r) {
    p = a[(l+r)/2];
    i = l-1, j = r+1;
    while (1) {
      while (a[++i] < p);
      while (a[--j] > p);
      if (i > j) break;
      t = a[i], a[i] = a[j], a[j] = t;
    }
    if (n < i) r = j;
    if (n > j) l = i;
  }
  return a[n];
}

int N;
int a[200005];
int b[200005];

int main()
{
	int i, n, a1, a2;
	char *p1, *p2, s1[20], s2[20];
	
	N = in(), n = N / 2;
	i = N; while (i--) a[i] = in();
	memcpy(b, a, N*sizeof(int));
	a1 = selection(b, N, n-1);
	a2 = selection(b, N, n);
	p1 = out(s1, a1), p2 = out(s2, a2);
	while (N--) outs((a[N] >= a2)? p1: p2);
	return 0;
}


Measured memory_bytes: 3712
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
N=int(input())
A=factorization(N)
ans=0
if N==1:
 print(0)
else:
 for i in range(len(A)):
  ans+=int((2*A[i][1]+0.25)**(0.5)-0.5)
 print(ans)

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

int main()
{
    long a, b, c, k;
    long ans;
    // scanf("%d", &x);
    cin >> a >> b >> c >> k;
    if (k <= a)
    {
        cout << k << endl;
        return 0;
    }
    k -= a;
    if (k <= b)
    {
        cout << a << endl;
        return 0;
    }
    k -= b;
    cout << a - k << endl;
}

Measured memory_bytes: 3632
/*
g++ -std=c++11 -o2 -Wall ABC112A.cpp -o .\out\ABC112A.out
.\out\ABC112A.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  if (n == 1) {
    cout << "Hello World\n";
  } else {
    int a, b;
    cin >> a >> b;
    cout << (a+b) << "\n";
  }
}


Measured memory_bytes: 256