akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a%m+b%m);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a%m-b%m);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
//	x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;


void solve()
{
	int n,k,cnt=0,i;
	cin>>n>>k;
	int a[n+1],b[n+1];
	a[0]=0;
	memset(b,0,sizeof(b));
	for(i=0;i<n;i++)
		cin>>a[i];
	while(cnt!=n && k>0)
	{
		cnt=0;
		for(i=0;i<n;i++)
		{
			int l=max(0ll,i-a[i]);
			int r=min(n,i+a[i]+1);
			b[l]++;
			b[r]--;
		}
		for(i=0;i<n;i++)
		{
			if(i)
				b[i]+=b[i-1];
			a[i]=b[i];
			if(a[i]==n)
				cnt++;
		}
		for(i=0;i<=n;i++)	b[i]=0;
		k--;
	}
	for(i=0;i<n;i++)
		cout<<a[i]<<" ";
	cout<<endl;
}

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

Measured memory_bytes: 6784
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<int,int>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int INF=1000000007;
using ll=long long;


int n;
string s,t;
void check(string *u){
	REP(i,1,n){
		if(s[i]=='o'){
			if(t[i]=='S'){
				if(t[i-1]=='S')t+="S";
				else t+="W";
			}else{
				if(t[i-1]=='S')t+="W";
				else t+="S";
			}
		}else{
			if(t[i]=='S'){
				if(t[i-1]=='S')t+="W";
				else t+="S";
			}else{
				if(t[i-1]=='S')t+="S";
				else t+="W";
			}
		}
	}
	if(s[0]=='o'){
		if(t[0]=='S'){
			if(t[n-1]=='S')t+="S";
			else t+="W";
		}else{
			if(t[n-1]=='S')t+="W";
			else t+="S";
		}
	}else{
		if(t[0]=='S'){
			if(t[n-1]=='S')t+="W";
			else t+="S";
		}else{
			if(t[n-1]=='S')t+="S";
			else t+="W";
		}
	}
}
int main(){
	cin>>n>>s;
	string dt="SSWW",ddt="SWSW";
	rep(j,4){
		t=(char)dt[j];
		t+=(char)ddt[j];
		check(&t);
		if(t[0]==t[n]&&t[1]==t[n+1]){
			rep(i,n)cout<<t[i];
			return 0;
		}
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <algorithm>
#include <numeric>
/*#include <stdlib.h>
#include <string>
#include <vector>
#include <iostream>
#include <forward_list>*/
using namespace std;

#define SCAN_INT(i) scanf("%lld", i)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define PRINT_INT(i) printf("%lld\n", i)
#define PRINT_TWO_INT(i, j) printf("%d %d\n", i, j)
#define PRINT_THREE_INT(i, j, k) printf("%d %d %d\n", i, j, k)

int main()
{
    long long int A, B;
    scanf("%lld %lld", &A, &B);

    long long int X2 = B * 10;
    for (int i = 0; i < 9; i++)
    {
        if (X2 * 0.08 < A)
            X2++;
        else
            break;
    }

    while ((X2 - 1) * 2 / 25 == A && (X2 - 1) / 10 == B)
        X2--;

    long long int A1 = X2 * 0.08;
    if (A1 != A)
        printf("-1");
    else
    {
        printf("%lld", X2);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
int a,b,c;
signed main()
{
	cin>>a>>b>>c;
	if(b-a<c*2){
		for(int i=a;i<b+1;i++){
			cout<<i<<endl;
		}
	}else{
		for(int i=a;i<a+c;i++){
			cout<<i<<endl;
		}
		for(int i=b-c+1;i<b+1;i++){
			cout<<i<<endl;
		}
	}
}

Measured memory_bytes: 256
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{
    class ProgramC
    {
        static void Main(string[] args)
        {

            //入力
            string s  = Console.ReadLine();
            int count1 = 0;
            int count2 = 0;

            for (int i = 0; i < s.Length; i++)
            {
                if (i % 2 == 0)
                {
                    if (s[i] == '0')
                        count1++;
                    else
                        count2++;
                }

                if (i % 2 == 1)
                {
                    if (s[i] == '1')
                        count1++;
                    else
                        count2++;
                }

            }

            Console.WriteLine(Math.Min(count1, count2));
            

        }

        
    }

    

}


Measured memory_bytes: 11232
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const u32 a = scan<u32>();
  const u32 b = scan<u32>();
  if (a <= 9 && b <= 9) {
    std::cout << a * b << std::endl;
  } else {
    std::cout << "-1" << std::endl;
  }
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int[] count = new int[S.length()];
    if (S.charAt(S.length() - 1) == 'W') {
      count[S.length() - 1] = 1;
    }
    for (int i = S.length() - 2; i >= 0; i--) {
      count[i] = count[i + 1];
      if (S.charAt(i) == 'W') {
        count[i]++;
      }
    }
    long ans = 0;
    for (int i = 0; i < S.length(); i++) {
      if (S.charAt(i) == 'B') {
        ans += count[i];
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 26680
let N = stdin.ReadLine() |> int
let H = stdin.ReadLine().Split() |> Array.map float

let rec resolver t r i =
    if i = N - 1 then r
    elif H.[i + 1] <= H.[i] then resolver (t + 1) (max r (t + 1)) (i + 1)
    else resolver 0 r (i + 1)

resolver 0 0 0 |> stdout.WriteLine


Measured memory_bytes: 24288
/**
    AUTHOR:JUNSH
    TIME:19/6/1
**/
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rev(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
const int mod=1e6+3;
ll fac[mod+10];
ll quick_pow(ll x,ll n){
    ll res=1;
    while(n){
        if(n&1){
            res=(res*x)%mod;
        }
        n=n>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inv(ll x){
    return quick_pow(x,mod-2);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll x,d,n;
    fac[0]=1;
    rep(i,1,mod){
        fac[i]=(fac[i-1]*i)%mod;
    }
    ll q;
    cin>>q;
    while(q--){
        cin>>x>>d>>n;
        if(!d){
            cout<<quick_pow(x,n)<<endl;
            continue;
        }
        x=x*inv(d)%mod;
        if(x+n-1>=mod){
            cout<<"0"<<endl;
            continue;
        }
        cout<<fac[x+n-1]*inv(fac[x-1])%mod*quick_pow(d,n)%mod<<endl;
    }

}


Measured memory_bytes: 8704
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var ans int
	for i := 1; i <= n; i += 2 {
		count := 0
		for j := 1; j <= n; j += 2 {
			if i%j == 0 {
				count++
			}
		}
		if count == 8 {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &slice[i])
	}
	sort.Sort(sort.IntSlice(slice))
	alice, bob := 0, 0

	for i := 0; i < n; i++ {
		if i%2 == 0 {
			alice += slice[n-i-1]
		} else {
			bob += slice[n-i-1]
		}
	}
	fmt.Println(alice - bob)

}


Measured memory_bytes: 1844
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;

#define N 3
#define N2 9
  
struct Puzzle{
int f[N2];
int space;
string path;
  
bool operator < (const Puzzle &p) const{
for(int i = 0; i < N2; i++){
if(f[i] == p.f[i]) continue;
return f[i] > p.f[i];
}
return false;
}
};
  
static const int dx[4] = {-1,0,1,0};
static const int dy[4] = {0,-1,0,1};
static const char dir[4] = {'u','l','d','r'};
  
bool isTarget(Puzzle p){
for(int i = 0; i < N2; i++)
if(p.f[i] != (i + 1)) return false;
return true;
}
  
string bfs(Puzzle s){
queue<Puzzle> Q;
map<Puzzle, bool> V;
Puzzle u, v;
s.path = "";
Q.push(s);
V[s] = true;
  
while(!Q.empty()){
u = Q.front(); Q.pop();
if(isTarget(u)) return u.path;
int sx = u.space / N;
int sy = u.space % N;
for(int r = 0; r < 4; r++){
int tx = sx + dx[r];
int ty = sy + dy[r];
if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
v = u;
swap(v.f[u.space], v.f[tx * N + ty]);
v.space = tx * N + ty;
if(!V[v]){
V[v] = true;
v.path += dir[r];
Q.push(v);
}
}
}
return "";
}
  
int main(){
Puzzle in;
for(int i = 0; i < N2; i++){
cin >> in.f[i];
if(in.f[i] == 0){
in.f[i] = N2;
in.space = i;
}
}
string ans = bfs(in);
cout << ans.size() << endl;
  
return 0;
}


Measured memory_bytes: 30544
using System;
using System.Linq;

class E
{
	static long[] Read() => Console.ReadLine().Split().Select(long.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		var af = Read().OrderBy(x => x).Zip(Read().OrderBy(x => -x), (x, y) => new { x, y }).ToArray();

		Console.WriteLine(First(0, af.Last().x * af[0].y, m => af.Sum(_ => Math.Max(0, _.x - m / _.y)) <= h[1]));
	}

	static long First(long l, long r, Func<long, bool> f)
	{
		long m;
		while (l < r) if (f(m = l + (r - l - 1) / 2)) r = m; else l = m + 1;
		return r;
	}
}


Measured memory_bytes: 47692
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int cal(int e,int f,int g) {
	int h;
	switch (g) {
		case 0: h=e+f; break;
		case 1: h=e-f; break;
		case 2: h=e*f; break;
	}
	return h;
}
int main() {
	int i,j,k,m,a,b,c,d,e,sk[4],da[4];
  char y[3]={'+','-','*'};
  while(true) {
	  cin >> sk[0] >> sk[1] >> sk[2] >> sk[3];
	  if (sk[0]==0 && sk[1]==0 && sk[2]==0 && sk[3]==0) break;
  for (i=0;i<4;i++)  for (j=0;j<4;j++) 
	  for (k=0;k<4 && j!=i;k++) for (m=0;m<4 && k!=i && k!=j;m++) {
				  if (m==i || m==j || m==k) continue;
				  da[0]=sk[i]; da[1]=sk[j]; da[2]=sk[k]; da[3]=sk[m];
				  for (a=0;a<3;a++) for (b=0;b<3;b++) 
					  for (c=0;c<3;c++) for (d=0;d<3;d++) {
						  switch (d) {
							  case 0: 
                               e=cal(da[0],da[1],a);
							   if (c==2) e=cal(e,cal(da[2],da[3],c),b); else e=cal(cal(e,da[2],b),da[3],c); 
                               if (e==10) printf("(%d%c%d)%c%d%c%d\n",da[0],y[a],da[1],y[b],da[2],y[c],da[3]);
							   break;
							  case 1:
							   if (b==2) e=cal(da[0],cal(da[1],da[2],b),a); else e=cal(cal(da[0],da[1],a),da[2],b);
							   e=cal(e,da[3],c);
                               if (e==10) printf("(%d%c%d%c%d)%c%d\n",da[0],y[a],da[1],y[b],da[2],y[c],da[3]);
							   break;
							  case 2:
                               e=cal(cal(da[0],da[1],a),cal(da[2],da[3],c),b);
                               if (e==10) printf("(%d%c%d)%c(%d%c%d)\n",da[0],y[a],da[1],y[b],da[2],y[c],da[3]);
                               break;                             
					  }
						  if (e==10) { a=b=c=d=i=j=k=m=10; break;}
	       		 }
	  }
	  if (a<6) cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)


int main() {
  	long double a,b,c;
  	cin>>a>>b>>c;
  	
  	if(a+b<c && 4*a*b<(c-a-b)*(c-a-b)) cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;
  
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x) make_pair(x)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
 
int main() {

    int n,m;
    cin>>n>>m;

    if(n==m)    cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;

 return 0;
}

Measured memory_bytes: 256
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define track  1;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j,cnt=0;
	bool flag=0;
	int a,b,c,k;
	cin>>a>>b>>c>>k;

	if(k<=a)
	{
		cnt = k;
	}
	else if(k<=a+b)
	{
		cnt=a;
	}
	else if(k<=a+b+c)
	{
		cnt = a - (k-(a+b));
	}
	else
	{
		cnt = (a-c);
	}

	cout<<cnt<<endl;



	

}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <cstdio>
#define EPS 1e-5
using namespace std;

int main(){
    double q;
    while(true){
        cin >> q; if(q == -1) break;
        double x = q/2;
        while(true){
            if(fabs(x*x*x-q) < EPS*q) break;
            x -= (x*x*x-q)/(x*x*3);
        }
        printf("%f\n",x);
    }
}

Measured memory_bytes: 1228
from sys import stdin, setrecursionlimit
import math


def main():
    input = stdin.buffer.readline
    a, b, x = map(int, input().split())
    v = (a ** 2) * b

    if 0.5 * v > x:
        h = x * 2 / (a * b)
        ans = b / h
    else:
        diff = v - x
        h = (diff * 2 / (a ** 2))
        ans = h / a
    print(math.degrees(math.atan(ans)))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38384
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        xyvv: [[(Usize1, usize)]]
    };

    let n = xyvv.len();
    let mut res = 0;
    for bits in 0..(1 << n) {
        let mut honest_set = HashSet::new();
        let mut unkindness_set = HashSet::new();
        for i in 0..n {
            let is_honest = (bits >> i) & 1 == 1;
            if is_honest {
                honest_set.insert(i);
            } else {
                unkindness_set.insert(i);
            };
            for &(x, y) in &xyvv[i] {
                if is_honest {
                    if y == 0 {
                        unkindness_set.insert(x);
                    } else {
                        honest_set.insert(x);
                    }
                }
            }
        }
        let is_ok = honest_set.intersection(&unkindness_set).count() == 0;
        if is_ok && honest_set.len() > res {
            res = honest_set.len();
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2248
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int N;
    std::string S;
    std::cin>>N>>S;

    int k = 0;
    for(int i = 1;i < N;i++){
        int cnt = 0;
        for(char c = 'a';c <= 'z';c++){
            bool x = false;
            bool y = false;

            for(int j = 0;j < i;j++){
                if(S[j] == c){
                    x = true;
                }
            }
            for(int j = i;j < N;j++){
                if(S[j] == c){
                    y = true;
                }
            }
            if(x && y){
                cnt++;
            }
        }
        if(k < cnt){
            k = cnt;
        }
    }
    std::cout<<k<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#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 ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s,t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

sumA = sum(As)

for i, B in enumerate(Bs):
    d = min(As[i], B)
    As[i] -= d
    B -= d
    d = min(As[i+1], B)
    As[i+1] -= d
    B -= d

print(sumA - sum(As))


Measured memory_bytes: 82148
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 1000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

int ans,ans2;
int n,h,a[111111],b[111111];
signed main(){

	cin>>n>>h;
	//vector<P> v;

	rep(i,n){
		cin>>a[i]>>b[i];
	}
	int max=0,max2;
	rep(i,n){
		if(max<a[i]){
			max=a[i];
			max2=b[i];
		}
	}
	vector<int> v;
	sort(b,b+n,greater<int>());
	rep(i,n){
		if(max>b[i])continue;
		h-=b[i];ans++;
		if(h<=0){
			cout<<ans<<endl;
			return 0;
		}
	}
	ans+=h/max;
	if(h%max!=0)ans++;
	cout<<ans<<endl;;

	
}


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

void bfs(vector<vector<ll>> &friends,vector<bool> &checked,queue<ll> &q,ll &K){
  ll i;
  for(i=0;i<friends.at(K).size();i++){
    if(!checked.at(friends.at(K).at(i))){
      q.push(friends.at(K).at(i));
    }
  }
}

int main(void){
  ll n,m,k;
  cin >> n >> m >> k;
  vector<ll> a(m),b(m);
  vector<vector<ll>> friends(n,vector<ll>(0));
  ll i;
  for(i=0;i<m;i++){
    cin >> a.at(i) >> b.at(i);
    a.at(i)--;
    b.at(i)--;
    friends.at(a.at(i)).push_back(b.at(i));
    friends.at(b.at(i)).push_back(a.at(i));
  }
  
  vector<ll> group(n);
  vector<bool> checked(n,false);
  queue<ll> q;
  for(i=0;i<n;i++){
    if(!checked.at(i)){
      q.push(i);
      while(!q.empty()){
        group.at(q.front())=i;
        bfs(friends,checked,q,q.front());
        checked.at(q.front())=true;
        q.pop();
      }
    }
  }
  
  vector<ll> count(n,0),member(n,0);
  for(i=0;i<n;i++){
    count.at(group.at(i))++;
  }
  for(i=0;i<n;i++){
    member.at(i)=count.at(group.at(i))-1-friends.at(i).size();
  }
  
  ll c,d;
  for(i=0;i<k;i++){
    cin >> c >> d;
    c--;
    d--;
    if(group.at(c)==group.at(d)){
      member.at(c)--;
      member.at(d)--;
    }
  }
  
  cout << member.at(0);
  for(i=1;i<n;i++){
    cout << " " << member.at(i);
  }
}

Measured memory_bytes: 14268
n, m = map(int, input().split())
ab_list = [0] * m
for i in range(m):
	ab_list[i] = list(map(int, input().split()))
a_list = []
b_list = []
for i in ab_list:
	if i[0] == 1:
		a_list.append(i[1])
	elif i[1] == n:
		b_list.append(i[0])
r = 'POSSIBLE' if set(a_list) & set(b_list) else 'IMPOSSIBLE'
print(r)

Measured memory_bytes: 94544
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define LLINF (1LL<<60)
#define INF (1<<30)
#define F first
#define S second
int main(void){
    long long n,t;
    long long a[100005];
    long long uru[100005]={0};
    cin>>n>>t;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    long long maxs=a[n-1];
    for(int i=n-1;i>=0;i--){
        uru[i]=maxs-a[i];
        maxs=max(a[i],maxs);
    }
    sort(uru,uru+n,greater<long long>());
    long long ans=1;
    for(int i=1;i<n;i++){
        if(uru[0]==uru[i]) ans++;
        else break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto A = RD;
	auto B = RD;

	writeln(A * B % 2 == 0 ? "Even" : "Odd");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_a
// https://atcoder.jp/contests/dp/tasks/dp_b
// https://atcoder.jp/contests/dp/tasks/dp_z
#include <bits/stdc++.h>
#define int             long long
#define ld              long double
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(int i=1;i<=n;i++)
#define fok(i,k,n)      for(int i=k;i<=n;i++)
#define rfo(i,n)        for(int i=n;i>=0;i--)
#define rfo1(i,n)       for(int i=n;i>0;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcount(x)
#define zerobits(x)     __builtin_ctz(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define endl            '\n'
#define mod             1000000007
#define M               (int)1e6+6
#define inf             1e18
using namespace std;

int n,m,k,x,y,z,a1,b,c,d,i,j,l,r;


void frog1(vi h)
{ int dp[n+1]={};
  dp[2]=abs(h[2]-h[1]);

  fok(i,3,n)dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  
  cout<<dp[n]<<endl;
}




void frog2(vi h,int k)
{
    int dp[n+1]={};
    dp[2]=abs(h[2]-h[1]);
    fok(i,3,n)
    {   dp[i]=inf;
        fo1(j,k)
        {   
            if(i-j>=1)
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n]<<endl;
}

void sol()
{   
    cin>>n; 
    //for frog2
    cin>>k;
    in1(h,n);
    // frog1(h);
    
    frog2(h,k);
    
    
    // cout<<  <<endl;
}





int32_t main(){

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // w(t)
    sol();
    return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll r;
  R r;
  pr(r*r*3);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int lcm(int a, int b){
  return a / gcd(a,b) * b;
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};
// 区間加算にも対応した BIT
template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

struct data{int f,t,id;};
bool cmp(data a,data b){
  if(a.t != b.t) return a.t < b.t;
  else return a.id < b.id;
}
int main(){
  int n,m,q; cin >> n >> m >> q;
  vector<data> v(m+q);
  vector<int> c;
  rep(i,m+q){
    cin >> v[i].f >> v[i].t;
    v[i].t++;
    if(i<m) v[i].id = -1;
    else v[i].id = i-m;
    c.push_back(v[i].f);c.push_back(v[i].t);
  }
  sort(v.begin(),v.end(),cmp);
  sort(c.begin(),c.end());
  c.erase(unique(c.begin(),c.end()),c.end());
  
  rep(i,m+q){
    int l = lower_bound(c.begin(),c.end(),v[i].f) - c.begin();
    int r = lower_bound(c.begin(),c.end(),v[i].t) - c.begin();
    v[i].f = l+1;
    v[i].t = r+1;
  }
  
  BIT<int> b((m+q)*2+5);
  vector<int> ans(q);
  rep(i,m+q){
    if(v[i].id == -1) b.add(v[i].f,v[i].f+1,1);
    else ans[v[i].id] = b.sum(v[i].f,v[i].t);
  }
  
  rep(i,q) cout << ans[i] << endl;
  
  return 0;
}

Measured memory_bytes: 13420
import java.util.*

fun main(args:Array<String>) {
    val (n,k) = readLine()!!.split(" ").map { it.toLong() }
    val cnt = TreeMap<Int,Long>()
    (1..n.toInt()).forEach {
        val (a,b) = readLine()!!.split(" ").map { it.toInt() }
        val tmp = (cnt[a]?:0L) + b
        cnt[a] = tmp
    }
    var cur = 0L
    for(key in cnt.keys) {
        cur += cnt[key]!!
        if(cur >= k) {
            println(key)
            return
        }
    }

}



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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int x, y; cin >> x >> y;
    cout << __gcd(x, y) << endl;
}


Measured memory_bytes: 3184
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <numeric>
using namespace std;
#define MAX_N 400

// Input
int N, K;
char S[MAX_N];

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    S[K-1] += 32;
    cout << S;
}

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

int main(){
    long long int h, w;
    cin >> h >> w;

    long long int ans = h * w;

    for(long long int i=1;i<=w/2;++i){
        long long int smax = i * h, smin = i * h;
        long long int s1 = (w-i) * (h/2);
        long long int s2 = (w-i) * ((h+1)/2);
        smax = max(smax, max(s1, s2));
        smin = min(smin, min(s1, s2));
        ans = min(ans, smax-smin);

        smax = i * h, smin = i * h;
        s1 = h * ((w-i)/2);
        s2 = h * ((w-i+1)/2);
        smax = max(smax, max(s1, s2));
        smin = min(smin, min(s1, s2));
        ans = min(ans, smax-smin);
    }
    for(long long int i=1;i<=h/2;++i){
        long long int smax = i * w, smin = i * w;
        long long int s1 = (h-i) * (w/2);
        long long int s2 = (h-i) * ((w+1)/2);
        smax = max(smax, max(s1, s2));
        smin = min(smin, min(s1, s2));
        ans = min(ans, smax-smin);

        smax = i * w, smin = i * w;
        s1 = w * ((h-i)/2);
        s2 = w * ((h-i+1)/2);
        smax = max(smax, max(s1, s2));
        smin = min(smin, min(s1, s2));
        ans = min(ans, smax-smin);
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
	int a=1,N,K;
	cin>>N>>K;
  	int count=N;
  	a=2;--count;
  	while(count!=0){
    	if(a<K)a*=2;
      	else a+=K;
      	--count;
    }
  	cout<<a<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
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; }

void _main() {
  int N, M, K;
  cin >> N >> M >> K;

  bool f = false;
  rep(i, 0, N+1) rep(j, 0, M+1) {
    if (K == i*(M-j) + j*(N-i)) f = true;
  }

  if (f) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a[200000];
	int i,j,flg=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	for(i=0;i<n-1;i++){
		if(a[i]==a[i+1]){
			flg=1;
		}
	}
	if(flg==1){
		printf("NO\n");
	}
	else{
		printf("YES\n");
	}
	return 0;
}

Measured memory_bytes: 2416
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
#define OUT(x) for(auto a:x) cout << a << " "; cout << endl;
#define OK cout << "ok" <<endl;

using namespace std;

int main()
{
	fast_cin
	int n;
	cin >> n;
	vi v(n+2),dp(n+2);
	for(int i=1;i<=n;i++) cin >> v[i];
	for(int i=2;i<=n;i++){
		if(v[i]<=v[i-1]){
			dp[i]=max(dp[i-1]+1,dp[i]);
		}
		else dp[i]=0;
	}

	cout << *max_element(all(dp))<<endl;

}


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

using namespace std;
typedef long long i64;


bool ok(int idx, vector<int>& balls)
{
	const int n = balls.size();
	i64 size = 0;

	for(int i = 0; i <= idx; ++i)
		size += balls[i];

	for(int i = idx + 1; i < n; ++i) {
		if(size * 2 < balls[i])
			return false;
		size += balls[i];
	}

	return true;
}

int main()
{
	int n;
	vector<int> as;

	scanf("%d", &n);
	as.resize(n);
	for(int i = 0; i < n; ++i)
		scanf("%d", &as[i]);

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

	int lb = 0;
	int ub = n;

	if(ok(lb, as)) {
		printf("%d\n", n);
		return 0;
	}

	while(ub - lb > 1) {

		int mid = (ub + lb) / 2;

		if(ok(mid, as))
			ub = mid;
		else
			lb = mid;
	}

	int ans = n - 1 - lb;

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  string S; cin >> S;
  int ai = S.size();
  int zi = -1;
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == 'A')
      chmin(ai, i);
    else if (S[i] == 'Z')
      chmax(zi, i);
  }
  auto ans = zi - ai + 1;
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  string s; cin>>s;
  s.pop_back(); s.pop_back();
  while (1) {
    int n = s.length();
    if (s.substr(0,n/2) == s.substr(n/2)) out(n);
    s.pop_back(); s.pop_back();
  }
  assert(0);
  

  return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int N;
pii P[100010];

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	int X, L;
	rep(i, 0, N)
	{
		cin >> X >> L;
		//L--;
		P[i].second = X - L;
		P[i].first = X + L;
	}

	sort(P, P + N);

	int r = -INF;
	int ans = 0;
	rep(i, 0, N)
	{
		if (r <= P[i].second)
		{
			ans++;
			r = P[i].first;
		}
	}

	cout << ans << endl;

	return 0;
}

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

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

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

Measured memory_bytes: 256
package main

import "fmt"

func main() {
    var n, m int
    var a [100][100]int
    var b [100]int
    var ans int

    // 行列フォーマット読み込み
    // n行 m列
    fmt.Scanf("%d %d", &n, &m)

    // 行列a読み込み
    for i:=0; i<n; i++ {
        for j:=0; j<m; j++ {
            fmt.Scanf("%d", &a[i][j])
        }
    }

    // 行列b読み込み
    for i:=0; i<m; i++ {
        fmt.Scanf("%d", &b[i])
    }

    // fmt.Println(a)
    // fmt.Println(b)

    // 掛け算
    for i:=0; i<n; i++ {
        ans = 0
        for j:=0; j<m; j++ {
            ans += a[i][j] * b[j]
        }
        fmt.Println(ans)
    }
}


Measured memory_bytes: 1708
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		char[] S = sc.next().toCharArray();
		int count = A + B;
		int count_b = B;

		int i = 0;
		for (; i< S.length; i++) {
			if(S[i] == 'a'){
				count--;
				System.out.println("Yes");
			} else if(S[i] == 'b'){
				if(count_b != 0) {
					count--;
					count_b--;
					System.out.println("Yes");
				}else{
					System.out.println("No");
				}
			} else {
				System.out.println("No");
			}

			if (count==0)break;

		}
		i++;
		for ( ;i< S.length; i++) {
			System.out.println("No");
		}

		sc.close();
	}

}


Measured memory_bytes: 23928
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <cstring>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;
const int MOD = 100000;

ll dp[50][3001];

int main(){
	int n, m, s;
	while(cin >> n >> m >> s, n|m|s){
		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1;
		for(int i = 1; i <= m; i++){
			for(int j = n*n; j >= 1; j--){
				for(int k = i; k <= s; k++){
					dp[j][k] += dp[j-1][k-i];
					dp[j][k] %= MOD;
				}
			}
		}
		cout << dp[n*n][s] << endl;
	}

    return 0;
}

Measured memory_bytes: 2336
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  string s;
  cin >> n >> s;
  ll c[3][n];
  mem(c);
  rep(i,n) {
    if(i) {
      rep(j,3) c[j][i]+=c[j][i-1];
    }
    if(s[i]=='R') c[0][i]++;
    if(s[i]=='B') c[1][i]++;
    if(s[i]=='G') c[2][i]++;
  }
  ll ans=0;
  REP(i,1,n-1) {
    if(s[i]=='R') {
      ans+=c[1][i-1]*(c[2][n-1]-c[2][i]);
      ans+=c[2][i-1]*(c[1][n-1]-c[1][i]);
    } else if(s[i]=='B') {
      ans+=c[0][i-1]*(c[2][n-1]-c[2][i]);
      ans+=c[2][i-1]*(c[0][n-1]-c[0][i]);
    } else {
      ans+=c[1][i-1]*(c[0][n-1]-c[0][i]);
      ans+=c[0][i-1]*(c[1][n-1]-c[1][i]);
    }
  }
  REP(i,1,n-1) {
    for(ll j=1; j<=n; j++) {
      if(i-j>=0&&j+i<n) {
        if(s[i]!=s[i-j]&&s[i]!=s[i+j]&&s[i-j]!=s[j+i]) ans--;
      } else break;
    }
  }
  pr(ans);
}

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


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);

int main(){ 
  ll n;
  cin >> n;
  ll res = INF;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) res = min(res, (i - 1) + (n/i-1));
  }
  cout << res << endl;
  return 0;
} 

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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

using namespace std;
using ll = long long;
using P = pair<int, int>;


void Main() {
  int n;
  cin >> n;
  vector<int> U(n), V(n);
  {
    vector<int> X(n), Y(n);
    rep(i, n) cin >> X[i] >> Y[i];
    rep(i, n) {
      U[i] = X[i] + Y[i];
      V[i] = X[i] - Y[i];
    }
  }
  rep(i, n-1) if(abs(U[i])%2 != abs(U[i+1])%2) {
    cout << -1 << endl;
    return;
  }
  int m = 1;
  {
    int mx = 0;
    rep(i, n) mx = max(mx, max((U[i]), abs(V[i])));
    while(mx+1>(1LL<<m)) {m++;}
  }
  vector<int> d(m, 1);
  rep(i, m-1) d[m-i-2] = d[m-i-1]*2;
  if (U[0] % 2 == 0) {
    d.push_back(1);
    m++;
  }
  cout << m << endl;
  rep(i, m) cout << d[i] << " ";
  cout << endl;
  rep(i, n) {
    vector<int> LRDU(m, 0);
    rep(j, m) {
      int mode = 0;
      if (U[i] < 0) {U[i] += d[j]; mode += 1;}
      else {U[i] -= d[j]; mode -= 1;}
      if (V[i] < 0) {V[i] += d[j]; mode += 2;}
      else {V[i] -= d[j]; mode -= 2;}
      if (mode==3) cout << "L";
      if (mode==-3) cout << "R";
      if (mode==-1) cout << "D";
      if (mode==1) cout << "U";
    }
    cout << endl;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [0]*4
for i in range(n):
    x = input()
    if x == "AC":
        s[0] += 1
    elif x == "WA":
        s[1] += 1
    elif x == "TLE":
        s[2] += 1

    else:
        s[3] += 1

print("AC x {}".format(s[0]))
print("WA x {}".format(s[1]))
print("TLE x {}".format(s[2]))
print("RE x {}".format(s[3]))


Measured memory_bytes: 9200