akhauriyash/Code-Regression huggingface dataset:
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
        q: usize,
        bc: [(usize, usize); q],
    }

    let mut counter = vec![0 as i64; 100001];
    let mut sum: i64 = 0;

    for num in a {
        counter[num] += 1;
        sum += num as i64;
    }

    for (b, c) in bc {
        let diff = counter[b];
        counter[c] += diff;
        counter[b] = 0;
        sum = sum + (c as i64 - b as i64) * diff;

        println!("{}", sum);
    }
}

Measured memory_bytes: 6772
use std::cmp::max;
use std::error::Error;
use std::io;

fn main() {
    if let Err(e) = run() {
        panic!("failed.");
    }
}

struct Bit {
    elements: Vec<i64>,
}

impl Bit {
    fn update(&mut self, index: usize, value: i64) {
        let mut index = index + 1;
        while index < self.elements.len() {
            self.elements[index] = max(self.elements[index], value);
            index += (index as i64 & -(index as i64)) as usize;
        }
    }

    fn find_max(&self, index: usize) -> i64 {
        let mut index = 1 + index as i64;
        let mut result = 0;
        while index > 0 {
            result = max(result, self.elements[index as usize]);
            index -= index & -index;
        }
        result
    }
}

fn run() -> Result<(), Box< Error>> {
    let mut input = String::new();
    io::stdin().read_line(&mut input);
    let n = input.trim().parse::<i32>().unwrap();
    input.clear();
    io::stdin().read_line(&mut input);
    let hs: Vec<i64> = input
        .trim()
        .split_whitespace()
        .map(|s| s.parse::<i64>().unwrap())
        .collect();
    input.clear();
    io::stdin().read_line(&mut input);
    let vs: Vec<i64> = input
        .trim()
        .split_whitespace()
        .map(|s| s.parse::<i64>().unwrap())
        .collect();
    input.clear();
    // (h, v)
    let mut pairs = vec![];
    for i in 0..n as usize {
        pairs.push((hs[i], vs[i]));
    }
    pairs.sort_by_key(|&(h, _)| h);

    let mut bit = Bit {
        elements: vec![0; 1 + n as usize],
    };
    let mut result = 0;
    for i in 0..n as usize {
        let target_index = pairs.binary_search_by_key(&hs[i], |&(h, _)| h).unwrap();
        let mut new_max = pairs[target_index].1;
        if target_index != 0 {
            new_max += bit.find_max(target_index - 1);
        }
        bit.update(target_index, new_max);
        result = max(result, bit.find_max(target_index));
    }
    println!("{:?}", result);
    Ok(())
}


Measured memory_bytes: 18664
/* be name khoda */

// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <fstream>
#include <set>
#include <map>
using namespace std;

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl

const ll INF = 2000000000;
const long long BIG = 1446803456761533460LL;

#define XL (x << 1)
#define XR (XL | 1)
#define MD ((l + r) >> 1)
#define Add(a, b) a = ((a) + (b)) % M
#define Mul(a, b) a = (1LL * (a) * (b)) % M

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

const ll maxn = 2010;

ll n, M;
ll dp[maxn * 3][maxn];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> M;
    dp[0][0] = 1;
    fori (i, n * 3) {
        fori (j, n + 1) {
            Add(dp[i + 1][j], dp[i][j]);
            Add(dp[i + 2][j + 1], 1LL * dp[i][j] * (n * 3 - i - 1) % M);
            Add(dp[i + 3][j + 1], 1LL * dp[i][j] * (n * 3 - i - 1) * (n * 3 - i - 2) % M);
        }
    }
    ll ans = 0;
    fori (i, n + 1) Add(ans, dp[n * 3][i]);
    cout << ans << '\n';

}


Measured memory_bytes: 50740
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>

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

using namespace std;

bool isP(int p)
{
    if (p <= 1)
        return false;
    int sq = int(sqrt(p));
    FOR(i, 2, sq+1)
    {
        if (p % i == 0)
            return false;
    }
    return true;
}

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

    int c = 0;
    REP(i, N)
    {
        int a;
        cin >> a;
        if(isP(a)) c++;
    }

    cout << c << endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll A,B,C,K;
  cin>>A>>B>>C>>K;
  if(A+B>=K){
    cout<<min(A,K)<<endl;
  }else{
    cout<<A-(K-(A+B))<<endl;
  }
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)

const int INF = 100000000;

using namespace std;

