akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

string calc(string a, string b)
{
	int max_size = max(a.size(), b.size());

	vint res(max_size + 1, 0);

	rep(i, max_size)
	{
		int anum = i < a.size() ? a[a.size() - 1 - i] - '0' : 0;
		int bnum = i < b.size() ? b[b.size() - 1 - i] - '0' : 0;
		
		res[i] += anum + bnum;

		res[i + 1] += res[i] / 10;
		res[i] %= 10;
	}

	string ret;
	rep(i, max_size + 1)
		ret = char(res[i] + '0') + ret;

	if(ret[0] == '0') ret = ret.substr(1, ret.size() - 1);

	return ret;
}

bool solve(string line, char x)
{
	rep(i, line.size())
		if(line[i] == 'X')
			line[i] = x;

	string v[3];
	int index = 0;
	rep(i, line.size())
	{
		if(isdigit(line[i]))
			v[index] += line[i];
		else 
			index++;
	}

	return calc(v[0], v[1]) == v[2];
}

int main()
{
	string line;
	while(cin >> line)	
	{
		rep(i, 10)
		{
			if(solve(line, '0' + i))
			{
				cout << i << endl;

				goto ng;
			}
		}

		cout << "NA" << endl;
ng:
		;
	}
}

Measured memory_bytes: 0
#include <string>
#include <iostream>
#include <cassert>
#include <cctype>
using namespace std;

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

string S = "3*(12+3)";
size_t cur = 0;

int expression();

int digit() {
  assert(isdigit(S[cur]));
  int n = S[cur] - '0';
  cur++;
  return n;
}

int number() {
  int n = digit();
  while (cur < S.size() && isdigit(S[cur]))
    n = n*10 + digit();
  return n;
}

int factor() {
  if (S[cur] != '(') return number();
  cur += 1;
  int n = expression();
  assert(S[cur] == ')');
  cur++;
  return n;
}

int term() {
  int a = factor();
  while (cur < S.size() && (S[cur] == '*' || S[cur] == '/')) {
    char op = S[cur++];
    int b = factor();
    if (op == '*') a *= b; else a/= b;
  }
  return a;
}

int expression() {
  int a = term();
  while (cur < S.size() && (S[cur] == '+' || S[cur] == '-')) {
    char op = S[cur++];
    int b = term();
    if (op == '+') a += b; else a -= b;
  }
  return a;
}

int parse() {
  cur = 0;
  return expression();
}

