akhauriyash/Code-Regression huggingface dataset:
import sys
from math import factorial
sys.setrecursionlimit(10000)
def comb (x,y):
	return factorial(x)//factorial(x-y)//factorial(y)

w,h,ax,ay,bx,by=map(int,input().split())
dx=min(w-abs(ax-bx),abs(ax-bx))
dy=min(h-abs(ay-by),abs(ay-by))
ans=1
if dx*2==w:ans*=2
if dy*2==h:ans*=2
ans*=comb(dx+dy,dx)
print(ans%100000007)

Measured memory_bytes: 7800
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << 0 << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(){
    int N,T;
    int t[214514];
    cin >> N >> T;
    REP(i,N){
        cin >> t[i];
    }
    int Ans=T;
    REP(i,N-1){
        Ans+=min(T,t[i+1]-t[i]);
    }
    cout << Ans << endl;
    return 0;
}   


Measured memory_bytes: 1792
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

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

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut H: Vec<i64> = sc.vec(N);
    for i in 0..N-1 {
        let d = H[i+1] - H[i];
        if d < 0 && d.abs() > 1 {
            println!("No");
            return;
        } else if d < 0 {
            H[i+1] = H[i];
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
s = list(input())
K = int(input())
l = len(s)
for i in range(l-1):
    x = (ord('a')-ord(s[i])) % 26
    if x <= K:
        K -= x
        s[i] = 'a'
s[l-1] = chr(ord('a') + (ord(s[-1])-ord('a')+K) % 26)
print(''.join(s))

Measured memory_bytes: 70028
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <unordered_set>
//#include <unordered_map>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=INT_MAX;

void mainmain(){
	int m,n,k,d;
	while(cin>>m>>n>>k>>d,m||n||k||d){
		vvint dp;
		initvv(dp,m+n+2,1<<m,INF);
		VV(pii) vv(m+n+2);
		vint cake(m+1,0);
		rep(i,m){
			cin>>cake[i+1];
		}
		rep(i,d){
			string s1,s2;
			int c;
			cin>>s1>>s2>>c;
			int a,b;
			if(s1[0]=='H'){
				a=0;
			}
			if(s1[0]=='C'){
				a=s1[1]-'0';
			}
			if(s1[0]=='L'){
				int t;
				convert(s1.substr(1),t);
				// cout<<t<<endl;
				a=t+m;
			}
			if(s1[0]=='D'){
				a=n+m+1;
			}

			if(s2[0]=='H'){
				b=0;
			}
			if(s2[0]=='C'){
				b=s2[1]-'0';
			}
			if(s2[0]=='L'){
				int t;
				convert(s2.substr(1),t);
				b=t+m;
			}
			if(s2[0]=='D'){
				b=n+m+1;
			}
			vv[a].PB(pii(b,k*c));
			vv[b].PB(pii(a,k*c));
		}
		priority_queue<pair<int,pii>> pq;
		pq.push(mkp(0,pii(0,0)));
		while(!pq.empty()){
			pair<int,pii> top=pq.top();
			pq.pop();
			if(dp[top.S.F][top.S.S]!=INF){
				continue;
			}
			// cout<<top.S.F<<" "<<top.S.S<<" "<<-top.F<<endl;
			dp[top.S.F][top.S.S]=-top.F;
			int now=top.S.F;
			rep(i,vv[now].size()){
				int next=vv[now][i].F;
				if(1<=next&&next<=m&&(top.S.S&(1<<(next-1)))){
					continue;
				}
				pair<int,pii> t=top;
				if(1<=next&&next<=m){
					t.S.S|=1<<(next-1);
					// t.F+=cake[next];
				}
				t.F-=vv[now][i].S;
				t.S.F=next;
				if(dp[t.S.F][t.S.S]==INF){
					pq.push(t);
				}
			}
		}
		int ans=INF;
		rep(i,1<<m){
			int tmp=dp[n+m+1][i];
			rep(j,m){
				if(i&(1<<j)){
					tmp-=cake[j+1];
				}
			}
			ans=min(ans,tmp);
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1412
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(h,adj):
	n = len(h)
	ans = [0]*n
	for i in range(n):
		if(ans[i] == 0):
			currH = h[i]
			f = 1
			z = 1
			for nn in adj[i]:
				f = 0
				# print('nn:',nn,'i:',i)
				if(h[nn] >= currH):
					# print('$',h[nn],currH)
					z = 0
					break
				elif(h[nn] < currH):
					# print('~',h[nn],currH)
					ans[nn] = -1
			if(z == 1 and f == 0 and ans[i] == 0):
				# print('*',i)
				ans[i] = 1
			# print(i,ans)
	# print()
	for i in range(n):
		if(len(adj[i]) == 0):
			ans[i] = 1
	# print(ans)
	return ans.count(1)

N,M = list(map(int, stdin.readline().rstrip().split()))
h = list(map(int, stdin.readline().rstrip().split()))
adj = [[] for i in range(N)]
for mm in range(M):
	a,b = list(map(int, stdin.readline().rstrip().split()))
	a -= 1
	b -= 1
	adj[a].append(b)
	adj[b].append(a)
ans = solve(h,adj)
print(ans)



Measured memory_bytes: 101632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str = sc.next();
        char c[] = str.toCharArray();
        
        // dp[i][j]: i文字目からとj文字目からの共通文字列の長さ
        // 後ろから考えていく
        int[][] dp = new int[n + 1][n + 1];
        for (int j = n - 1; j >= 0; j--) {
            for (int i = j; i >= 0; i--) {
                // 文字が一致する場合、i, jが1つ後ろ時点の長さ+1になる
                if (c[i] == c[j]) {
                    dp[i][j] = dp[i + 1][j + 1] + 1;
                } else {
                    dp[i][j] = 0;
                }
            }
        }
        
        int max = 0;
        for (int j = n - 1; j >= 0; j--) {
            for (int i = j; i >= 0; i--) {
                // 文字列の重なりを許さないので、
                // ababa, (0, 2) => 本来3だがj-iでカット
                max = Math.max(max, (Math.min(dp[i][j], j - i)));
            }
        }
        
        System.out.println(max);
    }
}


Measured memory_bytes: 169096
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n,m = list(map(int,input().split()))
a = list(map(lambda x : int(x) * (-1) ,input().split()))

from heapq import heappush, heappop, heapify

heapify(a)
for i in range(m):
    tmp_min = (-1)*heappop(a)//2*(-1)
    heappush(a,tmp_min)

print(sum(list(map(lambda x : int(x * (-1)),a))))

Measured memory_bytes: 14168
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

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

ll lcm(ll x, ll y) {
    return x*y / gcd(x,y);
}

int main(void)
{
    IOS
    ll a,b; cin >> a >> b;
    ll g = gcd(a,b);
    int ans = 1;
    ll g2 = g;
    for (ll i = 2; i*i <= g ; i++) {
        if (g2 % i == 0) {
            ans++;
            while(g2 % i == 0) g2 /= i;
        }
    }
    if (g2 != 1) ans++;

    cout << ans << endl;

    return 0;
}

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

const long long MAX = 1000000000;

int main() {
    long long s;
    cin >> s;
    auto x = (MAX - s % MAX) % MAX, y = (s + x) / MAX;
    cout << 0 << ' ' << 0 << ' ' << MAX << ' ' << 1 << ' ' << x  << ' ' << y;
    return 0;
}

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

ans = 0
for i in range(N):
    A[i] -= i+1

b_index = N // 2
A.sort()

def regret(A, b):
    result = 0
    for a in A:
        result += abs(a-b)
    return result

ans = regret(A, A[b_index])
if b_index + 1 < N:
    ans = min(ans, regret(A, A[b_index+1]))
print(ans)


Measured memory_bytes: 26180
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
const int N = 205;
int n;
int co[N],qu[N];
vector<int> cg[N];
char g[N][N];
void bp_bfs(int u)
{
    int u0 = u;
    co[u] = 1;
    int l=0,r=0;
    qu[r++] = u;
    for (;l<r;++l) {
        u = qu[l];
        cg[u0].push_back(u);
        int c = co[u];
        int cc = 3 ^ c;
        for (int i = 0; i < n; ++i) {
            if (g[u][i]) {
                if (!co[i]) {
                    co[i] = cc;
                    qu[r++] = i;
                } else if (co[i] != cc) {
                    cerr << "NOT BIPARTITE\n";
                    cout << -1 << endl;
                    exit(0);
                }
            }
        }
    }
}
int bfs(int u)
{
    co[u] = 1;
    int l=0,r=0,k=1;
    qu[r++] = u;
    for (;l<r;++l) {
        u = qu[l];
        int c = co[u];
        k = max(c, k);
        int cc = c + 1;
        for (int i = 0; i < n; ++i) {
            if (g[u][i]) {
                if (!co[i]) {
                    qu[r++] = i;
                    co[i] = cc;
                } else if (abs(co[i] - c) != 1) {
                    return -1;
                }
            }
        }
    }
    return k;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> g[i];
        for (int j = 0; j < n; ++j)
            g[i][j] -= '0';
    }
    for (int i = 0; i < n; ++i) {
        if (co[i] == 0)
            bp_bfs(i);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (cg[i].empty()) continue;
        int mx = -1;
        for (int u : cg[i]) {
            for (int v : cg[i]) co[v] = 0;
            mx = max(mx, bfs(u));
        }
        if (mx == -1) {
            cout << -1 << endl;
            return 0;
        }
        ans += mx;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define ull unsigned long long
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define eps 1e-9
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }

template<class T>
class DirectedGraph {
public:
	class Edge {
	public:
		int to;
		T cost;

		Edge(int t, T c) : to(t), cost(c) {}

		bool operator<(const Edge& right) const {
			return cost == right.cost ? to < right.to : cost < right.cost;
		}
	};

	vector<vector<Edge>> G;
	int V;

	DirectedGraph(int n = 0) {
		resize(n);
	}

	void resize(int n) {
		V = n;
		G.resize(n);
	}

	void addEdge(int from, int to, T cost = 0) {
		int v = max(from, to);
		if (v >= V)
			resize(v + 1);
		G[from].push_back(Edge(to, cost));
	}

	void dfs(int s) {
		vector<bool> visit(V);
		calcDfs(visit, s);
	}

	void calcDfs(vector<bool>& visit, int s) {
		if (visit[s])
			return;

		visit[s] = true;
		for (int i = 0; i < G[s].size(); ++i) {
			calcDfs(G[s][i].to);
		}
	}

	vector<int> bfs(int s) {
		vector<int> dist(V);
		queue<int> que;

		fill(dist.begin(), dist.end(), -1);
		dist[s] = 0;
		que.push(s);
		while (!que.empty()) {
			int from = que.front();
			que.pop();
			for (int i = 0; i < G[from].size(); ++i) {
				int to = G[from][i].to;
				if (dist[to] != -1)
					continue;
				dist[to] = dist[from] + 1;
				que.push(to);
			}
		}

		return dist;
	}
};

int main() {
	DirectedGraph<int> g;
	int n, from, k, to;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> from >> k;
		while (k--) {
			cin >> to;
			g.addEdge(from, to);
		}
	}

	auto v = g.bfs(1);
	for (int i = 1; i <= n; ++i) {
		cout << i << " " << v[i] << endl;
	}

	return 0;
}

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

int main()
{
    string s, ans, a ="...";
    int n, k;
    cin >> k;
    cin >> s;
    n = s.size();
    if(n <= k){
      ans = s;
    }else{
      ans = s.substr(0,k) + a;
    }
  	
	cout<< ans <<endl;
}

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

int main()
{
	int64_t h, w, ch, cw, dh, dw;
	cin >> h >> w >> ch >> cw >> dh >> dw;
	ch--;
	cw--;
	dh--;
	dw--;
	vector<string> ss(h);
	for (auto &&s : ss)
	{
		cin >> s;
	}

	auto inside = [](int64_t a, int64_t b, int64_t c, int64_t d) {
		return 0 <= a && a < c && 0 <= b && b < d;
	};

	vector<int64_t> dd = {0, 1, 0, -1, 0};

	int64_t inf = (1LL << 60);

	vector<vector<int64_t>> dist(h, vector<int64_t>(w, inf));
	deque<pair<int64_t, pair<int64_t, int64_t>>> dq;
	dist[ch][cw] = 0;
	dq.push_front({dist[ch][cw], {ch, cw}});

	while (!dq.empty())
	{
		int64_t d = dq.front().first;
		int64_t i = dq.front().second.first;
		int64_t j = dq.front().second.second;
		dq.pop_front();

		if (dist[i][j] < d)
		{
			continue;
		}

		for (int k = 0; k < 4; k++)
		{
			int64_t ni = i + dd[k];
			int64_t nj = j + dd[k + 1];

			if (inside(ni, nj, h, w) && (ss[ni][nj] == '.') && (dist[i][j] < dist[ni][nj]))
			{
				dist[ni][nj] = dist[i][j];
				dq.push_front({dist[ni][nj], {ni, nj}});
			}
		}

		for (int64_t di = -2; di <= 2; di++)
		{
			for (int64_t dj = -2; dj <= 2; dj++)
			{
				int64_t ni = i + di;
				int64_t nj = j + dj;

				if (inside(ni, nj, h, w) && (ss[ni][nj] == '.') && (dist[i][j] + 1 < dist[ni][nj]))
				{
					dist[ni][nj] = dist[i][j] + 1;
					dq.push_back({dist[ni][nj], {ni, nj}});
				}
			}
		}
	}

	if (dist[dh][dw] == inf)
	{
		cout << -1 << endl;
		return 0;
	}
	cout << dist[dh][dw] << endl;

	return 0;
}

Measured memory_bytes: 13620
#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;
 
int main() {
int n;
cin>>n;
int t[200000];
int x[200000];
int y[200000];
t[0]=0;
x[0]=0;
y[0]=0;
for(int i=1;i<=n;i++)cin>>t[i]>>x[i]>>y[i];
string ans="Yes";
for(int i=1;i<=n;i++){
int a,b,c;
a=t[i]-t[i-1];
b=abs(x[i]-x[i-1]);
c=abs(y[i]-y[i-1]);
if(a<b+c || (a-b-c)%2!=0)ans="No";
}
cout<<ans<<endl;
}

Measured memory_bytes: 2304
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    deque<int> a;
    deque<int> b;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(i%2==0){
            a.push_back(x);
            b.push_front(x);
        }
        else{
            a.push_front(x);
            b.push_back(x);
        }
    }
    if(n%2==0){
        for(int i = 0; i < n; i++){
            cout << a.front() << " ";
            a.pop_front();
        }
    }
    else{
        for(int i = 0; i < n; i++){
            cout << b.front() << " ";
            b.pop_front();
        }
    }
    
}

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

