akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
// Int MOD = 998244353;


int main() {
    ios::sync_with_stdio(false);
    Int x[4] = {};
    for (Int i = 0; i < 3; i++) {
        Int a, b;
        cin >> a >> b;
        x[a - 1]++;
        x[b - 1]++;
    }
    sort(x, x + 4);
    Int s[4] = {1, 1, 2, 2};
    bool res = true;
    for (Int i = 0; i < 4; i++) {
        if (x[i] != s[i]) res = false;
    }
    dump(res ? "YES" : "NO");
    return 0;  
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono>
#include <climits>
#include <unordered_map>
#include <iomanip> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;


int main(){
	fast;
	#ifdef LOCAL_PROJECT
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif

	auto start = high_resolution_clock::now(); 

	int n;
	string s;
	cin >> n >> s;
	if (n%2 == 0){
		int flag = 1;
		for(int i = 0; i < n/2; i++){
			if (s[i] != s[i+n/2])
				flag = 0;
		}
		if (flag == 1)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	else
		cout << "No" << endl;
	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << fixed << setprecision(9) << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[]){
    int N,X,i,min,answer,sum;
    char scan[256];
    int array[100000];
    scanf("%d %d",&N,&X);
    for (i = 0; i < N; i++) {
        scanf("%d",&array[i]);
        if(i==0||min>array[i]){
            min=array[i];
        }
    }
    for (i = 0; i < N; i++) {
        sum=sum+array[i];
    }
    answer=(X-sum)/min+N;
    printf("%d",answer);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=1e5+50;
int n,a[N];LL s[N],ans,now;
int main(){
    scanf("%d",&n);
    for(int i=0;i<=n;i++)scanf("%d",&a[i]);
    for(int i=n;i;i--)s[i]=s[i+1]+a[i];
    for(int i=0;i<=n;i++){
        now=i?min(now*2,s[i]):1,ans+=now;
        if(now<a[i])puts("-1"),exit(0);
        now-=a[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4820
import scala.io.StdIn._
import scala.annotation.tailrec

object Main {

  object Dice{
    private val north = List(2,6,3,4,1,5).map(_ - 1)
    private val east = List(4,2,1,6,5,3).map(_ - 1)
    private val ccw = List(1,4,2,5,3,6).map(_ - 1)

    def vertical(d: Dice): List[Dice] =
      List(d, d.north, d.north.north, d.south)

    def horizontal(d: Dice): List[Dice] =
      List(d, d.east, d.east.east, d.west)

    def turn(d: Dice): List[Dice] = List(d, d.ccw, d.uturn, d.cw)

    def enumerateTop(d: Dice, n: Int = 24): List[Dice] = {
      if(n<=0)List[Dice]()
      else d :: enumerateTop(if(n%2==0)d.north else d.east, n-1)
    }

    def enumerate(d: Dice): List[Dice] = enumerateTop(d).flatMap(turn)
  }

  case class Dice(pip: List[Int] = List(1,2,3,4,5,6)) {
    private def north = Dice(Dice.north.map(pip))
    private def east = Dice(Dice.east.map(pip))
    private def south = north.north.north
    private def west = east.east.east
    private def ccw = Dice(Dice.ccw.map(pip))
    private def uturn = ccw.ccw
    private def cw = ccw.uturn

    def rotate(com: Char):Dice = com match {
      case 'N' => north
      case 'E' => east
      case 'S' => south
      case 'W' => west
      case _ => this
    }
  }

  @tailrec
  def loop(n:Int, all: List[Dice]):Unit = if(n>0){
    val Array(a,b,_*) = readLine.split(" ").map(_.toInt)
    val res = all.filter(d => d.pip(0)==a && d.pip(1)==b)
    println(res(0).pip(2))
    loop(n-1,all)
  }

  def main(args: Array[String]): Unit = {
    val pip = readLine.split(" ").map(_.toInt).toList
    val all: List[Dice] = Dice.enumerate(Dice(pip))
    val Array(n,_*) = readLine.split(" ").map(_.toInt)
    loop(n,all)
  }
}

Measured memory_bytes: 41220
use std::io::Read;
use std::cmp::min;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let m: usize = it.next().unwrap().parse().unwrap();
    let inf = 1_000_000;
    let mut dp = vec![inf; 1 << n];
    dp[0] = 0;
    for _ in 0..m {
        let a: u32 = it.next().unwrap().parse().unwrap();
        let b: usize = it.next().unwrap().parse().unwrap();
        let mut bit = 0;
        for _ in 0..b {
            let c = it.next().unwrap().parse::<usize>().unwrap() - 1;
            bit |= 1 << c;
        }
        dp[bit] = min(dp[bit], a);
    }
    for i in 0..n {
        for j in 0..(1 << n) {
            if (j >> i) & 1 == 1 {
                dp[j ^ (1 << i)] = min(dp[j ^ (1 << i)], dp[j]);
            }
        }
    }
    for i in 1..(1 << n) {
        let mut j = (i - 1) & i;
        while j > 0 {
            dp[i] = min(dp[i], dp[i ^ j] + dp[j]);
            j = (j - 1) & i;
        }
    }
    if dp[(1 << n) - 1] == inf {
        println!("-1");
    } else {
        println!("{}", dp[(1 << n) - 1]);
    }
}

fn main() {
    run();
}


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

const double eps = 1e-10;
bool dcmp(double d, double d2 = 0) { return abs(d - d2) < eps; }
double sgn(double d) {
  if (dcmp(d))
    return 0;
  if (d > 0)
    return 1;
  return -1;
}

struct vec {
  double x, y;
  vec(double x, double y) : x(x), y(y) {}
  vec() : x(0), y(0) {}
  const bool operator==(const vec &v) const {
    return dcmp(x, v.x) && dcmp(y, v.y);
  }
  const bool operator!=(const vec &v) const { return !(*this == v); }
  const vec operator+(const vec &v) const { return vec(x + v.x, y + v.y); }
  const vec operator-() const { return vec(-x, -y); }
  const vec operator-(const vec &v) const { return *this + (-v); }
  const vec operator*(const double d) const { return vec(x * d, y * d); }
  const vec operator/(const double d) const { return *this * (1 / d); }
  const vec unit() const { return *this / len(); };
  const double len() const { return sqrt(x * x + y * y); }
  const double dot(const vec &v) const { return x * v.x + y * v.y; }
  const double cross(const vec &v) const { return x * v.y - y * v.x; }
  const bool parallel(const vec &v) const { return dcmp(cross(v)); }
  const bool perpendicular(const vec &v) const { return dcmp(dot(v)); }
};

typedef vec point;

template <class T> struct optional {
  bool has;
  T val;
  optional() : has(false) {}
  optional(T t) : has(true), val(t) {}
};

struct line {
  double a, b, c;
  line(point p1, point p2) {
    a = p1.y - p2.y;
    b = p2.x - p1.x;
    c = (p1.x - p2.x) * p1.y + (p2.y - p1.y) * p1.x;
    double m1 = a * p1.x + b * p1.y + c;
    double m2 = a * p2.x + b * p2.y + c;
  }
  optional<point> intersect(line l) {
    if (dcmp(a * l.b, b * l.a))
      return optional<point>();
    return point(-(c * l.b - b * l.c) / (a * l.b - b * l.a),
                 (c * l.a - a * l.c) / (a * l.b - b * l.a));
  }
  bool contains(point p) { return dcmp(a * p.x + b * p.y + c); }
};

struct segment {
  point p1, p2;
  segment(point p1, point p2) : p1(p1), p2(p2) {}
  line sline() { return line(p1, p2); }
  bool contains(point p) {
    double x1 = min(p1.x, p2.x), x2 = max(p1.x, p2.x);
    double y1 = min(p1.y, p2.y), y2 = max(p1.y, p2.y);
    bool ok = sline().contains(p) && (x1 <= p.x && p.x <= x2) &&
              (y1 <= p.y && p.y <= y2);
    return ok;
  }
  bool intersect(segment s) {
    vec v0 = p2 - p1;
    vec v1 = s.p2 - s.p1;
    if (v0.parallel(v1)) {
      return (contains(s.p1) || contains(s.p2)) ||
             (s.contains(p1) || s.contains(p2));
    }
    point a = p1, b = p2, c = s.p1, d = s.p2;
    return sgn((a - b).cross(b - c)) != sgn((a - b).cross(b - d)) &&
           sgn((c - d).cross(d - a)) != sgn((c - d).cross(d - b));
  }
};

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    point p0, p1, p2, p3;
    cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
    segment l0(p0, p1);
    segment l1(p2, p3);
    line ll0 = l0.sline();
    line ll1 = l1.sline();
    // printf("%lfx + %lfy + %lf = 0\n", ll0.a, ll0.b, ll0.c);
    // printf("%lfx + %lfy + %lf = 0\n", ll1.a, ll1.b, ll1.c);
    bool has = l0.intersect(l1);
    cout << (has ? 1 : 0) << endl;
  }
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main(){
    int N;
    cin >> N;
    vector<ll> t(N), a(N);
    for(int i=0; i<N; i++) {
        cin >> t[i] >> a[i];
    }


    ll T = 1, A = 1;
    for(int i=0; i<N; i++) {
        ll co = max((T+t[i]-1)/t[i], (A+a[i]-1)/a[i]);
        T = co * t[i];
        A = co * a[i];
    }
    cout << T + A << endl;
}

Measured memory_bytes: 3584
void main(){
	int k = _scan();
	string s = readln().chomp();
	if( s.length <= k ){
		s.writeln();
		return;
	}else{
		( s[0..k] ~ "..." ).writeln();
	}
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

int main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++) {
		for (int j = i; j < s.size(); j++) {
			if (s.at(i) > s.at(j)) {
				swap(s.at(i), s.at(j));
			}
		}
	}
	for (int i = 0; i < t.size(); i++) {
		for (int j = i; j < t.size(); j++) {
			if (t.at(i) < t.at(j)) {
				swap(t.at(i), t.at(j));
			}
		}
	}
	if (s < t)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
#define int long long
#define f(i,n) for(ll i=0;i<n;i++)
#define fo(i,a,b) for(ll i=a;i<=b;i++)
#define forr(i,a,b) for(ll i=a;i>=b;i--)
#define bp __builtin_popcount
#define all(x) (x).begin(),(x).end()
#define s(x) sort(all(x))
#define r(x) reverse(all(x))
#define vll vector<ll>
#define pll pair<ll,ll>
#define sz size()
#define ln length()
#define pi acos(-1)
#define U 1e9
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second 
#define vl vector<ll>
#define pll pair<ll,ll>
#define KHILADI ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))
//cout << fixed << showpoint;
//cout << setprecision(7);

ll max(ll a , ll b){ if(a>b) return a; else return b;}
ll min(ll a , ll b){ if(a<b) return a; else return b;}

ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}          
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

signed main()
{
    KHILADI;
    ll n;
    cin >> n;
    ll a[n];
    f(i,n)  
        cin >> a[i];
    f(i,n)
    {
        if(a[i]%2==0)
        {
            if(a[i]%3==0 || a[i]%5==0)
                continue;
            else
            {
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
    return 0;
}




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

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

void solve(long long A, long long B)
{
    if (B % A == 0)
    {
        cout << A + B << endl;
    }
    else
    {
        cout << B - A << endl;
    }
}

int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{int n,k,sum=0;
 cin>>n>>k;
 int a[n];
 for(int i=0;i<n;i++)
   cin>>a[i];
 sort(a,a+n);
 for(int i=0;i<n;i++)
 {
     if(k)
   {

   sum+=a[i];
   k--;
}
else break;
 }
 cout<<sum;
}

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

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();
    
    if k <= (n+1)/2 {
        println!("YES");
    } else {
        println!("NO");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }



void solve(long long N){
	double res = 0;
	ll ki = N/2;
	if (N%2) ki++;
	res = double(ki)/N;
	PRINTD(res, 10);
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void){
  int n,i;
  ll t[100010],a[100010],ans=1;
  const int mod=1e9+7;
  cin >> n;
  for (i=0;i<n;i++) cin >> t[i];
  for (i=0;i<n;i++) cin >> a[i];
  if (t[0]>a[0] || t[n-1]<a[n-1]){
    cout << 0 << endl;
    return 0;
  }
  for (i=1;i<n-1;i++){
    if ((t[i]!=t[i-1] && t[i]>a[i]) || (a[i]!=a[i+1] && a[i]>t[i])){
      cout << 0 << endl;
      return 0;
    }
    if (t[i]==t[i-1] && a[i]==a[i+1]) ans=(ans*min(t[i],a[i]))%mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<queue>
#include<cstring>
using namespace std;
const int N=210;
char a[N][N];
int dist[N][N];
const int dx[3] = {0, 1}, dy[3] = {1, 0};
struct Node{
    int x,y,dist;
    friend bool operator <(Node a,Node b){
        return a.dist>b.dist;
    }
};
int main()
{
    int n,m;
    priority_queue<Node> q;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%s", a[i]+1);
    }
    memset(dist, 0x3f, sizeof dist);
    dist[1][1] = a[1][1]!='.';
    q.push((Node){1, 1, a[1][1]!='.'});
    while(!q.empty()){
        Node t=q.top();
        q.pop();
        if(t.dist>dist[t.x][t.y]) continue;
        for(int i=0;i<2;i++){
            int u=t.x+dx[i],v=t.y+dy[i];
            if(u<=0||u>n||v<=0||v>m) continue;
            if(dist[u][v]>t.dist+(a[t.x][t.y]=='.'&&a[u][v]!='.')){
                dist[u][v] = t.dist+(a[t.x][t.y]=='.'&&a[u][v]!='.');
                q.push((Node){u,v,dist[u][v]});
            }
        }
    }
    cout<<dist[n][m]<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void){

  int a=100000;
  int i,n;
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    a=a*1.05;
    if(a%1000!=0)
      a=(a/1000+1)*1000;
  }
  printf("%d\n",a);
  return 0;
}

Measured memory_bytes: 592
A = int(input())
B = int(input())
C = int(input())
X = int(input())
sum = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if(i*500+j*100+k*50 == X):
                sum+=1
print(sum)


Measured memory_bytes: 3060
n = int(input())
L = []
for _ in range(n):
    x, l = map(int, input().split())
    L.append([x - l, x + l])
L = sorted(L, key=lambda x: x[1])
ans = 0
r = -float('inf')
for i in range(n):
    if L[i][0] >= r:
        ans += 1
        r = L[i][1]
print(ans)


Measured memory_bytes: 22104
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "D"
int n;
struct town{
    int x, y;
    int i;
} t[100001];
bool cmpx(town a, town b){
    return a.x<b.x;
}
bool cmpy(town a, town b){
    return a.y<b.y;
}
struct edge{
    int u, v, c;
} e[200001];
bool cmp(edge a, edge b){
    return a.c<b.c;
}
int m;
int r[100001];
int root(int u){
    if(r[u]<0) return u;
    return r[u]=root(r[u]);
}
bool uni(int u, int v){
    u=root(u); v=root(v);
    if(u!=v){
        if(r[u]>r[v]) swap(u, v);
        r[u]+=r[v];
        r[v]=u;
        return 1;
    }
    return 0;
}
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    read(n);
    FOR(i, 1, n){
        read(t[i].x);
        read(t[i].y);
        t[i].i=i;
    }
    sort(t+1, t+n+1, cmpx);
    FOR(i, 2, n){
        m++;
        e[m].u=t[i].i;
        e[m].v=t[i-1].i;
        e[m].c=t[i].x-t[i-1].x;
    }
    sort(t+1, t+n+1, cmpy);
    FOR(i, 2, n){
        m++;
        e[m].u=t[i].i;
        e[m].v=t[i-1].i;
        e[m].c=t[i].y-t[i-1].y;
    }
    FOR(i, 1, n) r[i]=-1;
    sort(e+1, e+m+1, cmp);
    ll ans=0;
    FOR(i, 1, m) if(uni(e[i].u, e[i].v)) ans+=e[i].c;
    write(ans);
}

Measured memory_bytes: 4224
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	long long n, a, b;
	cin >> n >> a >> b;



	if (a > b)swap(a, b);
	if ((b-a)%2) {
		long long d = (b - a) / 2;
		cout << d + min(a, n - b + 1) << endl;
	}
	else {
		cout << (b - a) / 2 << endl;
	}



	return 0;
}

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

int main()
{
    int a,b,c,d;
    std::cin>>a>>b>>c>>d;

    std::cout<<std::min(a,b)+std::min(c,d)<<std::endl;

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

s = input()
for i in range(1,len(s)+1):
    if i%2 == 0 and s[i-1] == 'R':
        print('No')
        exit(0)
    if i%2 == 1 and s[i-1] == 'L':
        print('No')
        exit(0)
print('Yes')

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    long long n,m;
    cin>>n>>m;
    int sum=0;
    if(2*n>=m)
        printf("%lld\n",m/2);
    else
        printf("%lld\n",n+(m-n*2)/4);
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}

bool IsPrime(LL N){
  if(N >= 1) return false;
  for(int i = 2; i*i <= N; ++i){
    if(N%i == 0) return false;
  }
  return true;
}

bool ComPaiSec(PII a, PII b){
  if(a.SE != b.SE){
    return a.SE < b.SE;
  }else{
    return a.FI < b.FI;
  }
}

int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N;
  LL M=0;
  cin >> N;
  VI A(N);
  VB B(N,true);
  VPII C;
  REP(i,N){
    cin >> A.at(i);
  }
  SORT(A);
  
  
  FOR(i,1,N-1){
    if(A.at(i)<0){
      continue;
    }
    C.PB(MP(A.at(0),A.at(i)));
    A.at(0) -= A.at(i);
    B.at(i) = false;
  }
  
  REP(i,N-1){
    if(B.at(i)){
      C.PB(MP(A.at(N-1),A.at(i)));
      A.at(N-1) -= A.at(i);
    }
  }
  
  cout << A.at(N-1) << endl;
  
  REP(i,N-1){
    cout << C.at(i).FI << " " << C.at(i).SE << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3188
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

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

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

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

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

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int a,b;
    while (cin >> a >> b) {
        int x = b; 
        do {
            x = x/10;
            a = a*10;
        } while (x > 0);
        int y = a + b;
        int i=0;
        for (; i*i <= y; i++) {
            if (i*i == y)
                break;
        }
        if (i*i == y)
                cout << "Yes" << endl;
            else
                cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1023456789
#define sacnf scanf
#define CRLF <<'\n';
#define PRPAIR(x) x.first << x.second
#define DEBUG(x) do { std::cerr <<(x)<<'\n'; } while (0)
#define rep(i,a,b) for(int i=(a);i!=(int)b-((a)>(b));(a)>(b)?--i:++i)
#define trav(it,v) for(typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pip;
typedef vector<int> vi;
typedef long long ll;

int main(){
    char c;
    scanf("%c",&c);
    if ( 'A' <= c && c <= 'Z')
        cout << 'A';
    else if ('a' <= c && c <= 'z')
        cout << 'a';
}


Measured memory_bytes: 3660
#「探索候補スタック」「探索済みリスト」「現在地点」の３点セットでとらえる
n,q=map(int,input().split())
mat=[set() for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    mat[a-1].add(b-1)
    mat[b-1].add(a-1) # プラスした要素
count=[0]*n
for _ in range(q):
    p,score=map(int,input().split())
    count[p-1]+=score

stack=[[0,0,-1]]
while stack:
    # print(stack)
    num,cnt,pr=stack.pop()
    count[num]+=cnt
    for k in mat[num]:
        if k==pr:
            continue
        stack.append([k,count[num],num])
print(*count)

Measured memory_bytes: 98272
#include<bits/stdc++.h>
using namespace std;
void rd(long long &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(char a){
  putchar_unlocked(a);
}
void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
long long solve(long long A){
  if(A < 0){
    return 0;
  }
  if(A%4==0){
    return A;
  }
  if(A%4==1){
    return 1;
  }
  if(A%4==2){
    return A+1;
  }
  return 0;
}
int main(){
  long long A, B, res;
  rd(A);
  rd(B);
  res = solve(B) ^ solve(A-1);
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190227-1 [beta]

// --- original code ---
// ll solve(ll A){
//   if(A < 0) return 0;
//   if(A%4==0) return A;
//   if(A%4==1) return 1;
//   if(A%4==2) return A+1;
//   return 0;
// }
// {
//   ll A, B, res;
//   rd(A,B);
//   res = solve(B) ^ solve(A-1);
//   wt(res);
// }


Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;

int solve() 
{
	//happy coding

	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a+b>=k){
		cout<<min(a,k)<<endl;
	}else{
		//cout<<(k-(a+b))<<endl;
		cout<<a-(k-(a+b))<<endl;
	}
	
	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

Measured memory_bytes: 3620
n = int(input())

lis = list(map(int, input().split()))

ans = 0
tmp = 0

for i in range(1,n):
    if lis[i-1] >= lis[i]:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
        
ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 14224
#include<stdio.h>
int main()
{
	int n,m;
	scanf("%d",&n);
	int g=0,i;
	for(i=0;i<n;i++)
	{
		scanf("%d",&m);
		if(m%2==0)
		{
			if(m%3==0||m%5==0)
			{
				continue;
			}
			else
			{
				g=1;
			}
		}
	}
	if(g) printf("DENIED\n");
	else printf("APPROVED\n");
}

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

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(M);
    rep(i, M) cin >> A.at(i);

    int right = 0;
    int left = 0;

    rep(i, M) {
        if (A.at(i) > X) {
            right++;
        } else {
            left++;
        }
    }

    cout << min(right, left) << endl;
}


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

int main(){
int k; cin>>k;
int ans  = 0;
int count  = 0;
while(count <1000001){
ans = (ans*10 + 7)%k;
count++;
if(!ans){
cout<<count;
return 0;
}
}
cout<<-1;
}

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

using namespace std;
int main()
{
int a,i=0,k=0;
  cin >> a;
  int f[a]{};
  
int n;
cin >> n;
  
while(cin >> a){
f[i] = a;
i++;
}
  sort(f, f + i); 
i = 0;
while(i < n){
  
k = k + f[i];
  i++;
}

  cout << k;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(void){
    double a, b, c;
    cin >> a >> b >> c;
    c = c * M_PI / 180;
    double S = a * b * sin(c) / 2;
    double L = a + b + sqrt(a* a + b * b - 2 * a * b * cos(c));
    double h = S * 2 / a;
    cout << fixed << setprecision(15) << S << endl;
    cout << fixed << setprecision(15) << L << endl;
    cout << fixed << setprecision(15) << h << endl;
}



Measured memory_bytes: 3672
from itertools import groupby
from functools import reduce
from operator import xor

s = input()
k = int(input())
r = len(s) * k // 2
a = [reduce(xor, (1 for _ in g)) for _, g in groupby(s)]
if len(a) > 1:
  r -= sum(a) * k // 2
  if s[0] == s[-1] and a[0] & a[-1]:
    r += k - 1
print(r)


Measured memory_bytes: 3572
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int n = sc.nextInt();
    int total = 0;
    for(int i = 0;i<n;i++){
      total += sc.nextInt();
    }
    String ans;
    if(total >= h){
      ans = "Yes";
    }else{
      ans = "No";
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 47672
#DP D
n,W=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(n)]
dp=[[0]*(W+1) for _ in range(n+1)]
for i in range(n):
    w,v=wv[i]
    for j in range(W+1):
        if j<w:
            dp[i+1][j]=dp[i][j]
        else:
            dp[i+1][j]=max(dp[i][j],dp[i][j-w]+v)
print(dp[-1][-1])

Measured memory_bytes: 119916
n=int(input())
a=[]
for i in range(1,n+1):
    if (i%3==0):
        a.append(i)
        continue
    x=i
    while x>0:
        if (x%10==3):
            a.append(i)
            break
        x=x//10
result=" ".join([str(n) for n in a])
print("",result)


Measured memory_bytes: 6108
#include <iostream>
#include <cstdio>
#include <string>
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vvl G;
vl color;  // color[i] : 0は白、1は黒、-1は未訪問

bool dfs(ll v, ll now = 0) {
    color[v] = now;
    for(auto u : G[v]) { 
        if(color[u] != -1) {
            if(color[u] == now) {
                return false;
            }
            continue;
        }
        if(!dfs(u, 1-now)) {
            return false;
        }
    }
    return true;
}

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

    G.resize(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    
    color.assign(n, -1);
    bool nibuGraph = true;
    rep(v, n) {
        if(color[v] != -1) {
            continue;
        }
        if(!dfs(v)) {
            nibuGraph = false;
        }
    }
    
    // 二部グラフの場合
    // 異なる頂点集合間にはすべて辺を張ることができる
    if(nibuGraph) {
        ll cntW = 0, cntB = 0;
        rep(v, n) {
            if(color[v] == 0) {
                cntW++;
            }
            else if(color[v] == 1) {
                cntB++;
            }
        }
        out(cntW*cntB - m);
        re0;
    }

    // 二部グラフでない場合
    // 「二部グラフ」 ⇔ 「奇数長サイクルが存在しない」 より
    // 「二部グラフでない」 ⇒ 「奇数長サイクルが存在」
    // 奇数長サイクルは操作で完全グラフにできる
    // その完全グラフを使えばいいかんじにすべての辺を張れそう(てきとう)
    out(n*(n-1)/2 - m);
    re0;
}

Measured memory_bytes: 7424
/*+lmake
 * STD = c++14
 * DEFINE += MDEBUG
 */
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#ifdef MDEBUG
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#else
#define debug(args...) // Just strip off all debug tokens
#endif

struct debugger
{
    template <typename T>
    debugger &operator,(const T &v)
    {
        cerr << v << " ";
        return *this;
    }
} dbg;
#define MAXN 200000
int p[MAXN + 10];
void solve(long long N, vector<long long> X)
{
    vector<pair<LL, int>> a;
    for (int i = 0; i < N; ++i) {
        a.push_back(make_pair(X[i], i));
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < N; ++i) {
        p[a[i].second] = i;
    }
    int z = N / 2;
    for (int i = 0; i < N; ++i) {
        if (p[i]+1 <= z) {
            printf("%lld\n", a[z ].first);
        } else {
            printf("%lld\n", a[z-1].first);
        }
    }
}

int main()
{
	//freopen("in_C_1.txt","r",stdin);
    long long N;
    scanf("%lld", &N);
    vector<long long> X(N - 1 + 1);
    for (int i = 0; i <= N - 1; i++) {
        scanf("%lld", &X[i]);
    }
    solve(N, X);
    return 0;
}


Measured memory_bytes: 10220
import collections

N,K=map(int,input().split())
A=collections.Counter(map(int,input().split()))
A=sorted(A.items(),key=lambda x:x[1])
L=len(A)
ans=0

if K>=L:
  print(ans)
else:
  for a in A:
    ans+=a[1]
    L-=1
    if L==K:
      print(ans)

  

Measured memory_bytes: 45600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846264338327950288
#define mt make_tuple


void love() {
	int n; cin>>n;
	int a[n];
	for(int i = 0; i<n; i++) cin>>a[i];

	int ans = 0;
	int temp = 0;
	for(int i = 1; i<n; i++) {
		if(a[i] <= a[i-1]) temp++;
		else temp = 0;
		ans = max(ans, temp);
	}
	cout<<ans<<endl;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	love();
	return 0;
}

Measured memory_bytes: 640
//package abc157.B;

import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int[] a = new int[9];
		
		for (int i = 0; i < 9; i++) {
			a[i] = sc.nextInt();
		}
		
		int n = sc.nextInt();
		
		for (int i = 0; i < n; i++) {
			int b = sc.nextInt();
			for (int j = 0; j < 9; j++) {
				if (a[j] == b) a[j] = -1;
			}
		}
		
		String ans = "No";
		
		if (a[0] + a[1] + a[2] == -3) ans = "Yes";
		if (a[3] + a[4] + a[5] == -3) ans = "Yes";
		if (a[6] + a[7] + a[8] == -3) ans = "Yes";
		if (a[0] + a[3] + a[6] == -3) ans = "Yes";
		if (a[1] + a[4] + a[7] == -3) ans = "Yes";
		if (a[2] + a[5] + a[8] == -3) ans = "Yes";
		if (a[0] + a[4] + a[8] == -3) ans = "Yes";
		if (a[2] + a[4] + a[6] == -3) ans = "Yes";
		
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 23380
def f(a):
    for x in 'ox':
        if a[0::4].count(x)==3 or a[2:7:2].count(x)==3:return x
        for i in range(3):
            if a[i*3:i*3+3].count(x)==3 or a[i::3].count(x)==3:return x
    return 'd'

while 1:
    try:print(f(input()))
    except:break

Measured memory_bytes: 7384
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<map>

using namespace std;

int main() {
	unsigned long long int a, b, ans;
	cin >> a >> b;
	ans = b;
	for (int i = 1; i < a; i++) {
		ans *= (b - 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input()) + 2
A = [0] + list(map(int, input().split())) + [0]
C = [abs(A[i] - A[i + 1]) for i in range(N - 1)]
cost = sum(C)
for i in range(1, N - 1):
    print(cost - C[i] - C[i - 1] + abs(A[i + 1] - A[i - 1]))


Measured memory_bytes: 13920
use std::io;

fn main() {
    let n = read_one::<usize>();
    let an = read::<usize>();
    let _m = read_one::<usize>();
    let mi = read::<usize>();

    let mut sums = Vec::new();

    for b in 0..1 << n {
        let mut sum = 0;
        for j in 0..n {
            if b & (1 << j) != 0 {
                sum += an[j];
            }
        }
        sums.push(sum);
    }

    for m in mi.iter() {
        if sums.contains(m) { println!("yes"); }
        else { println!("no"); }
    }
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

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

int main(int argc, char **argv)
{
	ll n, d, a; cin >> n >> d >> a;
	vector<pair<ll, ll>> v(n);
	REP(i, n) cin >> v[i].first >> v[i].second;

	sort(ALL(v));
	ll res{0};
	ll tot{0};
	queue<pair<ll, ll>> q;

	REP(i, n)
	{
		ll x = v[i].first;
		ll h = v[i].second;

		while (q.size() && q.front().first < x)
		{
			tot -= q.front().second;
			q.pop();
		}

		h -= tot;
		if (h > 0)
		{
			ll cnt = (h+a-1)/a;
			res += cnt;
			ll dam = cnt * a;
			tot += dam;
			q.emplace(x+d*2, dam);
		}
	}

	std::cout << res << std::endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<atcoder/all>
#include<vector>
using namespace std;
typedef long long li;
#define yn(i) print((i)?"Yes":"No"),i
#define dist(a,b) max((a)-(b),(b)-(a))
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n;li d; cin >>n >>d;
  vector<vector<li>> x(n,vector<li>(2));
  atcoder::two_sat ts(n);
  rep(i,n){
    li a,b; cin >>a >>b;
    x[i]={a,b};
    rep(j,i) rep(ii,2) rep(jj,2){
      if(dist(x[i][ii],x[j][jj])<d)
        ts.add_clause(i,1-ii,j,1-jj);
    }
  }
  if(yn(ts.satisfiable())){
    vector<bool> ans=ts.answer();
    rep(i,n)print(x[i][ans[i]]);
  }
}


Measured memory_bytes: 3796
CHARACTER(20) S
INTEGER A,B
READ*,S
A=SCAN(S,"C")
B=SCAN(S,"C",.TRUE.)
IF (S(1:1)/="A".or.A<=2.or.A/=B.or.B==LEN_TRIM(S))THEN
  PRINT"(A)","WA"
  STOP
ENDIF
S(1:1)="a"
S(A:A)="c"
DO I=1,LEN_TRIM(S)
  IF(ICHAR(S(I:I))<ICHAR("a"))THEN
      PRINT"(A)","WA"
  STOP
  ENDIF
END DO
PRINT"(A)","AC"
END 

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}
int main(void){
  int a[5],i,j,b[5],tmp,ans=0;
  for(i=0;i<5;i++){
    scanf("%d",&a[i]);
    if(a[i]%10==0) b[i]=9;
    else b[i]=a[i]%10;
  }
  for(i=0;i<5-1;i++){
    for(j=i+1;j<5;j++){
      if(b[i]<b[j]){
        tmp=b[i];
        b[i]=b[j];
        b[j]=tmp;
        tmp=a[i];
        a[i]=a[j];
        a[j]=tmp;
      }
    }
  }
  //for(i=0;i<5;i++) printf("%d ",a[i]);
  for(i=0;i<5;i++){
    if(a[i]%10==0) ans+=a[i];
    else if(i==4) ans+=a[i];
    else ans+=a[i]+(10-(a[i]%10));
    //printf("%d ",ans);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

const int N=2e5+5;
int dp[N][2];
string s;

int32_t main()
{
    fast;
    cin>>s;
    int n=s.size();
    s='a'+s;
    dp[0][0]=dp[1][0]=0;
    dp[1][0]=1,dp[1][1]=0;
    for(int i=2;i<=n;i++)
    {
        if(s[i]==s[i-1])
        {
            dp[i][0]=1+dp[i-1][1];
            dp[i][1]=1+dp[i-2][0];
        }
        else
        {
            dp[i][0]=1+max(dp[i-1][0],dp[i-1][1]);
            dp[i][1]=1+dp[i-2][0];
        }
    }
    cout<<max(dp[n][0],dp[n][1]);
}

Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll solve(vector<ll> &a,vector<ll> &b,ll lev,ll pos){
    if(lev == 0){
        return 1;
    }
    if(pos == 1){
        return 0;
    }
    if(pos == a[lev]){
        return b[lev];
    }
    if(pos == a[lev-1]+2){
        return b[lev-1]+1;
    }
    if(pos < a[lev-1]+2){
        return solve(a,b,lev-1,pos-1);
    }
    if(pos > a[lev-1]+2){
        return b[lev-1] + 1 +  solve(a,b,lev-1,pos-a[lev-1]-2);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,x;
    cin >> n >> x;

    vector<ll> total(n+1,0);
    vector<ll> p(n+1,0);
    p[0] = 1;
    total[0] = 1;
    for(int i = 1; i <= n; i++){
        total[i] = total[i-1]*2+3;
        p[i] = p[i-1]*2+1;
    }

    cout << solve(total,p,n,x) << endl;

    
    return 0;
}

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

using namespace std;

constexpr int kSize = 200000;
int N = 0;
int Q = 0;
char ch[kSize];
int dir[kSize];

bool find(const string& s, int p, bool left, bool right) {
  for (int i = 0; i < Q; i++) {
    if (s[p] == ch[i]) {
      p += dir[i];
      if (N <= p) return right;
      if (p < 0) return left;
    }
  }
  return false;
}

int main() {
  string s;
  cin >> N >> Q >> s;
  for (int i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    ch[i] = t;
    dir[i] = d == 'L' ? -1 : 1;
  }

  int ans = N;
  int l = -1;
  int r = N;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (find(s, mid, true, false)) {
      l = mid;
    } else {
      r = mid;
    }
  }
  ans -= r;

  l = -1;
  r = N;
  while (r - l > 1) {
    const int mid = (l + r) / 2;
    if (find(s, mid, false, true)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  ans -= N - r;

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


Measured memory_bytes: 1540
#include <iostream>
#include <cstdio>
#define SIZE  100
using namespace std;

class P{
public:
  int p[SIZE];
  int x[SIZE];
};
  

int main()
{
  int tmp;
  cin >> tmp;
  const int n = tmp;
  int t[n];
  for(int i = 0; i < n; i++){
    cin >> t[i];
  }
  cin >> tmp;
  const int m = tmp;
  P ob[m];
  for(int i = 0; i < m; i++){
    cin >> ob[i].p[i] >> ob[i].x[i];
  }

  int total = 0;
  int tcp[n];

  for(int i = 0; i < m; i++){
     for(int i = 0; i < n; i++){
    tcp[i] = t[i];
  }
    int j = ob[i].p[i];
    int k = ob[i].x[i];
    tcp[j-1] = k;
    for(int f = 0; f < n; f++){ //total
      total += tcp[f];
    }
    cout << total <<endl;
    total = 0;
  }
  
 
  
    
    
  
}

Measured memory_bytes: 256
N = int(input())
F = [int("".join(input().split()), 2) for i in range(N)]
P = [list(map(int, (input().split()))) for i in range(N)]

ans = float("-inf")
for bit in range(1, 1024):
    sum_p = 0
    for shop in range(N):
        time = bin(F[shop] & bit).count("1")
        sum_p += P[shop][time]

    ans = max(ans, sum_p)

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
typedef int Int;
#define int long long
#define loop(i,n) for(int i =0; i < (n); i ++)
using namespace std;
Int main(){
	int n,m;
	cin>>n>>m;
	int num[n][3],maxv=-1;
	loop(i,n)loop(j,3)cin>>num[i][j];
	loop(bit,8){
		vector<int> v(n);
		loop(i,n)loop(j,3)v[i]+=(bit & (1<<j) ? -1 : 1) * num[i][j];
		sort(v.rbegin(),v.rend());
		maxv=max(maxv,accumulate(v.begin(),v.begin()+m,0LL));
	}
	cout<<maxv;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll k,x;
	cin>>k>>x;
	if (k*500>=x)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 256