void p(int x) {
	cout << x << endl;
}

int main() {
	int x;
	int x5 = 0, x7 = 0;
	rep(i, 0, 3) {
		cin >> x;
		if (x == 5)x5++;
		if (x == 7)x7++;

	}

	if (x5 == 2 && x7)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // スペース区切りの整数の入力
    int a;
    cin >> a;
    // 出力
  	int aa=0;
    
    while(a>0){
        if(a%10==1)aa++;
        a/=10;
    }
    cout << aa << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    K = II()
    A, B = MI()

    for i in range(A, B+1):
        if i % K == 0:
            print('OK')
            return
    print('NG')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9092
X, N = list(map(int, input().split()))

P = list(map(int, input().split()))
if (N == 0):
    print(X)
    exit(0)

i = 0
while (True):
    if (X - i not in P):
        print(X - i)
        break
    elif (X + i not in P):
        print(X + i)
        break
    i += 1


Measured memory_bytes: 9184
package main

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

var sc = bufio.NewScanner(os.Stdin)
var dp [101][100010]int

func main() {
	scanInit()

	n := nextInt()
	k := nextInt()
	w := make([]int, n)
	v := make([]int, n)
	for i := 0; i < n; i++ {
		w[i] = nextInt()
		v[i] = nextInt()
	}

	for i := 0; i < n; i++ {
		for j := 0; j <= k; j++ {
			if j >= w[i] {
				dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j])
			} else {
				dp[i+1][j] = dp[i][j]
			}
		}
	}

	fmt.Println(dp[n][k])
	//fmt.Println(dp)

}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 79936
n,l = map(int,input().split())
if l >= 0:
  print(((n-1)*(2*l+n))//2)
elif l+n-1 >= 0:
  print((n*(2*l+n-1))//2)
else:
  print(((n-1)*(2*l+n-2))//2)

Measured memory_bytes: 3064
// https://atcoder.jp/contests/arc083/tasks/arc083_b

package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)

	var A = make([][]int, N)

	sum := 0
	for i := 0; i < N; i++ {
		A[i] = make([]int, N)
		for j := 0; j < N; j++ {
			var a int
			fmt.Scan(&a)
			A[i][j] = a
			sum += a
		}
	}

	dupes := 0
	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			if i == k || A[i][k] == 0 {
				continue
			}
			for j := i + 1; j < N; j++ {
				if k == j || A[k][j] == 0 {
					continue
				}
				if A[i][j] > A[i][k]+A[k][j] {
					fmt.Println(-1)
					return
				} else if A[i][j] == A[i][k]+A[k][j] {
					dupes += A[i][j]
					A[i][j] = 0
					A[j][i] = 0
				}
			}
		}
	}

	fmt.Println((sum/2 - dupes))
}


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

ll dfs_num[100001],dfs_low[100001],rev[100001],timer=0;

ll n,dist[100001],good=1,trace[100001],inf=1e16;
bool visited[100001];


void solve(vector<pair<ll,ll>> v[])
{
    queue<ll> q;
    q.push(1);
    dist[1]=0;
    for(auto a:v[1]) dist[a.first]=a.second;
    visited[1]=1; 
    ll tot=n-1;
    while(q.size() && tot)
    {
        ll idx=q.front(); q.pop();
        // cout<<idx<<" ";
        ll found=0,mindist=inf;
        for(auto a:v[idx])
        {
            if(dist[a.first]<mindist && !visited[a.first])
            {
                mindist=dist[a.first]; found=a.first;
            }
        }
        if(found)
        {
        for(auto a:v[found])
        {
            if(dist[a.first]>dist[found]+a.second)
                dist[a.first]=dist[found]+a.second;
        }
        visited[found]=1;
        q.push(found);
        tot--;
        }
    }
    for(int i=1;i<=n;i++) cout<<dist[i]<<" ";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--)
    {
        double d,t,s; cin>>d>>t>>s;
        double ti=d/s;
        if(ti<=t) cout<<"Yes";
        else cout<<"No";
    }
}

Measured memory_bytes: 3784
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

void solve() {
	int k; cin >> k;
	if (k % 2 == 0 || k % 5 == 0) {
		cout << -1 << "\n"; return;
	}
	vector<bool> used(k, false);
	int s = 0;
	int ans = 0;
	while (true) {
		ans++;
		s = 10 * s + 7; s %= k;
		if (used[s]) {
			cout << -1 << "\n"; return;
		}
		used[s] = true;
		if (s == 0) {
			cout << ans << "\n"; return;
		}
	}
}




signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f();
	//cout << grandy(2, 3, false, false) << "\n";
	//int t; cin >> t; rep(i, t)
		solve();
	return 0;
}


Measured memory_bytes: 7832
import numpy as np
from scipy.optimize import fmin

n,k=map(int,input().split())
XYC=[list(map(int,input().split())) for i in range(n)]
X,Y,C=[],[],[]
for x,y,c in XYC:
    X.append(x)
    Y.append(y)
    C.append(c)
X=np.array(X,dtype=np.float)
Y=np.array(Y,dtype=np.float)
C=np.array(C,dtype=np.float)
def f(xy):
    x,y=xy
    times=(X-x)*(X-x)+(Y-y)*(Y-y)
    times=C*np.sqrt(times)
    times=np.sort(times)
    return times[k-1]
deff=0.5
ansx=[fmin(f,(x,y),disp=False,ftol=10**(-7),initial_simplex=[(x+deff,y),(x-deff,y+deff),(x-deff,y-deff)]) for x,y,c in XYC]
ansy=list(map(lambda x:f(x),ansx))
print(min(ansy))


Measured memory_bytes: 49852
#include<iostream>
using namespace std;
int main()
{
  int d;
  cin>>d;
  
    if(d==22)
    {
      cout<<"Christmas Eve Eve Eve";
    }else if(d==23)
    {
      cout<<"Christmas Eve Eve";
    }else if(d==24)
    {
      cout<<"Christmas Eve";
    }else if(d==25)
    {
      cout<<"Christmas";
    }
  
  return 0;
  
}


Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;

const ll INF = pow(10,18)+1;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}
 