int main(){
  int x,v;
  string s;
  cin >> s;
  FOR(i,s.size()){
    if(s[i]=='A'){
      v=i;
      break;
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='Z'){
      x=i;
      break;
    }
  }
  cout << x-v+1 << endl;
 }

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

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

Measured memory_bytes: 3640
#include<stdio.h>
int j,n,A[20];
int solve(int i,int m)
{
	int res;
	if (m == 0)
		return 1;
	if (i >= n)
		return 0;
	res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}
int main(void)
{
	int i,m,q;
	scanf("%d",&n);
	for(i=0;i<n;i++){scanf("%d",&A[i]);}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&m);
		printf(solve(0,m)?"yes\n":"no\n");
	}
	return 0;
}

Measured memory_bytes: 580
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
const long long MOD = 1000000007;
long long dp[300][102000] = {};
int main() {
	int n;
	cin >> n;
	int x;
	cin >> x;
	vector<int> s;
	for (int i = 0; i < n; ++i) {
		int tmp;
		cin >> tmp;
		s.push_back(tmp);
	}
	dp[0][x] = 1;
	sort(s.begin(), s.end(), greater<int>());
	for (long long i = 0; i < s.size(); ++i) {
		for (long long q = 0; q <= x; ++q) {
			dp[i + 1][q] += dp[i][q] * ((long long)s.size() - i - 1LL);
			dp[i + 1][q % s[i]] += dp[i][q];
			dp[i + 1][q] %= MOD;
			dp[i + 1][q % s[i]] %= MOD;
		}
	}
	long long ans = 0;
	for (int i = 0; i <= x; ++i) {
		ans += dp[s.size()][i] * (long long) i;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 161280
#include <stdio.h>
int main (void)
{
	int m, f, r;
		
	while(scanf("%d %d %d",&m,&f,&r),m!=-1 || f!=-1 || r!=-1){
		
		
		if(m==-1 || f==-1) printf("F");
		
		else if(m+f>=80) printf("A");
		else if(m+f>=65) printf("B");
		else if(m+f>=50) printf("C");
		else if(m+f>=30) 
			if(r>=50) printf("C");
			else	  printf("D");
		else printf("F");
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
# include <bits/stdc++.h>
# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define fors(i, s) for (int i = 0; s[i]; i++)
# define in freopen("input.txt", "r", stdin)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
 
using namespace std;
 
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
 
int main()
{
	speed;
	int n;
	cin >> n;
	while ( 1 ) {
		int cnt = 0;
		for ( int i = 1; i <= (int)sqrt(n); i++ ) {
			if ( n % i == 0 ) {
				cnt++;
				if ( n / i != i ) cnt++;
			}
		}
		if ( cnt == 2 ) {
			break;
		}
		n++;
	}
	cout << n << endl;
	time;
}

Measured memory_bytes: 256
#!python3

MOD = 10 ** 9 + 7

# input
N, K = list(map(int, input().split()))


def modpow(x, y):
    res = 1
    while y > 0:
        if y & 1:
            res = res * x % MOD
        x = x * x % MOD
        y >>= 1
    return res


def solve(w, x):
    s = 0
    n = K // x
    for i in range(n, 1, -1):
        y = x * i
        if w[y] == 0:
            solve(w, y)
        s = (s + w[y]) % MOD
    w[x] = modpow(n, N) - s


def main():
    w = [0] * (K + 1)
    for i in range(2, K + 1):
        if w[i]:
            continue
        solve(w, i)
    w[1] = modpow(K, N) - sum(w[2:]) % MOD
    
    ans = 0
    for i in range(1, K + 1):
        ans = (ans + w[i] * i) % MOD
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 11880
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    string s; cin >> s;
    bool res = true;
    rep(i,s.size()-1){
        if (s[i] != s[i+1])res = false;
    }
    cout << (res ? "No" : "Yes") << endl;
}


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

using ll = long long;

using namespace std;

int main(){
  int N, M, X;
  cin >> N >> M >> X;
  vector <int> cost(N, 0);
  vector < vector <int> > skills(N + 1, vector <int> (M + 1, 0));
  for(int i = 0; i < N; i++){
    cin >> cost[i];
    for(int j = 0; j < M; j++){
      cin >> skills[i][j];
    }
  }
  vector <ll> curSkills(M, 0);
  ll ans = LLONG_MAX;
  function <void(int, ll)> bruteForce = [&ans, &bruteForce, &N, &M, &X, &cost, &skills, &curSkills](int i, ll P)->void{
    bool ok = true;
    for(int j = 0; j < M; j++){
      if(curSkills[j] < X){
        ok = false;
      }
    }
    if(ok){
      ans = min(ans, P);
    }
    if(i >= N)return;
    // skip
    bruteForce(i + 1, P);
    // i take it
    for(int j = 0; j < M; j++){
      curSkills[j] += skills[i][j];
    }
    bruteForce(i + 1, P + cost[i]);
    for(int j = 0; j < M; j++){
      curSkills[j] -= skills[i][j];
    }
  };
  bruteForce(0, 0);
  if(ans == LLONG_MAX){
    cout << "-1";
  }else{
    cout << ans;
  }
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a[i];
  vector<double>ans(n);
  sort(a.begin(),a.end());
  ans[0] = (a[0]+a[1])/2.0;
  for (int i = 1; i < (n); ++i){
    ans[i] = (ans[i-1]+a[i+1])/2;
  }
  
  printf("%10f\n",ans[n-2]);
  return 0;
}


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

typedef long long ll;

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

    ll n;
    cin >> n;
    vector<ll> h(n);
    for(ll i=1;i<=n;i++) cin >> h[i];
    ll dp[100010];
    dp[1] = 0; dp[2] = abs(h[2]-h[1]);
    for(ll i=3;i<=n;i++){
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int q = sc.nextInt();
			if ((n | q) == 0)
				break;
			int[] cd = new int[101];
			for (int i = 0; i < n; i++) {
				int m = sc.nextInt();
				for (int j = 0; j < m; j++) {
					cd[sc.nextInt()]++;
				}
			}
			int max = 0;
			int ans = 0;
			for (int i = 0; i < 101; i++) {
				if (cd[i] >= q && max < cd[i]) {
					max = cd[i];
					ans = i;
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main(){
	long long int a,b,c[200010],ans =0;
  
  cin >> a >>b ;
  
  if(b%2 ==0){

    ans += ((a+b/2)/b)*((a+b/2)/b)*((a+b/2)/b);
    
    ans += (a/b)*(a/b)*(a/b);
    
  }
  
  else{
    
    ans += (a/b)*(a/b)*(a/b);
    
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX=1e5+10;
ll l[200];
int solve(){
    int n=0,m=0;
    cin>>n;
    for (int i = 0; i < n; ++i) {
        cin>>l[i];
    }
    //if (n<3) return cout<<m<<endl,0;
    for(int i=0;i<n;i++){
        for (int j = i+1; j < n; ++j) {
            for (int k = j+1; k < n; ++k) {
                if (l[i]!=l[j]&&l[j]!=l[k]&&l[i]!=l[k]){
                  if ((l[i]+l[j]>l[k])&&(l[i]+l[k]>l[j])&&(l[k]+l[j]>l[i]))
                      m++;
                }
            }
        }
    }
    cout<<m<<endl;
    return 0;
}
int main(){
    int _=1;
//    cin>>_;
    while(_--){
        solve();
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 5e5 + 5;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	int x, y;
	cin >> x >> y;
	for (int i = 0; i <= x && i * 2 <= y; i++) {
		if ((y - i * 2) % 4 == 0 && i + (y - i * 2) / 4 == x) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)

char tail(string s) {
  return s.at(s.size()-1);
}

int main() {
  int n;cin>>n;
  vector<string> s(n);rep(i,n) cin>>s[i];
  bool ans = true;
  rep(i,n-1) if(tail(s[i]) != s[i+1][0]) ans = false;
  rep(i,n) rep(j,n) if(i!=j&&s[i]==s[j]) ans = false;
  cout << (ans?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using Tuple = tuple<int, int, int>;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modnum = 1e9+7;

int main() {
    string s; cin >> s;
    reverse(s.begin(), s.end());

    vector<vector<ll>> dp(s.size()+5, vector<ll>(13, 0));

    // 初期値を埋めておく
    if(s[0] == '?') {
        rep(i, 10) dp[0][i] = 1;
    } else {
        int n = s[0] - '0';
        dp[0][n] = 1;
    }

    // dpテーブルの構築
    ll num = 10;
    for(int i=1; i < s.size(); i++) {
        if(s[i] == '?') {
            rep(j, 10) rep(k, 13) {
                // i番目に idx のあまりになるのは
                // 339という数値があって,分解すると
                // (10^2 * 3) + 39 という感じにできる
                // これを13で割ったあまりは ((10^2 * 3) % 13 + 39 % 13) という感じで計算できる
                ll idx = (k + j * num) % 13;
                dp[i][idx] += dp[i-1][k];
                dp[i][idx] %= modnum;
            }
        } else {
            int n = s[i] - '0';
            rep(k, 13) {
                ll idx = (k + n * num) % 13;
                dp[i][idx] += dp[i-1][k];
                dp[i][idx] %= modnum;
            }
        }

        num *= 10;
        num %= 13;
    }

    cout << dp[s.size()-1][5] % modnum << endl;

    return 0;
}

Measured memory_bytes: 13696
#include<iostream> 
#include<vector> 
using namespace std; 
typedef unsigned long long int ull; 
vector<ull> allPrimes; 

void sieve(int n) 
{ 
    vector<bool> prime(n+1, true); 
    for (int p=2; p*p<=n; p++) { 
        if (prime[p] == true) { 
            for (int i=p*2; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for (int p=2; p<=n; p++) 
        if (prime[p]) 
            allPrimes.push_back(p); 
} 
ull factorialDivisors(ull n) 
{ 
    sieve(n); 
    ull result = 1;
    for (int  i=0; i < allPrimes.size(); i++) 
    { 
        ull p = allPrimes[i]; 
        ull exp = 0; 
        while (p <= n) 
        { 
            exp = exp + (n/p); 
            p = p*allPrimes[i]; 
        } 
        result = (result*(exp+1))%1000000007; 
    } 
    return result; 
}

int main() 
{ 
    int n; cin>>n;
    cout << factorialDivisors(n); 
    return 0; 
} 


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    forn(i, n){
        int t;
        cin >> t;
        ans += (t < a || t >= b);
    }
    cout << ans << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3640
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0;i<N;++i){
		cin >> A[i];
	}
	const int tenMax = 100*N;
	//0問目からN問目まで
	//0点から100*N点まで
	//0も入るので+1
	vector< vector<bool> > dp(N+1,vector<bool>(tenMax+1,false) );
	dp[0][0] = true;//0問目までに取れる点数は0点のみ
	for(int i=0;i<N;++i){//i+1問目の加点について
		for(int ten=tenMax;ten>=0;--ten){
			if( dp[i][ten] ){//i問目までに取れる点数なら
				dp[i+1][ten] = true;//i+1問目の加点をしない
				dp[i+1][ten+ A[i]] = true;//i+1問目の加点をする
			}
		}
	}
	int ans = 0;
	for(int ten = tenMax; ten >= 0;--ten){
		if( dp[N][ten] && (ten%10 != 0) ){
			ans = max(ans,ten);
		}
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int a,i,b,c,x=0;
	scanf("%d",&a);
	b=a;
	for(i=0;i<9;i++){
		x=x+b%10;
		b=b/10;
		if(b==0)break;
	}
	if(a%x==0){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

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

int main(){
	int n;
	long long sum = 0;
	long long sub_sum = 0;
	long long min = INT_MAX;
	long diff;
	cin >> n;
	vector<long> v(n);
	for(int i = 0; i < n; i++) {
		long l;
		cin >> l;
		v[i] = l;
		sum += l;
	}
	for(int i = 0; i < n - 1; i++) {
		sub_sum += v[i];
		diff = abs(sum - 2*sub_sum);
		if(diff < min) min = diff;
	}
	cout << min;
	return 0;
}



Measured memory_bytes: 1792
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const A = parseInt(arg[0].split(" ")[0]);
    const B = parseInt(arg[0].split(" ")[1]);
    
    const abs = Math.abs(A - B);
    
    if(abs % 2 !== 0) {
        console.log("IMPOSSIBLE");
        return;
    }
    
    let answer = (abs / 2) + Math.min(A, B) 
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include<iostream>
#include<cstdlib>
#include<cstdio>
using namespace std;
int n,a[100010],mx,mn,y;
int main(){mn=200000;mx=0;
    scanf("%d",&n);
	for(int i=1;i<=n;++i)
	  {scanf("%d",&a[i]);
	   mn=min(a[i],mn);mx=max(mx,a[i]);}
	if(mx-mn<2)
	  if(mx-mn==0)
	    if(mx<=n/2||mx==n-1)cout<<"Yes"<<endl;
	    else cout<<"No"<<endl;
	  else
	    {for(int i=1;i<=n;++i)
	       if(a[i]==mn)y++;
	     if(mx-y>0&&mx-y<=(n-y)/2)cout<<"Yes"<<endl;
	     else cout<<"No"<<endl;}
	else cout<<"No"<<endl;
	return 0;}
		    

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 998244353;
using ll = long long;
using P = pair<ll, ll>;
double PI = acos(-1);

int n;
int a, b, c;
vector<vector<P>> to(MX);
int q,k;
int x[MX], y[MX];
int vis[MX];
int dep[MX];

void dfs(int v, int depth) {
    if(vis[v]==1) return;
    vis[v] = 1;
    dep[v] = depth;
    for(auto u: to[v]) {
        dfs(u.first, depth+u.second);
    }
}

signed main(){
    cin >> n;
    rep(i,n-1) {
        cin >> a >> b >> c;
        to[a].push_back({b,c});
        to[b].push_back({a,c});
    }
    cin >> q >> k;
    dfs(k,0);
    
    rep(i, q) {
        cin >> x[i] >> y[i];
        cout << dep[x[i]]+dep[y[i]] << endl;
    }
    return 0;
}



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

typedef map<int,int> MAP;
MAP M;
int main()
{
	int N;
	cin>>N;
	MAP::iterator iter;
	for(int i=0,d;i<N;++i)
	{
		cin>>d;
		if(!M.count(d))	M[d]=1;
		else M[d]++;
	}
	int m;
	cin>>m;
	for(int i=0,d;i<m;++i)
	{
		cin>>d;
		if((iter=M.find(d))==M.end()||M[d]==0)	{cout<<"NO";return 0;}
		else M[d]--;
	}
	cout<<"YES"<<endl;
	return 0;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,A,B=MI()
    a=min(A,B)
    b=max((A+B)-N,0)
    print(a,b)

main()


Measured memory_bytes: 61808
#if 1
#ifdef LOCAL
#define _GLIBCXX_DEBUG 1
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)

typedef string str;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define ts to_string
str ts(char c) { return str(1,c); }
str ts(bool b) { return b ? "true" : "false"; }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
template<class A> str ts(complex<A> c) { stringstream ss; ss << c; return ss.str(); }
str ts(vector<bool> v) { str res = "{"; F0R(i,sz(v)) res += char('0'+v[i]);	res += "}"; return res; }
template<size_t SZ> str ts(bitset<SZ> b) { str res = ""; F0R(i,SZ) res += char('0'+b[i]); return res; }
template<class A, class B> str ts(pair<A,B> p);
template<class T> str ts(T v) { bool fst = 1; str res = "{"; for (const auto& x: v) {if (!fst) res += ", ";	fst = 0; res += ts(x);}	res += "}"; return res;}
template<class A, class B> str ts(pair<A,B> p) {return "("+ts(p.f)+", "+ts(p.s)+")"; }
 
template<class A> void pr(A x) { cout << ts(x); }
template<class H, class... T> void pr(const H& h, const T&... t) { pr(h); pr(t...); }
void ps() { pr("\n"); }
template<class H, class... T> void ps(const H& h, const T&... t) { pr(h); if (sizeof...(t)) pr(" "); ps(t...); }
 
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {cerr << ts(h); if (sizeof...(t)) cerr << ", ";	DBG(t...); }
#endif

int cnt[70][30];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    ll ans = 0;
    
    for (int i = 0; i < n; i++) {
        long long a;
        string bb;

        cin >> a;
        // dbg(a);
        if (cin.peek() == '.') {
            cin.ignore(1);
            cin >> bb;
            // dbg(bb);
        }
        
        while (sz(bb) < 9) bb = bb + '0';
        long long b = stoll(bb);
        // dbg(b);

        a = a * 1000000000 + b;
        int c2 = 0, c5 = 0;
        while (a % 2 == 0) {
            c2++;
            a /= 2;
        }
        while (a % 5 == 0) {
            c5++;
            a /= 5;
        }

        // dbg(c2,c5);
        for (int i = max(0, 18-c2); i < 70; i++) {
            for (int j = max(0, 18-c5); j < 30; j++) {
                ans += cnt[i][j];
            }
        }
        cnt[c2][c5]++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

int main(){
	int n=read(),m=read(),a=read(),b=read();
	swap(a,b);
	For(i,1,a){
		For(j,1,b) printf("1");
		For(j,b+1,m) printf("0");
		puts("");
	}
	For(i,a+1,n){
		For(j,1,b) printf("0");
		For(j,b+1,m) printf("1");
		puts("");
	}
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int dx[]={-1,0,1,-1,0,1,-1,0,1};
int dy[]={-1,-1,-1,0,0,0,1,1,1};
int main(){
    ll a,b;
    cin>>b>>a;
    vector<vector<int> >c(102,vector<int>(102));
    rep(i,50)rep(j,100){
        c[i+1][j+1]=1;
    }
    REP(i,50,100)rep(j,100){
        c[i+1][j+1]=2;
    }
    b--;
    rep(i,50){
        rep(j,100){
        if(b==0)break;
        bool f=1;
        rep(k,9){
            if(c[i+1+dx[k]][j+1+dy[k]]==2)f=0;
        }
        if(f){
            c[i+1][j+1]=2;
            b--;
        }
        }
        if(b==0)break;
    }
    a--;
    REP(i,50,100){
        rep(j,100){
        if(a==0)break;
        bool f=1;
        rep(k,9){
            if(c[i+1+dx[k]][j+1+dy[k]]==1){
                f=0;
            }
        }
        if(f){
            c[i+1][j+1]=1;
            a--;
        }
        }
        if(a==0)break;
    }
    cout<<100<<' '<<100<<endl;
    rep(i,100){
        rep(j,100){
            if(c[i+1][j+1]==1)cout<<'#';
            else cout<<'.';
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define int long long

signed main(){
    int n, a, b;
    cin >> n >> a >> b;
    int c = a - b;

    vector<int> v(n);
    for(int i = 0; i < n; i++)cin >> v[i];

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

    vector<int> tmp(n);
    int ok = 1e9;
    int ng = 0;
    int mid;
    int count;

    while(ok - ng > 1){
        mid = (ok + ng) / 2;
        count = 0;

        for(int i = 0; i < n; i++){
            tmp[i] = v[i] - b * mid;
            if(tmp[i] > 0){
                count += (tmp[i] + c - 1) / c;
            }
        }
        if(count <= mid){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
}

Measured memory_bytes: 1792