int main (int argc, char const* argv[]) {
  int n; cin>>n;
  rep(i,n) {
    cin>>S;
    S.erase(S.size()-1);
    //cout<<S<<endl;
    cout<<parse()<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
 
void printRectangle(int H, int W){
    int i,j;
    int check_cnt = 0;
    int line_cnt = 0;
     
    for(i=0; i<H; i++){
        check_cnt = line_cnt;
        for(j=0; j<W; j++){
            if(check_cnt %2 == 0)  printf("#");
            else printf(".");
            check_cnt++;
        }
        printf("\n");
        line_cnt++;
    }
    printf("\n");
}
 
int main(void){
     
    int h,w;
     
    while(1){
        scanf("%d %d", &h, &w);
        if(h==0 && w==0) break;
        printRectangle(h, w);
    }
    return 0;
}

Measured memory_bytes: 572
#pragma warning(disable:4996)

#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <complex>
#include <iterator>
#include <random>
#include <time.h>
#include <tuple>
#include <functional>
#include <list>
#include <limits.h>
#define mp make_pair
#define ni(x) scanf("%d", &(x))
#define nii(x,y) scanf("%d%d",&(x),&(y))
#define mul(x,y) ((ll)(x)*(y)%mod)
#define mtp make_tuple
#define F(i,n) for(int i = 0; i < (n); i++)
#define FF(i,n) for(int i = 1; i <= (n); i++)
#define FE(i,n) for(int i = 0; i <= (n); i++)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int mod = 1000000007;
const int inf = 2012345678;
const ll infl = 9012345678901234567;
const double pi = 3.1415926535897932384626433832795;
//----------------------------------------------------------------------------//

const int N = 2000;
int a[N];
vector<int> adj[N];
int chk[N];

int gcd(int a, int b) {
	if (!b)return a;
	else return gcd(b, a%b);
}

vector<int> merge(const vector<int>& a, const vector<int>& b) {
	int n = a.size();
	int m = b.size();
	int i = 0, j = 0;
	vector<int> V;
	while (i < n&&j < m) {
		if (a[i] < b[j])V.push_back(b[j++]);
		else V.push_back(a[i++]);
	}
	for (; i < n; i++)V.push_back(a[i]);
	for (; j < m; j++)V.push_back(b[j]);
	return V;
}

vector<int> dfs(int u) {
	chk[u] = 1;
	vector<int> v;
	for (auto &x : adj[u]) {
		if (chk[x])continue;
		v = merge(v, dfs(x));
	}
	int sz = v.size();
	v.push_back(0);
	for (int i = sz; i; i--)v[i] = v[i - 1];
	v[0] = a[u];
	return v;
}

int main() {
#ifndef __GNUG__
	freopen("input.txt", "r", stdin);
#endif
	int n; ni(n);
	F(i, n)ni(a[i]);
	sort(a, a + n);
	F(i, n) {
		F(j, n) {
			if (i == j)continue;
			if (gcd(a[i], a[j]) > 1) {
				adj[i].push_back(j);
			}
		}
	}
	vector<int> V;
	F(i, n) {
		if (chk[i]) continue;
		V = merge(V, dfs(i));
	}
	for (auto &x : V)printf("%d ", x);
	puts("");
	return 0;
}

Measured memory_bytes: 16000
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int main()
{
	int n, m;
	cin >> n >> m;
	if (n % 3 == 0 || m % 3 == 0 || (n + m) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
//#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#pragma GCC optimize("Ofast")
#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);

int a, b, c;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//	freopen("memory.in", "r", stdin);
	//	freopen("memory.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> a >> b >> c;
	if (a + b + c >= 22)
		cout << "bust";
	else
		cout << "win";

	return 0;
}

Measured memory_bytes: 892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// ここにコードを挿入
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		int t = 0;
		if (l < 0 && Math.abs(l) >= n) {
			for (int i = 0; i < n - 1; i++) {
				t += l + i;
			}
		} else if (l >= 0) {
			for (int i = 0; i < n - 1; i++) {
				t += l + i + 1;
			}
		} else {
			for (int i = 0; i < n; i++) {
				t += l + i;
			}
		}
		System.out.println(t);
	}

}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct Edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    int N,M,tmp;
    while(true){
        cin >> N >> M;
        if(!N && !M) break;
        vector<int> h(N+1, 0), w(M+1, 0);
        map<int, int> maph, mapw;
        reppp(i, 1, N+1){
            cin >> tmp;
            h[i] = tmp + h[i-1];
            repp(j, i){
                maph[h[i]-h[j]]++;
            }
        }
        reppp(i, 1, M+1){
            cin >> tmp;
            w[i] = tmp + w[i-1];
            repp(j, i){
                mapw[w[i]-w[j]]++;
            }
        }

        int ans = 0;
        for(auto itr=maph.begin();itr!=maph.end();++itr){
            int h = itr->first;
            ans += (itr->second) * mapw[h];
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 34316
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    Acum = list(accumulate(A))
    ans = 0
    for i in range(N-1):
        ans += A[i] * (Acum[N-1] - Acum[i]) %MOD
        ans %= MOD
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 28408
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println((int)Math.max(1, Math.ceil((a * 1.0) / (b * 2 + 1))));
	}
}

Measured memory_bytes: 21844
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>

// Aliases
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;

using std::cout;
using std::cerr;
using std::cin;
using std::endl;
using std::string;
using std::vector;
using std::array;
template <class T>
constexpr T inf = std::numeric_limits<T>::max();
template <class T>
constexpr T neg_inf = -std::numeric_limits<T>::max();
template <class T>
constexpr T pi = static_cast<T>(3.141592653589793);

template <class T = i64>
vector<T> read_vector(const u64 n)
{
    vector<T> vec;
    vec.reserve(n);
    for (u64 i = 0; i < n; i++)
    {
        T v;
        cin >> v;
        vec.emplace_back(v);
    }

    return vec;
}

template <class T>
void print(const vector<T>& vec, const bool new_line = false)
{
    const u64 n = vec.size(); 
    if (new_line)
    {
        for (u64 i = 0; i < n; i++)
        {
            cout << vec[i];
            if (i != n - 1) { cout << '\n'; }
        }
    }
    else
    {
        for (u64 i = 0; i < n; i++)
        {
            cout << vec[i];
            if (i != n - 1) { cout << ' '; }
        }
    }

    cout << endl;
}

int main()
{
    u32 n;
    cin >> n;
    vector<u32> vec(n);
    for (u32 i = 0; i < n; i++)
    {
        u32 v;
        cin >> v;
        vec[v - 1] = i + 1;
    }

    for (u32 i = 0; i < n; i++)
    {
        if (i != 0) { cout << " " << vec[i]; }
        else
        {
            cout << vec[i];
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  LL n, a, b; cin >> n >> a >> b;
  if (a > b) swap(a, b);
  LL ans = (b - a) / 2;
  if (a % 2 != b % 2) {
    ans += min(a, n + 1 - b);
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll A, ld B) {
  ld ans = A*B;
  cout << ll(floor(ans)) << endl;
}

int main() {
  ll A;
  cin >> A;
  ld B;
  cin >> B;
  solve(A, B);
  return 0;
}


Measured memory_bytes: 3728
import std.stdio, std.array, std.conv, std.typecons, std.algorithm;

T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

void main() {
    immutable ip = readln.split.to!(ulong[]);
    immutable a = ip[0], p = ip[1];

    writeln((a*3+p)/2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ll n,k;cin>>n>>k;
  vector<ll>ar;
  for(int i=0;i<n;i++){
    ll x;cin>>x;ar.push_back(x);
  }
  vector<ll>s=ar;
  for(int i=0;i<n;i++){s[i]=INT_MAX;}s[n-1]=0;
  for(int i=n-2;i>=0;i--){
    int j=i+1;
    while(j<=i+k&&j<n){
      s[i]=min(s[i],abs(ar[i]-ar[j])+s[j]);j++;
    }
  }
  cout<<s[0]<<endl;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    int l, r, d;
    cin >> l >> r >> d;
    cout << (r / d) - ((l - 1) / d) << endl;
    return 0;
}


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

int ans[100010] = {0};

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        int rx = root(x), ry = root(y);
        if (rx == ry) return false;
        if (size(rx) < size(ry)) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }

    bool isSame(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> F[100010];
    UnionFind uf(100010);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        F[a].push_back(b);
        F[b].push_back(a);
        uf.unite(a, b);
    }
    for (int i = 0; i < k; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        F[a].push_back(b);
        F[b].push_back(a);
    }
    for (int i = 0; i < n; i++) {
        ans[i] += uf.size(i) - 1;
        for (int j = 0; j < F[i].size(); j++) {
            if(uf.isSame(i, F[i][j])) ans[i]--;
        }
    }
    for (int i = 0; i < n; i++) cout << ans[i] << " ";
    return 0;
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,i;
  cin>>a>>b>>c;
  if (a<b){
    for(i=a;i<=b;i++){
      if(i==c){
        cout<<"Yes";break;}
}}

    if (i==b+1){cout<<"No";}
    if (a>b){
      for (i=a;i>=b;i=i-1){
        if (i==c){cout<<"Yes";break;}}
      
      if (i==b-1){cout<<"No";}
    }

  return 0;
  }

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        m: usize,
        edges: [(Usize1, Usize1); m],
    }

    let mut graph = vec![vec![]; n];
    for (a, b) in edges {
        graph[a].push(b);
        graph[b].push(a);
    }

    let mut solve = Solve {
        graph,
        ans: vec![0; n],
    };
    solve.bfs(0);
    println!("Yes");
    for &x in solve.ans[1..].iter() {
        println!("{}", x + 1);
    }
}

struct Solve {
    graph: Vec<Vec<usize>>,
    ans: Vec<usize>,
}

impl Solve {
    fn bfs(&mut self, start: usize) {
        use std::collections::VecDeque;

        let n = self.graph.len();

        let mut visited = vec![false; n];
        let mut queue: VecDeque<(usize, usize)> = VecDeque::new();

        visited[start] = true;
        queue.push_back((start, start));

        while let Some((prev, now)) = queue.pop_front() {
            // eprintln!("visit {}", vertex);
            self.ans[now] = prev;
            for &next in &self.graph[now] {
                if !visited[next] {
                    visited[next] = true;
                    queue.push_back((now, next));
                }
            }
        }
    }
}


Measured memory_bytes: 16024
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int a,b;cin >> a >> b;
    int now = 1;
    auto ceil  = [](int a,int b){
        return (a+b-1)/b;
    };
    cout << ceil(b-1,a-1) << endl;
    return 0;
}

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::string S) {
  string t = S.substr(0, S.size()/2);
  if( t + t == S ){
    cout << YES << endl;
  }else{
    cout << NO << endl;
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (v[i] - c[i] > 0) {
            ans += v[i] - c[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	
	int m;
	cin>>m;
	int y,n;
	long long int A;
	while(m>0){
		long long int max=0;
		cin>>A>>y>>n;
		for(int i=0;i<n;i++){
			int t,h;
			double x;
			long long int a=A;
			long long int B=0,s=0;
			cin>>t>>x>>h;
			for(int j=0;j<y;j++){
				if(t!=0){
					B=a*x;
					a=a+B-h;
				}
				else{
					B=a*x;
					a=a-h;
					s+=B;
				}
			}
			if(max<a+s)
				max=a+s;
	}
		cout<<max<<endl;
		m--;
	}
	
}

Measured memory_bytes: 1232
X = int(input())


def calc_sum_of_digits(x):
    val_sum = 0
    while x > 0:
        x, mod = divmod(x, 10)
        val_sum += mod
    return val_sum


if X % calc_sum_of_digits(X) == 0:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 2940
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#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++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
#define int long long

void solve() {
	int h, n; cin >> h >> n;
    int sum = 0;
    rep(i, n) {
        int a; cin >> a;
        sum += a;
    }
    if(sum >= h) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] in = br.readLine().split(" ");
        int a = Integer.parseInt(in[0]);
        int b = Integer.parseInt(in[1]);
        if(a >= 13) System.out.println(b);
        else if(a >= 6) System.out.println(b / 2);
        else System.out.println(0);

        br.close();
    }
}

Measured memory_bytes: 19412
#include<stdio.h>
#include<ctype.h>
#include<string.h>

int main(void)
{
    int count=0,j,n;
    char moji[11];
    char text[50];
    scanf("%s",moji);
    while(1)
    {
        scanf("%s",text);
        if(strcmp(text,"END_OF_TEXT")==0) break;
        n=strlen(text);
        for(j=0;j<n;j++)
        {
            text[j]=tolower(text[j]);
        }
        if(strcmp(moji,text)==0) count++;
    }
    printf("%d\n",count);
    
    return 0;
}


Measured memory_bytes: 2056
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long long i = p; i < q; i++)
#define repd(i, p, q) for (long long i = p; i >= q; i--)
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> M;
typedef map<long, long> ML;
typedef map<long long, long long> MLL;
typedef pair<int, int> P;
typedef pair<long, long> PL;
typedef pair<long long, long long> PLL;
typedef int I;
typedef double D;
typedef long double LD;
typedef long L;
typedef long long LL;