int main(){
    string S;
    cin >> S;
    if(stoi(S.substr(0,4))<=2019&&stoi(S.substr(5,2))<=4&&stoi(S.substr(8,2))<=30) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
s = n.times.map{gets.chomp}
h = Hash.new(0)
max=0
s.each do |string|
  h[string] += 1
  max = h[string] if max<h[string]
end

#puts h.select { |k,v| v==max }.keys.sort
ans = []
h.each do |k,v|
  if v==max
    ans << k
  end
end
#puts ans
puts ans.sort

Measured memory_bytes: 39784
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll dp[43][300005];
int d[300005];

ll modpow(ll x, ll n){
    ll res = 1, r = x;
    while(n){
        if(n & 1) res = res * r % MOD;
        r = r * r % MOD;
        n >>= 1;
    }
    return res;
}

int main()
{
    int n, x, y, z;
    cin >> n >> x >> y >> z;
    y += x;
    z += y;
    d[0] = 0;
    for(int i = 0; i < z - 1; i++){
        for(int j = (1 << i); j < (1 << (i + 1)); j++) d[j] = i + 1;
    }
    dp[0][0] = 1;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < (1 << z); j++){
            int m = j;
            for(int k = 1; k <= 10; k++){
                if(k >= z){
                    dp[i + 1][0] = (dp[i + 1][0] + dp[i][j]) % MOD;
                    continue;
                }
                bool f = false;
                if(d[m] + k == z){
                    if((m >> (x - 1)) & (m >> (y - 1)) & 1){
                        ans = (ans + dp[i][j] * modpow(10, n - (i + 1)) % MOD) % MOD;
                        f = true;
                    }
                    while((m & 1) == 0 && m != 0) m >>= 1;
                    m >>= 1;
                    if(f) continue;
                }
                dp[i + 1][m + (1 << (k - 1 + d[m]))] = (dp[i + 1][m + (1 << (k - 1 + d[m]))] + dp[i][j]) % MOD;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 94720
dp = [0] * 100005

S = raw_input()

dp[0] = 1

for i in range(len(S)):
    if dp[i] == 0:
        continue
    if i + 5 <= len(S) and S[i:i+5] == "dream":
        dp[i + 5] = 1
    if i + 7 <= len(S) and S[i:i+7] == "dreamer":
        dp[i + 7] = 1
    if i + 5 <= len(S) and S[i:i+5] == "erase":
        dp[i + 5] = 1
    if i + 6 <= len(S) and S[i:i+6] == "eraser":
        dp[i + 6] = 1

print "YES" if (dp[len(S)] == 1) else "NO"


Measured memory_bytes: 6660
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>

typedef long vertex;
typedef long dist;

using namespace std;

vector<bool> data_exists;
vector<long> xs;

long n;
long m;

vector<vertex> ls;
vector<vertex> rs;
vector<dist> ds;

map<vertex, vector<pair<vertex,dist>>> adj_map;

bool dfs(vertex v) {
    for (auto&& pair : adj_map[v]) {
        vertex w = pair.first;
        dist d = pair.second;
        if (data_exists[w]) {
            if (xs[w] != xs[v] + d) return false;
        } else {
            data_exists[w] = true;
            xs[w] = xs[v] + d;
            if (!dfs(w)) return false;
        }
    }
    return true;
}

bool solve() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n >> m;
    data_exists.resize((unsigned long)n, false);
    xs.resize((unsigned long)n);

    for (int i = 0; i < m; i++) {
        vertex l, r;
        dist d;
        cin >> l >> r >> d;
        l--;
        r--;
        adj_map[l].emplace_back(make_pair(r, d));
        adj_map[r].emplace_back(make_pair(l, -d));
    }

    for (vertex v = 0; v < n; v++) {
        if (!data_exists[v]) {
            xs[v] = 0;
            if (!dfs(v)) return false;
        }
    }
    return true;
}

int main() {
    cout << (solve() ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 24320
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = Long.parseLong(sc.next());
        long count = 0;
        long i = 1;
        while(count < x) {
            count += i;
            if(count >= x) break;
            i++;
        }
        System.out.println(i);
    }   
}

Measured memory_bytes: 22740
void main() {
	auto ip = readAs!(long[]), N = ip[0], A = ip[1], B = ip[2], C = ip[3], D = ip[4];
	
	foreach(i; 0..N) {
		auto m = A + C*i - D*(N-i-1), M = A+D*i - C*(N-i-1);
		if(m <= B && B <= M) {
			writeln("YES");
			return;
		}
	}
	writeln("NO");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#pragma region
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define rep(i, a, n) for (long long i = a; i <= n; ++i)
#define per(i, a, n) for (long long i = n; i >= a; --i)
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
template <typename T>
void read(T &x) {
    x = 0;
    char ch = getchar();
    ll f = 1;
    while (!isdigit(ch)) {
        if (ch == '-') f *= -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - 48;
        ch = getchar();
    }
    x *= f;
}
using namespace std;
/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */

#pragma endregion
const int maxn = 3e3 + 5;
int n;
double p[maxn], dp[maxn][maxn];
int main() {
    IO;
    cin >> n;
    rep(i, 1, n) cin >> p[i];
    dp[0][0] = 1;
    rep(i, 1, n) per(j, 0, i) if (!j) dp[i][j] = dp[i - 1][j] * (1 - p[i]);
    else dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; ++i) ans += dp[n][i];
    cout << fixed << setprecision(10) << ans << endl;
}

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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int M = (int) 1e9 + 7;

int add(int a, int b) {
  a += b;
  if (a >= M) {
    return a - M;
  }
  if (a < 0) {
    return a + M;
  }
  return a;
}

int mul(int a, int b) {
  return a * (ll) b % M;
}

int pw(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) {
      r = mul(r, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return r;
}

int dv(int a, int b) {
  return mul(a, pw(b, M - 2));
}

const int N = (int) 2e5 + 7;
int n;
int ans;
ll a[N], b[N];
pair<ll, ll> p[N], ip[N];

void painfulReading() {
  cin >> n;
  int yacklen = 0;
  for (int i = 1; i <= n; i++) {
    ll x, y;
    cin >> x >> y;
    if (x == 0 && y == 0) {
      ans = add(ans, 1);
      continue;
    }
    if (x == 0) {
      y = 1;
      yacklen++;
      a[yacklen] = 0;
      b[yacklen] = 1;
      continue;
    }
    if (y == 0) {
      x = 1;
      yacklen++;
      a[yacklen] = 1;
      b[yacklen] = 0;
      continue;
    }
    ll g = __gcd(abs(x), abs(y));
    x /= g;
    y /= g;
    if (x < 0 && y < 0) {
      x *= -1;
      y *= -1;
    }
    if (x < 0 && y > 0) {
      x *= -1;
      y *= -1;
    }
    yacklen++;
    a[yacklen] = x;
    b[yacklen] = y;
  }
  n = yacklen;
  for (int i = 1; i <= n; i++) {
    p[i] = {a[i], b[i]};
    if (b[i] > 0) {
      ip[i] = {b[i], -a[i]};
    } else {
      ip[i] = {-b[i], a[i]};
    }
  }
  ans = add(ans, -1);
}

map<pair<ll, ll>, pair<int, int>> mp;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); /// freopen ("input", "r", stdin);
  painfulReading();
  for (int i = 1; i <= n; i++) {
    if (p[i] < ip[i]) {
      mp[p[i]].first++;
    } else {
      mp[ip[i]].second++;
    }
  }
  int prod = 1;
  for (auto &crazy : mp) {
    pair<int, int> it = crazy.second;
    int now = add(0, -1);
    now = add(now, pw(2, it.first));
    now = add(now, pw(2, it.second));
    prod = mul(prod, now);
  }
  ans = add(ans, prod);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 25332
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<int> s = new List<int>();
      static int[] t;
    static decimal result;
  static StringBuilder sb= new StringBuilder("");
static Hashtable ht=new Hashtable();
static int N,M;
static long[,] table;
    static void Main()
    {
Read1();
Read2();
      t=new int[N];
 for(int i=N-1;i>N/2;i--){
 t[i]=s[i];
   if(t[i]==1){result++;}
 }     
      
      for(int i=N/2;i>=0;i--)
      {
        int count=0;
        
      for(int j=i;j<N;j+=i+1)
      {
        if(t[j]==1){count++;}
      }
      
        if(count%2==0){t[i]=s[i];}
        else{if(s[i]==0){t[i]=1;}else{t[i]=0;}}
           if(t[i]==1){result++;}
      }
      
Console.WriteLine(result.ToString());
for(int i=0;i<N;i++){
if(t[i]==1){sb.Append((i+1).ToString() + " ");}
}
Console.WriteLine(sb);
    }

    static void Read1()
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }

    static void Read2()
    {
        string[] tmp=Console.ReadLine().Split(' ');
      for(int i=0;i<N;i++){
        s.Add(int.Parse(tmp[i]));
      }
    }


    static long Gcd(long a, long b)
    {
        var v = new[] { a, b };
        while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
        return v[0];
    }

    static long Lcm(long a, long b)
    {
        return a / Gcd(a, b) * b;
    }


}


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

int main(){
  int N;
  cin>>N;
  vector<ll> A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i)>>B.at(i);
  }

  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  if(N%2==1){
    ll x=B.at(N/2)-A.at(N/2)+1;
    cout<<x<<endl;
  }else{
    ll x=B.at(N/2)+B.at(N/2-1)-A.at(N/2)-A.at(N/2-1)+1;
    cout<<x<<endl;
  }
}


Measured memory_bytes: 6376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 1; i < (n)+1; i++) 
#define out(n) cout << n << endl;
static const double pi = 3.141592653589793;

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double kakudoa,kakudob,kakudo;

    kakudoa = 30*h+0.5*m;
    kakudob = 6*m;

    if(kakudoa >= kakudob){
        kakudo = kakudoa - kakudob;
    }else
    {
        kakudo = kakudob - kakudoa;
    }

    double ans;
    ans = sqrt(pow(a,2) + pow(b,2) - 2*a*b*cos(kakudo*pi/180));
    
  cout << fixed << setprecision(10);
    out(ans);
}

Measured memory_bytes: 4188
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    string s;
    cin >> s;
    int a = s.size();
    rep(i, a) {
        cout << "x";
    }
    cout << endl;

    return 0;
}

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

using namespace std;

#define nl '\n'

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

  vector<int> data(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> data[i];
  }

  vector<int> dp(n, -1);
  dp[0] = 0;
  dp[1] = abs(data[1] - data[0]);

  for (int i = 2; i < n; i++) {
    dp[i] = min(dp[i-1] + abs(data[i] - data[i-1]), dp[i-2] + abs(data[i] - data[i-2]));
  }

  cout << dp[n-1] << nl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  int n;
  cin>>n;
  
  int p=n/100;
  n=n-p*100;
  
  bool y=false;
  bool m=false;
  
  if(1<=n&&n<=12){
    y=true;}
  if(1<=p&&p<=12){
    m=true;}
  
  if(y&&m){
    cout<<"AMBIGUOUS"<<endl;}
  else if(y){
    cout<<"YYMM"<<endl;}
  else if(m){
    cout<<"MMYY"<<endl;}
  else{
    cout<<"NA"<<endl;}
  return 0;
 
 
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, x, res=0;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> x;
		res+=x-1;
	}
	cout << res;
	return 0;
}

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

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

  
  int count=0;
  int now=0;
  int temp;
  