int main()
{
    LL n;
    cin >> n;
    LL l[n + 3];
    repi(i, 0, n)
    {
        cin >> l[i];
    }
    sort(l, l + n);
    LL sum = 0;
    repi(i, 0, n - 1)
    {
        sum += l[i];
    }
    if (l[n - 1] < sum)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else float('inf')
    
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a+l[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b+l[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c+l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 46812
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {

        //a
        //aa
        //aaa

        // baaaab
        //先に文字列を変えちゃった方がよくて(Substrの境界にあったらどうするの?復元するだけ)

        //a,aa,aaa文字列という分類をしてみる。
        string s = Console.ReadLine();
        int[] sruiseki = new int[s.Length + 1];
        for (int i = 0; i < s.Length; i++) sruiseki[i + 1] = sruiseki[i] + (1 + (s[i] - 'A'));
        string t = Console.ReadLine();
        int[] truiseki = new int[t.Length + 1];
        for (int i = 0; i < t.Length; i++) truiseki[i + 1] = truiseki[i] + (1 + (t[i] - 'A'));
        int q = int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++)
        {
            int[] abcd = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if ((sruiseki[abcd[1]] - sruiseki[abcd[0] - 1]) % 3 == (truiseki[abcd[3]] - truiseki[abcd[2] - 1]) % 3) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 19124
a,v = map(int,input().split())
b,w = map(int,input().split())
T = int(input())

if v <= w:
  print('NO')
else:
  kyori = abs(a-b)
  tijimarusa = abs(v-w)
  if tijimarusa * T >= kyori:
    print('YES')
  else:
    print('NO')

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
int main(){
  string o,e;
  cin >> o >> e;
  int m = o.size() + e.size();
  vector<string> ans(m);
  for(int i = 0; i < m; i++){
    if(i%2 == 0){
      ans.at(i) = o.at(i/2);
    }
    else{
      ans.at(i) = e.at((i-1)/2);
    }
  }
  for(int i = 0; i < m-1; i++){
    cout << ans.at(i);
  }
  cout << ans.at(m-1) << endl;

}

Measured memory_bytes: 256
#include <iostream>

int main (void) {
	std::string S;
	std::cin >> S;
	int cnt = 0, max = 0;
	
	for (auto c : S) {
		if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
			++cnt;
			if (max < cnt) {max = cnt;}
		} else {
			cnt = 0;
		}
	}
	
	std::cout << max;
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int q,n;
vvi a,b;
vi vis,d;

void dfs(int v,int t){
	vis[v]=t;
	for(int u=0;u<n;u++) if(a[v][u]&&b[v][u]&&vis[u]==-1) dfs(u,t);
}

int main(){
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>n;
		a=b=vvi(n,vi(n));
		vis=vi(n,-1);
		d=vi(n);
		for(int j=1;j<n;j++){
			int u,v;
			cin>>u>>v;
			u--;v--;
			a[u][v]=a[v][u]=1;
			d[u]++;d[v]++;
		}
		for(int j=1;j<n;j++){
			int u,v;
			cin>>u>>v;
			u--;v--;
			b[u][v]=b[v][u]=1;
		}
		int res=inf,type=0;
		for(int j=0;j<n;j++) if(vis[j]==-1){
			dfs(j,type);
			int cnt=0;
			vi d_=d,used(n);
			vvi a_=a;
			for(int k=0;k<n;k++) if(vis[k]==type){
				cnt++;
				used[k]=1;
			}
			bool flag=1;
			for(int k=0;k<n-cnt;k++){
				bool B=0;
				for(int v=0;v<n;v++) if(d[v]==1&&!used[v]){
					int w;
					for(int u=0;u<n;u++) if(a[v][u]) w=u;
					for(int u=0;u<n;u++) if(used[u]&&b[v][u]){
						a[v][w]--;a[w][v]--;
						a[v][u]++;a[u][v]++;
						d[w]--;d[u]++;
						B=1;used[v]=1;
						break;
					}
					if(B) break;
				}
				if(!B){
					flag=0;
					break;
				}
			}
			if(flag) res=min(res,n-cnt);
			type++;
			d=d_;a=a_;
		}
		for(int j=0;j<n;j++) if(d[j]==1){
			int x;
			for(int k=0;k<n;k++) if(a[j][k]) x=k;
			for(int y=0;y<n;y++){
				vi used(n),d_=d;
				vvi a_=a;
				used[j]=1;
				bool flag=1;
				a[j][x]--;a[x][j]--;
				a[j][y]--;a[y][j]--;
				d[x]--;d[y]++;
				for(int k=0;k<n-1;k++){
					bool B=0;
					for(int v=0;v<n;v++) if(d[v]==1&&!used[v]){
						int w;
						for(int u=0;u<n;u++) if(a[v][u]) w=u;
						for(int u=0;u<n;u++) if(used[u]&&b[v][u]){
							a[v][w]--;a[w][v]--;
							a[v][u]++;a[u][v]++;
							d[w]--;d[u]++;
							B=1;used[v]=1;
							break;
						}
						if(B) break;
					}
					if(!B){
						flag=0;
						break;
					}
				}
				if(flag) res=min(res,n);
				a=a_;d=d_;
			}
		}
		cout<<(res==inf?-1:res)<<endl;
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int main(){
  ll N,K,x,ans,y;
  cin>>N>>K;
  x=N/K;
  ans=x*x*x;

  if(K%2==0){
    K/=2;
    y=N/K;
    y-=x;
    ans+=y*y*y;
  }
  cout<<ans<<endl;
  
}


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

int main(){
    int n;
    cin >> n;
    int sum = 0;
    vector<int> a(n),b(n),c(n);
    for (int i = 0; i < n; i++){
        cin >> a.at(i);
        a[i]--;
    }
    for (int i = 0; i < n; i++){
        cin >> b.at(i);
    }
    for (int i = 0; i < n - 1; i++){
        cin >> c.at(i);
    }

    for (int i = 0; i < n; i++){
        sum += b[a[i]];
        if (i > 0 && a[i - 1] + 1 == a[i]){
            sum += c[a[i-1]];
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;

int main()
{
	long long ans=0;
	long long a=100;
	long long X;
	cin>>X;
	
	while(X>a)
	{
		a+=a/100;
		a/=1;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}
	

Measured memory_bytes: 3608
use proconio::input;
use proconio::marker::Chars;

#[allow(non_snake_case)]
fn main() {
    input! {
        N: Chars,
    }

    let mut sum = 0;
    for c in N {
        sum += c as u32 - '0' as u32;
    }

    if sum % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
	//2^aのvector.sizeがKよりでかい→絞り込み
	vector<vector<int>> A(3, vector<int>(3));
	for (size_t i = 0; i < 3; i++)
	{
		for (size_t j = 0; j < 3; j++)
		{
			cin >> A.at(i).at(j);
		}
	}
	int N,M;
	cin >> N;
	for (size_t i = 0; i < N; i++)
	{
		cin >> M;
		for (size_t i = 0; i < 3; i++)
		{
			for (size_t j = 0; j < 3; j++)
			{
				if (A.at(i).at(j) == M)A.at(i).at(j) = 1000;
			}
		}
	}
	for (size_t i = 0; i < 3; i++)
	{
		if (A.at(i).at(0)==1000&&A.at(i).at(0) == A.at(i).at(1) && A.at(i).at(1) == A.at(i).at(2)) {
			cout << "Yes";
			return 0;
		}else if(A.at(0).at(i) == 1000&&A.at(0).at(i)==A.at(1).at(i)&&A.at(1).at(i)==A.at(2).at(i)) {
			cout << "Yes";
			return 0;
		}
	}
	if(A.at(0).at(0)+A.at(1).at(1)+A.at(2).at(2)==3000) {
		cout << "Yes";
		return 0;
	}
	else if (A.at(0).at(2) + A.at(1).at(1) + A.at(2).at(0) == 3000) {
		cout << "Yes";
		return 0;
	}
	cout << "No";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;

void solve() {
	cin >> N;
	ll A = 1, B = 1;
	rep(i, 0, N) {
		ll a, b; cin >> a >> b;
		ll c = (A + a - 1) / a;
		ll d = (B + b - 1) / b;
		ll e = max(c, d);
		A = e * a;
		B = e * b;
	}
	cout << A + B << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
n=int(input())
if n==1:
    print(1)
    exit()
    
x=[0]*n
y=[0]*n

for i in range(n):
    x[i],y[i]=map(int,input().split())
dis=[]
for i in range(n):
    for j in range(n):
        if i==j:
            continue
        dis.append((x[j]-x[i],y[j]-y[i]))
        
from collections import Counter
c=Counter(dis).most_common()[0]
print(n-c[1])


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

long long x, y;

int main() {
  cin >> x >> y;
  bool ch = 0;
  for (int i = 0; i <= x; ++i)
    if (2 * i + 4 * (x - i) == y) ch = 1;
  if (ch)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3636
import sys

stdin = sys.stdin

def na(): return map(int, stdin.readline().split())

def ns(): return stdin.readline().strip()

n = int(ns())
i = 1
mi = n
while i*i <= n:
    if n % i == 0:
        x = n // i
        mi = min(mi, x)
    i += 1
print(len(str(mi)))

Measured memory_bytes: 3188
object Main {

  def main(args: Array[String]): Unit = {
    val N = readLine().toInt
    val Bs = readLine().split(" ").map(_.toInt)

    val As = new Array[Int](Bs.length + 1)
    As(0) = Bs(0)
    As(1) = Bs(0)
    for {
      i <- 1 to Bs.length - 1
    } {
      As(i) = As(i) min Bs(i)
      As(i+1) = Bs(i)
    }

    println(As.sum)
      
  }

}


Measured memory_bytes: 27332
import copy

n,w = map(int,input().split()) #n:頂点数　w:辺の数
es = [[] for i in range(w)] #es[i]: [辺の始点,辺の終点,辺のコスト]
for i in range(w):
    x,y,z = map(int,input().split())
    es[i] = [x,y,-z]
    #es[2*i+1] = [y,x,z]
w = w

d = [10**20] * (n+1)
d[1] = 0

def find_negative_loop(n,w,es):
    #負の経路の検出
    #n:頂点数, w:辺の数, es[i]: [辺の始点,辺の終点,辺のコスト]
    

    #この始点はどこでもよい
    for i in range(n):
        for j in range(w):
            e = es[j]
            if d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                
    return d
find_negative_loop(n,w,es)

#print(es)
#print(d)
D=copy.deepcopy(d)
find_negative_loop(n,w,es)
                
#print(d)
if d[n]==D[n]:
    print(-D[n])
else:
    print("inf")
#print(d)


Measured memory_bytes: 46040
/*
    Author: MEHXM
*/
#include <bits/stdc++.h>
using namespace std;

#define cp_io ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long int
#define oo 1000000010
#define MAX 1000000
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define nl "\n"

int main()
{
    cp_io;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    char c;
  	cin >> c;
  	if(c >= 97 && c <= 122)
      cout << "a\n";
  	else
      cout << "A\n";
    return 0;
}

Measured memory_bytes: 3652
use std::collections::VecDeque;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{ next, $($r)* }
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{ next, $($r)* }
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{ $next $($r)* }
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt), * )) => {
        ( $(read_value!($nex, $t)), * )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Failed to parse")
    }
}

fn bfs(i: usize, j: usize, board: &Vec<Vec<char>>) -> usize {
    let mut count = 0;
    let mut queue = VecDeque::new();
    let mut b = board.clone();
    queue.push_back((i, j, 0));
    b[i][j] = '#';

    while let Some((i, j, c)) = queue.pop_front() {
        count = std::cmp::max(count, c);
        // println!("({}, {}), {}", i, j, c);

        if i > 0 && b[i-1][j] == '.' {
            queue.push_back((i - 1, j, c + 1));
            b[i-1][j] = '#';
        }
        if j > 0 && b[i][j-1] == '.' {
            queue.push_back((i, j - 1, c + 1));
            b[i][j-1] = '#';
        }
        if i < b.len() - 1  && b[i+1][j] == '.' {
            queue.push_back((i + 1, j, c + 1));
            b[i+1][j] = '#';
        }
        if j < b[0].len() - 1 && b[i][j+1] == '.' {
            queue.push_back((i, j + 1, c + 1));
            b[i][j+1] = '#';
        }
    }
    count
}

fn main() {
    input!{
        h: usize,
        w: usize,
        board: [chars; h]
    }

    let mut ans = 0;

    for i in 0..h {
        for j in 0..w {
            if board[i][j] == '#' {
                continue;
            }
            ans = std::cmp::max(ans, bfs(i,j, &board));
        }
    }
    
    println!("{}", ans);
}

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

constexpr int64_t mod = 1'000'000'007;

int main(){
    static int64_t dp[65][4];

    uint64_t L, R;
    cin >> L >> R;    

    int lh = -1, rh = -1;
    for(int i=0;i<64;i++){
        if((L>>i) > 0) ++lh;
        if((R>>i) > 0) ++rh;
    }

    for(int i=rh;i>=lh;--i){
        if(i==lh && i==rh) ++dp[i][0];
        else if(i==lh) ++dp[i][1];
        else if(i==rh) ++dp[i][2];
        else ++dp[i][3];
    }

    for(int i=rh-1;i>=0;--i){
        bool lb = (L>>i) & 1, rb = (R>>i) & 1;
        if(lb && rb){
            dp[i][0] = (dp[i][0] + dp[i+1][0]) % mod;

            dp[i][1] = (dp[i][1] + dp[i+1][1]) % mod;

            dp[i][2] = (dp[i][2] + 2*dp[i+1][2]) % mod;
            dp[i][3] = (dp[i][3] + dp[i+1][2]) % mod;

            dp[i][3] = (dp[i][3] + 3*dp[i+1][3]) % mod;
        }else if(lb){
            dp[i][1] = (dp[i][1] + dp[i+1][1]) % mod;

            dp[i][2] = (dp[i][2] + dp[i+1][2]) % mod;

            dp[i][3] = (dp[i][3] + 3*dp[i+1][3]) % mod;
        }else if(rb){
            dp[i][0] = (dp[i][0] + dp[i+1][0]) % mod;
            dp[i][1] = (dp[i][1] + dp[i+1][0]) % mod;
            dp[i][2] = (dp[i][2] + dp[i+1][0]) % mod;

            dp[i][1] = (dp[i][1] + 2*dp[i+1][1]) % mod;
            dp[i][3] = (dp[i][3] + dp[i+1][1]) % mod;

            dp[i][2] = (dp[i][2] + 2*dp[i+1][2]) % mod;
            dp[i][3] = (dp[i][3] + dp[i+1][2]) % mod;

            dp[i][3] = (dp[i][3] + 3*dp[i+1][3]) % mod;
        }else{
            dp[i][0] = (dp[i][0] + dp[i+1][0]) % mod;

            dp[i][1] = (dp[i][1] + 2*dp[i+1][1]) % mod;
            dp[i][3] = (dp[i][3] + dp[i+1][1]) % mod;

            dp[i][2] = (dp[i][2] + dp[i+1][2]) % mod;

            dp[i][3] = (dp[i][3] + 3*dp[i+1][3]) % mod;
        }
    }

    cout << (dp[0][0] + dp[0][1] + dp[0][2] + dp[0][3]) % mod << endl;
    
    return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  int a[m],b[m];
  for(int i=0;i<m;i++) cin >> a[i] >> b[i];
  int x[n+5];
  for(int i=0;i<n+5;i++){
    x[i]=0;
  }
  for(int i=0;i<m;i++){
    if(a[i]==1){
      x[b[i]]++;
    }
    if(b[i]==n){
      x[a[i]]++;
    }
  }
  bool ans=false;
  for(int i=0;i<n+5;i++){
    if(x[i]==2){
      ans=true;
    }
  }
  cout << (ans?"POSSIBLE":"IMPOSSIBLE") << endl;
}

Measured memory_bytes: 2560
#include <cassert>
#include <cmath>
#include <algorithm>
#include <deque>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const int MAX_N = 500;

int grid[MAX_N][MAX_N];

struct Node {
  int y;
  int x;
  int dist;

  Node(int y = -1, int x = -1, int dist = -1) {
    this->y = y;
    this->x = x;
    this->dist = dist;
  }
};

const int DY[4] = {-1, 0, 1, 0};
const int DX[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  vector<int> P;

  for (int i = 0; i < N * N; ++i) {
    int p;
    cin >> p;

    P.push_back(p);
  }

  for (int y = 0; y < N; ++y) {
    for (int x = 0; x < N; ++x) {
      int my = min(y, N - y - 1);
      int mx = min(x, N - x - 1);

      grid[y][x] = min(my, mx);
    }
  }

  int ans = 0;
  bool checked[N][N];
  memset(checked, false, sizeof(checked));

  for (int i = 0; i < N * N; ++i) {
    int p = P[i];
    int y = (p - 1) / N;
    int x = (p - 1) % N;
    int v = grid[y][x];

    checked[y][x] = true;
    ans += v;

    queue<Node> que;

    for (int i = 0; i < 4; ++i) {
      int ny = y + DY[i];
      int nx = x + DX[i];

      if (ny < 0 || nx < 0 || N <= ny || N <= nx) continue;

      que.push(Node(ny, nx, v));
    }

    /*
       cout << endl;

       fprintf(stderr, "p: %d\n", p);
       for (int y = 0; y < N; ++y) {
       for (int x = 0; x < N; ++x) {
       cerr << grid[y][x] << " ";
       }
       cerr << endl;
       }
     */

    while (!que.empty()) {
      Node node = que.front();
      que.pop();

      if (grid[node.y][node.x] <= node.dist) continue;

      // fprintf(stderr, "[%d, %d, %d]\n", node.y, node.x, node.dist);
      grid[node.y][node.x] = min(grid[node.y][node.x], node.dist);

      for (int i = 0; i < 4; ++i) {
        int ny = node.y + DY[i];
        int nx = node.x + DX[i];

        if (ny < 0 || nx < 0 || N <= ny || N <= nx) continue;

        if (checked[node.y][node.x]) {
          que.push(Node(ny, nx, node.dist));
        } else {
          que.push(Node(ny, nx, node.dist + 1));
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5608
use itertools::Itertools;
fn main() {
    proconio::input! {
        n: usize,
        m: usize,
        xyzs: [(i64, i64, i64); n],
    }
    let signss = [[-1, 1], [-1, 1], [-1, 1]];
    let np3_xyzs = [
        xyzs.iter()
            .cloned()
            .sorted_by(|l, r| (-l.0 - l.1 - l.2).cmp(&(-r.0 - r.1 - r.2)))
            .collect_vec(),
        xyzs.iter()
            .cloned()
            .sorted_by(|l, r| (-l.0 - l.1 + l.2).cmp(&(-r.0 - r.1 + r.2)))
            .collect_vec(),
        xyzs.iter()
            .cloned()
            .sorted_by(|l, r| (-l.0 + l.1 - l.2).cmp(&(-r.0 + r.1 - r.2)))
            .collect_vec(),
        xyzs.iter()
            .cloned()
            .sorted_by(|l, r| (-l.0 + l.1 + l.2).cmp(&(-r.0 + r.1 + r.2)))
            .collect_vec(),
        xyzs.iter()
            .cloned()
            .sorted_by(|l, r| (l.0 - l.1 - l.2).cmp(&(r.0 - r.1 - r.2)))
            .collect_vec(),
        xyzs.iter()
            .cloned()
            .sorted_by(|l, r| (l.0 - l.1 + l.2).cmp(&(r.0 - r.1 + r.2)))
            .collect_vec(),
        xyzs.iter()
            .cloned()
            .sorted_by(|l, r| (l.0 + l.1 - l.2).cmp(&(r.0 + r.1 - r.2)))
            .collect_vec(),
        xyzs.iter()
            .cloned()
            .sorted_by(|l, r| (l.0 + l.1 + l.2).cmp(&(r.0 + r.1 + r.2)))
            .collect_vec(),
    ];
    let v = np3_xyzs
        .iter()
        .map(|xyzs| {
            let sumxyz = xyzs.iter().take(m).fold((0, 0, 0), |sum, (x, y, z)| {
                (sum.0 + x, sum.1 + y, sum.2 + z)
            });
            sumxyz.0.abs() + sumxyz.1.abs() + sumxyz.2.abs()
        })
        .collect::<Vec<_>>();
    let ans = v.iter().max().unwrap();
    println!("{}", ans);
}


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

int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    int cnt0 = 0;
    int cnt1 = 0;
    if (s.length() == 1)
    {
        cnt = 0;
    }
    else
    {
        for (int i = 0; i < s.length(); i++)
        {
            if (s[i] == '0')
            {
                cnt0++;
            }
            if (s[i] == '1')
            {
                cnt1++;
            }
        }
        cnt = min(cnt1, cnt0) * 2;
    }
    // while (i < s.length())
    // {
    //     if (s[i] == '0' && s[i + 1] == '1')
    //     {
    //         s.erase(s.begin() + i, s.begin() + i + 2);
    //         i = 0;
    //         cnt += 2;
    //     }
    //     else
    //     {
    //         i++;
    //     }
    //     // cout << i << endl;
    // }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3760
x, y, a, b, c = map(int, input().split())
red = list(map(int, input().split()))
green = list(map(int, input().split()))
clear = list(map(int, input().split()))

red.sort(reverse = True)
red = red[:x]
green.sort(reverse = True)
green = green[:y]

apples = red + green + clear
apples.sort(reverse = True)
apples = apples[:x+y]

print(sum(apples))

Measured memory_bytes: 23328