while(1){  
  if(a.at(now)==2){
    count++;
    cout <<count<<endl;
    break;
    
  }
  else if(a.at(now)==-1){
    cout <<"-1"<<endl;
    break;
  }
  else{
    temp=a.at(now);
    count++;
    a.at(now)=-1;
    now=temp-1;
  }
  
}

}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

int main(void){
    int a,b,c,d,max;
    scanf("%d %d %d/",&a,&b,&c);
    scanf("%d",&d);
    max=a;
    if(max<=b){
        max=b;
    }
    if(max<=c){
        max=c;
    }
    int e=pow(2,d);
    printf("%d",max*e+a+b+c-max);
}

Measured memory_bytes: 128
def format(n)
  return sprintf "%.3f", (n*1000).round / 1000.0
end
n = gets.to_i

n.times{
  x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f)
  a = (x2-x3)**2+(y2-y3)**2
  b = (x3-x1)**2+(y3-y1)**2
  c = (x1-x2)**2+(y1-y2)**2
  aa = a*(b+c-a)
  bb = b*(c+a-b)
  cc = c*(a+b-c)
  x0 = (aa * x1 + bb * x2 + cc * x3) / (aa + bb + cc)
  y0 = (aa * y1 + bb * y2 + cc * y3) / (aa + bb + cc)
  r = Math.sqrt((x1-x0)**2+(y1-y0)**2)
  x0 = format(x0)
  y0 = format(y0)
  r = format(r)
  puts "#{x0} #{y0} #{r}"
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll 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(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int n,m;
    cin >> n >> m;
    int l[m],r[m];
    rep(i,m) cin >> l[i] >> r[i];

    int MAX = l[0];
    int MIN = r[0];

    for(int i=1;i<m;i++){
        MAX = max(MAX,l[i]);
        MIN = min(MIN,r[i]);
    }

    int ans = MIN-MAX+1;
    if(ans<0) ans=0;
    cout << ans <<endl;
}

Measured memory_bytes: 1024
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
typedef modint<MOD> m;
#pragma endregion

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

int main() {
  cin >> N >> H;
  priority_queue<int> que;
  ll sum = 0;
  rep(i, N){
    cin >> A;
    que.push(A);
    sum += A;
  }
  rep(i, H){
    sum -= que.top();
    que.pop();
  }
  cout << max(sum, 0ll);
}


Measured memory_bytes: 1400
#include <stdio.h>
#define N_MAX 4000
#define V_MAX 1000
#define K_MAX 4

int main(void)
{
    int n, k, dp[N_MAX + 1][K_MAX + 1];

    for(n = 0; n <= V_MAX; n++)
        dp[n][1] = 1;

    for(n = V_MAX + 1; n <= N_MAX; n++)
        dp[n][1] = 0;

    for(k = 2; k <= K_MAX; k++)
        for(n = 0; n <= N_MAX; n++)
        {
            int sum = 0, v;

            for(v = 0; v <= V_MAX && v <= n; v++)
                sum += dp[n - v][k - 1];

            dp[n][k] = sum;
        }

    while(~scanf("%d", &n))
        printf("%d\n", dp[n][K_MAX]);

    return 0;
}

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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> r;
  for (int i = 1; i <= min(a, b); i++) {
    if (a % i == 0 && b % i == 0) {
      r.push_back(i);
    }
  }
  for (auto e : r) {
    cerr << e << " ";
  }
  cerr << endl;
  cout << r[r.size() - k] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = int64_t;
using int128 = __int128_t;
constexpr int64 MAX = 1e18;

int main() {
  int n;
  cin >> n;
  vector<int64> a(n);
  bool zero = false;
  for (auto &e : a) {
    cin >> e;
    if (e == 0) zero = true;
  }

  if (zero) {
    cout << 0 << endl;
    return 0;
  }

  bool valid = true;
  int128 r = 1;
  for (auto e : a) {
    valid = valid && r * e <= MAX;
    r *= e;
  }
  cout << (valid ? (int64)r : -1) << endl;
}


Measured memory_bytes: 4048
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//ワーシャルフロイト法のテンプレ.graphに最短経路が格納される.
//負の重みがある場合inf + const = inf に気を付けること.
//graphは隣接行列.
void WF(vector<vector<int>> &graph){
	int n = graph.size();
	for (int k = 0; k < n; k++){
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
			}
		}
	}
}

//素因数分解をする関数.
map<long long int, int> prime_factorization(long long int a)
{
	map<long long int, int>ans;
	for (long long i = 2; i*i <= a; ++i) {
		while (a%i == 0) {
			ans[i]++;
			a /= i;
		}
	}
	if (a != 1)ans[a]++;
	return ans;
}

int main()
{
	ll x;
	cin >> x;
	ll ans = (x / 11) * 2;
	x = x % 11;
	if (x > 6)
		ans += 2;
	else if (x > 0)
		ans++;
	cout << ans << endl;

	return 0;
	
}

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

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

  if (n%10==3) cout << "bon" << endl;
  else if (n%10==0 || n%10==1 || n%10==6 || n%10==8) cout << "pon" << endl;
  else cout << "hon" << endl;
  
  return 0;
}


Measured memory_bytes: 3544
#include <stdio.h>

int A[2000];

int main(void)
{
    int a, b, c, d, i, j, k, sum = 0;

    A[0] = 1;

    scanf("%d", &a);
    for (i = 0; i < a; i++)
    {
        scanf("%d", &b);
        sum += b;
        for (j = sum - b; j >= 0; j--)
        {
            if (A[j])
                A[j + b] = 1;
        }
    }

    scanf("%d", &c);
    for (k = 0; k < c; k++)
    {
        scanf("%d", &d);
        if (A[d])
            printf("yes\n");
        else
            printf("no\n");
    }

    return 0;
}


Measured memory_bytes: 2104
#include<iostream>
using namespace std;
using ll = long long;

int n, W;
ll w[110], v[110], dp[100100];

int main(){
	cin >> n >> W;
	for (int i = 1; i <= n; i++)cin >> w[i] >> v[i];
	for (int i = 0; i < n; i++){
		for (int j = W; j >= 0 && w[i + 1] <= j; j--){
			dp[j] = max(dp[j - w[i + 1]] + v[i + 1], dp[j]);
		}
	}
	ll ans = 0;
	for (int i = 0; i <= W; i++) ans = max(dp[i], ans);
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
bool used[111];
int main()
{
	int n;
	pair<int,int> a[111];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i].first>>a[i].second;
		if(a[i].first==a[i].second)
			used[i]=true;
	}
	for(int i=0;i<n-2;i++){
		bool flag=true;
		for(int j=0;j<3;j++)
			if(used[i+j]!=true)
				flag=false;
		if(flag==true){
			cout<<"Yes"<<endl;
			return 0; 
		}
	}
	cout<<"No"<<endl;
	return 0;
 } 

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main(){
int a,b; 
char op;
while(1){
cin>> a >> op >> b;
if( op =='?'){break;}
if( op =='+'){
cout<< a + b<<endl;
}else if( op =='-'){
cout<< a - b<<endl;
}else if( op =='*'){ 
cout<< a * b<<endl;
}else if( op =='/'){
cout<< a / b<<endl;
}else{
cout<<endl;
}
}
return 0;
}




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


 
int main()
{
    int n;
    cin>>n;
    if(n>=1800 && n<=1999) cout<<1;
    else if(n>=1600 && n<=1799) cout<<2;
    else if(n>=1400 && n<=1599) cout<<3;
    else if(n>=1200 && n<=1399) cout<<4;
    else if(n>=1000 && n<=1199) cout<<5;
    else if(n>=800 && n<=999) cout<<6;
    else if(n>=600 && n<=799) cout<<7;
    else if(n>=400 && n<=599) cout<<8;
    
    return 0;
}

Measured memory_bytes: 3644
def main():
    a, b, k = [int(i) for i in input().split()]
    after_a = max(a - k, 0)
    k -= (a - after_a)
    b -= k
    b = max(b, 0)
    print(after_a, b)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#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;
#define yuki 10000
#define ichi 5000
#define hide 1000
int main(){
    int n;
    int Y;
    cin >> n >> Y;
    int x=0,y=0,z=0;
    x = Y/yuki;
    Y -=x*yuki;
    y = Y/ichi;
    Y-=y*ichi;
    z = Y/hide;
    //cout << x << " " << y << " " << z << endl;
    if(x+y+z > n){
        cout << "-1 -1 -1" << endl;
        return 0; 
    }

    while(x+y+z != n){
        if(n-(x+y+z) >= 4){
            y--;
            z+=5;
            if(y==-1){
                y++;
                z-=5;
                if(n-(x+y+z) >= 5){
                    x--;
                    y+=2;
                    if(x==-1){
                        cout << "-1 -1 -1" << endl;
                        return 0;
                    }
                }
                else{
                    x--;
                    y+=2;
                    if(x==-1){
                        cout << "-1 -1 -1" << endl;
                        return 0;
                    }
                }
            }
        }
        else{
            x--;
            y+=2;
            if(x==-1){
                cout << "-1 -1 -1" << endl;
                return 0;
            }
        }
        if(x+y+z > n){
            cout << "-1 -1 -1" << endl;
                return 0;
        }
    }
    cout << x << " " << y << " " << z << endl;
    return 0;
}

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

int n,t;
int a[100002];
int b[100002];

int mx=0,mn=1000000002,dif=0;

int main(){

	cin>>n>>t;
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[i] = mn;
		dif = max(dif,a[i]-b[i]);
		mn = min(a[i],mn);
	}

	int ans = 0;
	for(int i=0;i<n;i++){
		if(a[i]-b[i]==dif){
			ans++;
		}
	}
	cout<<ans<<endl;

	return(0);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  for(int i=1;i<10;i++)
  {
    if(n%i==0 && n/i<10 && n/i>0)
    return cout<<"Yes", 0;
  }
  cout<<"No";
  return 0;
}      

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

int a[4][4];
bool diag()
{
    if ((a[1][1]==a[2][2] && a[2][2]==a[3][3]) || (a[1][3]==a[2][2] && a[2][2]==a[3][1])) return true;
    else return false;
}
bool ngang()
{
    if ((a[1][1]==a[1][2] && a[1][2]==a[1][3]) || (a[2][1]==a[2][2] && a[2][2]==a[2][3]) || (a[3][1]==a[3][2] && a[3][2]==a[3][3])) return true;
    else return false;
}
bool doc()
{
    if ((a[1][1]==a[2][1] && a[2][1]==a[3][1]) || (a[1][2]==a[2][2] && a[2][2]==a[3][2]) || (a[1][3]==a[2][3] && a[2][3]==a[3][3])) return true;
    else return false;
}
int main()
{
    for (int i=1;i<=3;++i)
    {
        for (int j=1;j<=3;++j)
            cin >> a[i][j];
    }
    int n; cin >> n;
    int b[11];
    for (int i=1;i<=n;i++)
    {
        cin >> b[i];
        for (int j=1;j<=3;++j)
        {
            for (int k=1;k<=3;++k)
            {
                if (a[j][k]==b[i]) a[j][k]=0;
            }
        }
    }
    if (diag() || ngang() || doc()) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#pragma warning(disable:4996)
using namespace std;

int main()
{
	int n;
	string k;
	int count = 0;
	set<string>ss;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> k;
		ss.insert(k);

	}
	cout << ss.size() << endl;

}


Measured memory_bytes: 19232
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<int> a(n+1), b(n);
    for(int i=0;i<=n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    ll ans = 0;
    for(int i=n-1;i>=0;i--){
        // i+1番目の方を先に倒す
        ans += min(b[i], a[i+1]);
        b[i] = max(0,b[i] - a[i+1]);

        // i番目の方も倒せるなら倒す.
        ans += min(b[i], a[i]);
        a[i] = max(0, a[i] - b[i]);
    }
    cout << ans << endl;
}


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

int main() {
  string a;
  int b;
  cin >> a;
  b = a.size();
  char c = a.at(b-1);
  if(c == '3'){
    cout << "bon" <<  endl;
  }
  else if (c == '0' || c == '1' || c == '6' || c == '8'){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s;
    if(s=="ani")Cout("square1001");
    else Cout("e869120");
    return 0;
}



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

using namespace std;

#define mod 1000000007
#define inf 1e18
#define ll long long
#define PI 3.1415926536


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

  int n, k;
  cin >> n >> k;

  int prices[n];
  for (int i = 0; i < n; i++) {
    cin >> prices[i];
  }
  sort(prices, prices + n);
  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += prices[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3652
fn solve() {
    let n: usize = read();
    let mut ans = 0;
    for i in 1..n + 1 {
        let j = n / i;
        ans += j * (j + 1) * i / 2;
    }
    println!("{}", ans);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2256