akhauriyash/Code-Regression huggingface dataset:
N = int(input())

list753 = [3, 5, 7]
beforeLength = 0
for i in range(1, 9):
    afterLength = len(list753)
    for j in range(3):
        for k in range(beforeLength, afterLength):
            x = list753[k] + 10 ** i * list753[j]
            list753.append(x)
    beforeLength = afterLength

listTrue753 = []
for i in list753:
    numberString = str(i)
    if numberString.count("3") > 0 and numberString.count("5") > 0 and numberString.count("7"):
        listTrue753.append(i)

count = 0
for i in listTrue753:
    if i <= N:
        count += 1
print(count)

Measured memory_bytes: 10528
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  
  ll tmp1=A*X+B*Y;
  ll tmp3=max(X,Y)*C*2;
  ll tmp2;
  if(X>=Y)tmp2=Y*2*C+(X-Y)*A;
  else tmp2=X*2*C+(Y-X)*B;
  ll ans=min(tmp1,tmp2);
  ans=min(ans,tmp3);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
io = STDIN
n,x=io.gets.split.map(&:to_i)
l=io.gets.split.map(&:to_i)
l.unshift(0)
cnt = 0
d=0
(0..n).each do |i|
  d = d+l[i]
  cnt  += 1 if d<=x
end
puts cnt


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;
    cin >> N;
    cout << (N+1)/2 << "\n";
    return 0;
}

Measured memory_bytes: 256
n,m = gets.chomp.split(' ').map(&:to_i)
x = gets.chomp.split(' ').map(&:to_i).sort!
if x.size == 1 || n >= m
    puts '0'
else
    diff = Array.new((m-1),0)
    (m-1).times do |i|
        diff[i] = x[i+1]-x[i]
    end
    puts diff.sort.slice(0,m-n).inject(:+)
end

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

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

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

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

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

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

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

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int s, w; cin >> s >> w;
    if(s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

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


Measured memory_bytes: 7708
import java.util.*;

public class Main {

    public static void main(String[] args) {
       Scanner scanner = new Scanner(System.in);
       int [] nums = new int[3];
       for(int i = 0 ; i<3;i++){
       nums[i] = scanner.nextInt();
       }
       int sum = 0;
       int count = 0;
       for(int i = 0 ; i<nums.length;i++){
       if(nums[i] == 5){
       sum++;
       } else if(nums[i]  == 7 ){
       count++;
       } else{
       sum +=0;
       count+=0;
       }
       
       
       
       }
       if(sum == 2 && count ==1){
           System.out.println("YES");
       } else {
           System.out.println("NO");
       }
       
       
    }
    
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int main() {

	int N;
	ll power = 1;

	cin >> N;
	for (int i = 1; i <= N; i++) {

		power *= i;
		power = power%MOD;

	}

	cout << power << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  string s;
  cin >> s;
  vector <ll> v(s.size(), 0);
  vector <ll> u(s.size(), 0);
  rep(i, s.size()-1) {
    if (s.at(i)=='R' && s.at(i+1)=='L') u.at(i+1)++;
  }
  rep(i, s.size()-1) u.at(i+1) += u.at(i);
  rep(i, s.size()) {
    if (s.at(i) == 'R') {
      auto itr = upper_bound(u.begin(), u.end(), u.at(i));
      ll n = distance(u.begin(), itr), m = distance(next(u.begin(), i), itr);
      if (m%2) {
        v.at(i+m-1)++;
      } else {
        v.at(i+m)++;
      }
    } else {
      auto itr = lower_bound(u.begin(), u.end(), u.at(i));
      ll n = distance(u.begin(), itr), m = distance(itr, next(u.begin(), i));
      if (m%2) {
        v.at(i-m-1)++;
      } else {
        v.at(i-m)++;
      }
    }
  }
  rep(i, s.size()) {
    cout << v.at(i) << ' ' ;
  }
  cout << endl;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define rep(i,n) for(size_t i=0;i<(size_t)(n);i++)
#define rrep(i,n) for(size_t i=(size_t)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

inline int sum(const map<int,int>& b){
  int sum = 0;
  for(auto p : b) sum += p.second;
  return sum;
}

int main(){
  int n,m;
  cin >> n >> m;
  vector< map<int,int> > bucket(m);
  rep(i,n){
    int x;
    cin >> x;
    bucket[x%m][x]++;
  }

  int ans = 0;
  for(int i=1;i<(m+1)/2;i++){
    int idx_a = i, idx_b = m-i;
    int num_a = sum(bucket[idx_a]), num_b = sum(bucket[idx_b]);
    if(num_a > num_b){
      swap(idx_a, idx_b); swap(num_a, num_b);
    }

    ans += num_a;
    int self_pair = 0;
    for(auto p : bucket[idx_b]) self_pair += p.second/2;
    ans += min((num_b-num_a)/2, self_pair);
  }

  ans += sum(bucket[0])/2;
  if(m%2==0) ans += sum(bucket[m/2])/2;

  cout << ans << endl;
}


Measured memory_bytes: 9600
#include<iostream>
#include<string>
#include<vector>
#include<ctime>
#include<iomanip>
#include<fstream>
#include<stack>
#include<queue>
#include<cassert>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<functional>
#include<exception>
#include<utility>
#define fori(i,z,u) for(i=z;i<u;i++)
#define forz(i,m) for(i=0;i<m;i++)
#define forinc(i,z,u,inc) for(i=z;i<u;i+=inc)
using namespace std;
#define fi first
#define se second
#define vi vector<int>
#define vill vector<long long>
#define vd vector<long double>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vb vector<bool>
#define ump unordered_map
#define debug(x) cout<<#x<<" : "<<x
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define pii pair<int,int>
#define pll pair<ll,ll>
//#define Onlaptop

int main()
{
	int i{ 0 }, j{ 0 }, k{ 0 }, l{ 0 }, a{ 0 }, b{ 0 }, c{ 0 }, d{ 0 }, t{ 0 }, n{ 0 };

	#ifdef Onlaptop
		fstream cin,cout;
	
		cin.open("input.txt");
		cout.open("output.txt",ios::trunc);
	#endif
	
	cin>>a;
	
	for(int i=1;i<=a;i++)
	{
		string ans=to_string(i);
		
		c=ans.size();
		if(c&1)
		{
			n++;
		}
	}
	cout<<n;
	
	return 0;
}

Measured memory_bytes: 256
def d_grid_repainting(H, W, S, INF=float('inf')):
    def bfs():
        from collections import deque
        queue = deque([(0, 0)])  # スタート座標は (0, 0) とする
        dist = [[INF for _ in range(W)] for _ in range(H)]  # スタートからの距離
        dist[0][0] = 1  # スタート地点には1歩で到達可能とする
        while queue:
            h, w = queue.pop()
            if h == H - 1 and w == W - 1:
                break  # ゴールした
            for dh, dw in ((-1, 0), (0, 1), (1, 0), (0, -1)):
                nh, nw = h + dh, w + dw  # (h, w) の上右下左
                if 0 <= nh < H and 0 <= nw < W and S[nh][nw] != '#' and dist[nh][nw] == INF:
                    # (nh, nw) はグリッド内、黒マスでない、距離が未確定
                    queue.appendleft((nh, nw))  # 探索する座標
                    dist[nh][nw] = dist[h][w] + 1
        return dist[H - 1][W - 1]

    # ゴールに最短で辿り着こうとしたときに踏んだ白マス(スタートとゴールを含む)の数を調べる。
    # 発散したなら、ゴールに到達できなかったので-1を返す。
    # 有限なら、踏まなかった白マスをすべて黒にすればいいので、
    # (初期状態の白マス - 踏んだ白マス) を返す。
    num_white_square = sum([row.count('.') for row in S])
    reach_white_square_min = bfs()
    return num_white_square - reach_white_square_min if reach_white_square_min != INF else -1

H, W = [int(i) for i in input().split()]
S = [input() for _ in range(H)]
print(d_grid_repainting(H, W, S))

Measured memory_bytes: 3316
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $s = <STDIN>);
my $m = length $s;
my @t = split //, $s;
my @u = grep {my $x = 0; for my $i (0..$m-1) {$x++ if $_ eq $t[$i]}; $x} ('a'..'z');
my $min = $m;
for my $i (@u) {
  my @v = @t;
  my $c = 0;
  while ($i x scalar(@v) ne join('', @v)) {
    for my $j (0..@v-1) {
      if ($v[$j] eq $i || $v[$j+1] eq $i) {
        $v[$j] = $i;
      }
    }
    pop @v;
    $c++;
  }
  $min = $c if $min > $c;
}
say $min;

Measured memory_bytes: 896
#include<stdio.h>
int main()
{
	int a[101][101] = {  }, ruio, hideo, nagase = 0, masatoy = 0, j;
	char str[101][101] = { NULL};
	scanf("%d %d", &ruio, &hideo);
	for (int i = 0; i < ruio; i++) {
			scanf("%s", &str[i]);
	}
	for (int i = 0; i < ruio; i++) {
		for (int j = 0; j < hideo; j++) {
			if (str[i][j] == 'c') {
				a[i][j] = 0;
			}
			else {
				a[i][j] = -1;
			}
		}
	}
	for (int i = 0; i < ruio; i++) {
		for (int j = 1; j < hideo; j++) {
			for (int y = 0; y < hideo; y++){
				if (str[i][y] == 'c') {
					if (a[i][y] == -1) {
						a[i][y] = masatoy;
					}
				}
				
			}
			masatoy++;
			for (int x = hideo; x > 0; x--) {
				str[i][x] = str[i][x-1];
			}
		}
		masatoy = 0;
	}
	for (int i = 0; i < ruio; i++) {
		for (int j = 0; j < hideo; j++) {
			if (a[i][j] == -2) {
				a[i][j] = -1;
			}
		}
	}
	for (int i = 0; i < ruio; i++) {
		for (int j = 0; j < hideo; j++) {
			printf("%d", a[i][j]);
			if(j<hideo-1)printf(" ");
		}
		printf("\n");
	}
}

Measured memory_bytes: 2780
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#include<cstring>
#define ll long long
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>QUE;//きゅー
pair<pair<string, int>, int> p[110];//pair型
int length(char* str) {
    int len = strlen(str);
    return len;
}
ll GCD(ll a, ll b)
{

    ll r, tmp;

    /* 自然数 a > b を確認・入替 */
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }


    return b;
}
ll LCM(ll a, ll b)
{

    ll r, x, tmp;
    ll i, j;
    ll lcm;
    i = a;
    j = b;

    /* 自然数 a > b を確認・入替 */
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    lcm = (i / b) * j;

    return lcm;
}
int main()
{
    int A, B, K;
    int count = 0;
    cin >> A >> B >> K;
    for (int i = max(A, B); i > 0; i--) {
        if (A % i == 0 && B % i == 0) {
            count++;
            if (count == K) {
                cout << i << endl;
                return 0; 
            }
        }
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=1000000007;
int main(){
ll a,b,c,d,e;cin>>a>>b>>c>>d>>e;
if(a==0)cout << 1 << endl;
if(b==0)cout << 2 << endl;
if(c==0)cout << 3 << endl;
if(d==0)cout << 4 << endl;
if(e==0)cout << 5 << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  for (long long int i = 0; i < 200; i++) {
    for (long long int j = -200; j < 200; j++) {
      if (i*i*i*i*i - j*j*j*j*j == x) {
        cout << i << ' ' << j << '\n';
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
using namespace std;
typedef vector<int> vi;
typedef long int li;
typedef unsigned long long ull;


int main(int argc,char* argv[])
{
    set<int> st;
    int a;
    rep(i,3){ cin>>a ; st.insert(a);}
    cout<<st.size()<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;
  vll V;
  V.pb(3);
  V.pb(5);
  V.pb(7);
  map<vll, ll> m;

  queue<vll> q;
  q.push(V);

  ll ans = 0;
  while (!q.empty()) {
    vll v = q.front();
    q.pop();
    SORT(v);
    if (m[v] == 0) {
      m[v]++;
      do {
        ll num = 0;
        rep(i, v.size()) {
          num += pow(10, i) * v[i];
        }
        if (num <= N) {
          ans++;
        }
      } while (next_permutation(ALL(v)));

      if ((ll)v.size() < getDigit(N)) {
        v.pb(3);
        q.push(v);
        v.pop_back();
        v.pb(5);
        q.push(v);
        v.pop_back();
        v.pb(7);
        q.push(v);
      }
    }
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#define LIMIT_LINES (10)
#define LIMIT_STEPS (30)

char g_side[LIMIT_STEPS][LIMIT_LINES];

int draw_cross(char line[LIMIT_LINES], int end, int pos, int left) {
	if (left) {
		if (pos < 1 || line[pos-1] == '1')
			return 0;
		if (pos > 1 && line[pos-2] == '1')
			return 0;
		if (pos < end && line[pos] == '1')
			return 0;
		line[pos-1] = '1';
		return pos;
	}
	if (pos >= end || line[pos] == '1')
		return 0;
	if (pos < (end-1) && line[pos+1] == '1')
		return 0;
	if (pos > 0 && line[pos-1] == '1')
		return 0;
	line[pos] = '1';
	return pos + 1;
}

int run(int start, int num_step, int add, int left, int *cross) {
	int end, pos, step;
	char line[LIMIT_LINES];

	end = strlen(g_side[0]);
	pos = start - 1;
	add -= 1;
	*cross = 0;
	for (step = 0; step < num_step; step++) {
		strcpy(line, g_side[step]);
		if (add == step) {
			*cross = draw_cross(line, end, pos, left);
			if (!*cross)
				return 0;
		}
		if (pos > 0 && line[pos-1] == '1') {
			pos -= 1;
		}
		else if (pos < end && line[pos] == '1') {
			pos += 1;
		}
	}
	return pos + 1;
}

int main(void) {
	int n, start, hit, num_step, step, cross;

	while (1) {
		scanf(" %d ", &n);
		if (!n)
			break;
		scanf(" %d %d %d ", &start, &hit, &num_step);
		for (step = 0; step < num_step; step++) {
			scanf(" %s ", g_side[step]);
			//printf("%s\n", g_side[step]);
		}

		if (run(start, num_step, 0, 1, &cross) == hit) {
			puts("0");
			continue;
		}
		for (step = 1; step <= num_step; step ++) {
			if (run(start, num_step, step, 1, &cross) == hit) {
				printf("%d %d\n", step, cross);
				break;
			}
			if (run(start, num_step, step, 0, &cross) == hit) {
				printf("%d %d\n", step, cross);
				break;
			}
		}
		if (step > num_step) {
			puts("1");
		}
	}
	return 0;
}

Measured memory_bytes: 620
#include<bits/stdc++.h>
#define pb push_back 
#define mp make_pair
using namespace std;

const int maxn=1e5+7;
typedef long long ll;

ll n,m,ans,b,a;
ll h[maxn],f[maxn];

bool check(ll m)
{
	ll res=0,i,j;
	for(i=1;i<=n;++i)
	  f[i]=h[i]-b*m;
	
	for(i=1;i<=n;++i)
	{
		if(f[i]<=0) continue;
		res+=(f[i]+a-1)/a;
	}
	if(res<=m) return true;
	return 0;
	
}

int main()
{
	ll i,j,k;
	scanf("%lld%lld%lld",&n,&a,&b);
	a=a-b;
	
	for(i=1;i<=n;++i) scanf("%lld",&h[i]);
	
	ll l=1,r=1e9,ans=-1;
	
	while(l<=r)
	{
		ll mid=(l+r)/2;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	
	printf("%lld",ans);
	
	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;

    for(int i=0; i<2; i++){
        if(a>b){
            ans+=a;
            a--;
        }else{
            ans+=b;
            b--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-05 16:01:53
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>

template<class T> 
using pbds_tree = __gnu_pbds::tree<T, __gnu_pbds::null_type, std::less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

constexpr int inf = (int)1e9;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k; cin >> n >> k;
  vector<int> a(n); cin >> a;

  int r = 0;
  int ans = inf;

  pbds_tree<int> pt;
  vector<int> mp(101010, 0);

  for (int l = 0; l < n; ++l) {
    while (r < n && *pt.find_by_order(k - 1) != k) {
      ++mp[a[r]];
      pt.insert(a[r]);
      ++r;
    }
    int len = r - l;
    if (*pt.find_by_order(k - 1) == k) ans = min(ans, len);
    if (r == l) {
      ++r;
    } else {
      --mp[a[l]];
      if (mp[a[l]] == 0) pt.erase(pt.find(a[l]));
    }
  }

  if (ans == inf) ans = 0;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8272
x,n = map(int,input().split())
if n==0:
    print(x)
else:
    p = list(map(int,input().split()))
    p.sort()
    if not(x in p):
        print(x)
    else:
        i=1
        while True:
            if not(x-i in p):
                print(x-i)
                break
            elif not(x+i in p):
                print(x+i)
                break
            i= i+1

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

using Lint=long long;
using P=pair<int,int>;

int main()
{
   int N; cin>>N;
   vector<P> p(N);
   for(int i=0;i<N;i++){
      int t; cin>>t; t--;
      p[i]=make_pair(t,i);
   }
   sort(p.begin(),p.end());

   vector<int> a(N*N,-1);
   int cur=0;
   for(int i=0;i<N;i++){
      a[p[i].first]=p[i].second;
      // cout<<p[i].first<<' '<<p[i].second<<endl;

      for(int j=0;j<p[i].second;j++){
         while(cur<N*N and a[cur]!=-1) cur++;
         if(cur>p[i].first){ cout<<"No"<<endl; return 0; }
         a[cur]=p[i].second;
      }
      // for(int j=0;j<N*N;j++) cout<<a[j]+1<<' '; cout<<endl;
   }
   cur=N*N-1;
   for(int i=N-1;i>=0;i--){
      // cout<<p[i].first<<' '<<p[i].second<<endl;
      for(int j=0;j<N-p[i].second-1;j++){
         while(cur>=0 and a[cur]!=-1) cur--;
         if(cur<p[i].first){ cout<<"No"<<endl; return 0; }
         a[cur]=p[i].second;
      }
      // for(int j=0;j<N*N;j++) cout<<a[j]+1<<' '; cout<<endl;
   }
   cout<<"Yes"<<endl;
   for(int i=0;i<N*N;i++) cout<<a[i]+1<<' '; cout<<endl;
   return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a){
        cout<<k<<endl;
    }else if(k<=a+b){
        cout<<a<<endl;
    }else{
        cout<<a-(k-a-b)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"-----------"<<endl;
#define ll long long
#define P pair<int,int>
#define mk make_pair
#define en endl
#define RE return 0
#define int ll

int sum[505][505];

signed main(){
  int n,m,q;
  cin>>n>>m>>q;
  for(int i=0; i<m; i++){
    int l,r;
    cin>>l>>r;
    sum[l][r]++;
  }
  
  for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
      sum[i][j+1]+=sum[i][j];
    }
  }
  
  for(int i=0; i<q; i++){
    int l,r;
    cin>>l>>r;
    int ret=0;
    for(int j=l; j<=r; j++) ret+=sum[j][r];
    cout<<ret<<en;
  }
}



Measured memory_bytes: 2944
#include<stdio.h>
#include<string.h>
int main(){
  char a[110],b[110];
  int i,j,n;    
  scanf("%d %s %s",&n,a,b);
  for(i=0;a[i];i++){
    for(j=0;b[i+j];j++){
      if(a[i+j]-b[j])break;
    }
    if(a[i+j]==0)break;
  }
  printf("%d\n",n+i);
  return 0;
}


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

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





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



ll solve(vector<ll> a) {
    int n = a.size();
    vector<ll> acc(n+1, 0);
    for (int i=0; i<n; i++) {
	acc[i+1]=a[i];
	acc[i+1]+=acc[i];
    }

    ll res = acc[n];

    for (int i=0; i<n; i++) {
	ll left = acc[i+1];
	ll right = acc[n] - left;
	res = min(res, abs(left-right));
    }

    return res;
}



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

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

    ll res = solve(a);
    reverse(a.begin(), a.end());
    res = min(res, solve(a));
    out(res);    
    return 0;
}


Measured memory_bytes: 7888
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  pair<int,int> a[100010];
  for (int i = 0; i < M; i++) {
    int s, t; cin >> s >> t;
    a[i] = make_pair(s,t);
  }
  pair<int,int> c[100010];
  //cout << c[0].first << " " << c[0].second << endl;
  sort(a, a+M);
  c[0] = a[0];
  int n = 1;
  for (int i = 1; i < M; i++) {
    int l = a[i].first; int r = a[i].second;
    //cout << l << " " << r << endl;
    int s = 0;
    for (int j = 0; j < n; j++) {
      int x = c[j].first; int y = c[j].second;
      //cout << j << ":" << x << " " << y << endl;
      if (l <= x && l < y && r <= y && r > x) {
        c[j] = make_pair(x, r); s++;
      }
      if (l > x && l < y && r > y && r > x) {
        c[j] = make_pair(l, y); s++;
      }
      if (l > x && l < y && r <= y && r > x) {
        c[j] = make_pair(l, r); s++;
      }
      if (l <= x && l < y && r > y && r > x) {
         s++;
      }
    }
    if (s == 0) {
      c[n] = make_pair(l, r); n++;
    }
  }
  cout << n << endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cmath>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};


int main()
{
  int n,k; cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  sort(a.begin(), a.end(), [](ll x, ll y) {
			     return abs(x) > abs(y);
			   });

  int cnt = 0;
  mint sum(1);
  int emin = -1, omin = -1, emax = -1, omax = -1;
  rep(i,k) {
    sum *= (mint)abs(a[i]);
    if(a[i] > 0) {
      emin = i;
    }
    else if(a[i] < 0) {
      omin = i;
      cnt++;
    }
  }

  if(cnt % 2 == 0) {
    cout << sum.x << "\n";
    return 0;
  }
  
  for (int i = k; i < n; ++i) {
    if(a[i] > 0 && emax == -1) emax = i;
    else if(a[i] < 0 && omax == -1) omax = i;
  }
  bool fx = ((emin == -1) || (omax == -1));
  bool fy = ((omin == -1) || (emax == -1));
  if(fx && fy) {
    mint tmp(1);
    rep(i,k) {
      tmp *= (mint)abs(a[n - 1 - i]);
    }
    mint res;
    res -= tmp;
    cout << res.x << "\n";
  }
  else if(fx) {
    sum /= (mint)abs(a[omin]);
    sum *= (mint)abs(a[emax]);
    cout << sum.x << "\n";
  }
  else if(fy) {
    sum /= (mint)abs(a[emin]);
    sum *= (mint)abs(a[omax]);
    cout << sum.x << "\n";
  }
  else {
    if(a[omin] * a[omax] < a[emin] * a[emax]) {
      sum /= (mint)abs(a[omin]);
      sum *= (mint)abs(a[emax]);
    }
    else {
      sum /= (mint)abs(a[emin]);
      sum *= (mint)abs(a[omax]);
    }
    cout << sum.x << "\n";
  }

  return 0;
}


Measured memory_bytes: 4776
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <functional>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
  int N,M;cin>>N>>M;
  VI L(M);
  VI R(M);
  int max=100000;
  int min=-1;
  for(int i=0;i<M;i++){
    cin>>L[i];
    cin>>R[i];
  }
  for(int i=0;i<M;i++){
    if(min<=L[i]){
      min=L[i];
    }
    if(max>=R[i]){
      max=R[i];
    }
  }
  int ans=max-min+1;
  if(ans>=0){
    cout<<ans<<endl;
  }
  else{
    cout<<0<<endl;
  }
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
    static int count = 0;
    static int[] nums = {3, 5, 7};
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        helper(n, "3", 1, 0, 0);
        helper(n, "5", 0, 1, 0);
        helper(n, "7", 0, 0, 1);
        System.out.println(count);
    }
    private static void helper(int n, String strNum, int three, int five, int seven) {
        long num = Long.parseLong(strNum);
        if(num > n) return;
        if(three >= 1 && five >= 1 && seven >= 1) count++;
        helper(n, strNum + "3", three + 1, five, seven);
        helper(n, strNum + "5", three, five + 1, seven);
        helper(n, strNum + "7", three, five, seven + 1);
    }
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;

const int mod = 1e9+7;
const ll INF = 1e18;
const int MAX = 1e6;

// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visit[MAX]; // 訪問状況

int h, w;
char grid[1000][1000];
int dp[1000][1000];

int main() {
// input
    cin >> h;
    cin >> w;
    rep(i, h) {
        rep(j, w) {
            cin >> grid[i][j];
        }
    }
// solve
    rep(i, h) {
        rep(j, w) {
            if (grid[i][j] == '#') {
                dp[i][j] = 0;
            } else {
                if (i == 0 and j == 0) {
                    dp[i][j] = 1;
                } else {
                    if (i > 0) {
                        dp[i][j] += dp[i-1][j];
                    }
                    if (j > 0) {
                        dp[i][j] += dp[i][j-1];
                    }
                    dp[i][j] %= mod;
                }
            }
            // printf("%d ", dp[i][j]);
        }
        // printf("\n");
    }
    int ans = dp[h-1][w-1];
// output
    cout << ans << "\n";
}

Measured memory_bytes: 8460
s = input()
maximum = [(0, [()])]

s = tuple(s)
for i in range(1, len(s) + 1):
    j = i - 1
    while j >= 0:
        max_count, previous = maximum[j]
        if max_count < 0:
            j -= 1
            continue
        current = s[j:i]
        if any(p != current for p in previous):
            if len(maximum) == i + 1:
                mc, blocks = maximum[i]
                if mc == max_count + 1:
                    blocks.append(current)
                break
            else:
                maximum.append((max_count + 1, [current]))
        j -= 1
    else:
        if len(maximum) != i + 1:
            maximum.append((-1, []))
    assert len(maximum) == i + 1

print(maximum[-1][0])

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

int main() {
    int n, d;
    cin >> n >> d;
    vector<vector<int>> data(n, vector<int>(d));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> data.at(i).at(j);
        }
    }

    int count = 0;
    for (int i = 0; i < n - 1; i++){
        for (int j = i + 1; j < n; j++){
            int dist=0;
            for (int k = 0; k < d; k++){
                dist += (data.at(i).at(k) - data.at(j).at(k))*(data.at(i).at(k) - data.at(j).at(k));
            }
            int temp = (int)sqrt(dist);
            if(temp * temp == dist){
                count++;
            }
        }
    }

    cout << count << endl;

}

Measured memory_bytes: 256
/*
      author  : nishi5451
      created : 14.08.2020 23:34:29
*/

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


int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(),l.end());
    int sum = 0;
    rep(i,n-1) sum += l[i];
    if(sum>l[n-1]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);
		//出力
		Console.WriteLine(c+" "+a+" "+b);
	}
}

Measured memory_bytes: 13140
N = int(input())

dp = [None for _ in range(N+1)]
dp[0] = 0
for i in range(1, N+1):
    dp[i] = 100001
    p = 1
    while p <= i:
        dp[i] = min(dp[i], dp[i-p]+1)
        p *= 6
    p = 1
    while p <= i:
        dp[i] = min(dp[i], dp[i-p]+1)
        p *= 9

print(dp[N])

Measured memory_bytes: 3864
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
enum MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long H1, M1, H2, M2, K;
    scan(H1, M1, H2, M2, K);
    long L1 = H1 * 60 + M1;
    long L2 = H2 * 60 + M2;
    // dprint(H1, M1, H2, M2, K, L1, L2);
    writeln(max(0, L2 - L1 - K));
}


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

constexpr double esp = 10e-10;

int main(void){
    ll N; cin >> N;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    
    double digit = 0;
    ll ans = 1;
    for(int i=0;i<N;i++){
        digit += log10(A[i]);
        ans *= A[i];
    }


    if(18-digit < -esp || ans > 1000000000000000000LL){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}


Measured memory_bytes: 4108
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct{
  int id;
  int parent;
  int left;
  int right;
}Node;
void buildMaxHeap(Node *T,int n){
  int i;
  for(i=n/2;1<=i;i--){
    maxHeapify(T, i, n);
  }
}
int maxHeapify(Node *T,int i,int n){
  int l,r;
  int largest;
  Node A;
  
  l=2*i;
  r=2*i+1;
  if(l <= n && T[l].id > T[i].id){
    largest = l;
  }else largest = i;
  if(r <= n && T[r].id > T[largest].id){
    largest = r;
  }
  if(largest != i){
    A = T[i];
    T[i]=T[largest];
    T[largest]=A;
    maxHeapify(T, largest,n);
  }
}
int main(){
  int n,x;
  int i;
  Node *T;
  
  scanf("%d",&n);
  T=(Node*)malloc(sizeof(Node)*(n+1));
  for(i=1;i<=n;i++){//入力
    scanf("%d",&x);
    T[i].id=x;
    if(2*i<=n) T[2*i].parent=x;
    if(2*i+1<=n) T[2*i+1].parent=x;	
    if(i%2==0)T[i/2].left=x;
    else T[(i-1)/2].right=x;
  }
  buildMaxHeap(T,n);
  for(i=1;i<=n;i++){//出力
    printf(" %d",T[i]);
    }
  printf("\n"); 
  return 0;
}



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

int main() {
  int x; cin >> x;
  int t = 1e6;
  for (int i = x; i < t; i++) {
    bool f = true;
    for (int j = 2; j*j <= i; j++)
      if (i%j == 0) {
        f = false;
        break;
      }
      if(f) {
        cout << i;
        return 0;
      }
  }
  return 0;
}

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

string S;

ll dfs(int n, ll i, ll c) {
    if(n == S.size()-1) return i+c;
    ll res = 0;
    res += dfs(n+1, S[n+1]-'0', c+i)+dfs(n+1, i*10+S[n+1]-'0', c);
    return res;
}

int main() {
    cin >> S;
    cout << dfs(0,S[0]-'0',0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  //input
  string s;
  cin >> s;
  //end input

  //main
  bool ans;
  
  for (int i = 0; i < s.size(); i++) {
    if ((i + 1)%2 == 0) {
      if ( s.at(i) == 'L' ){
        ans = true;
      }
      else if ( s.at(i) == 'U' ){
        ans = true;
      }
      else if ( s.at(i) == 'D' ) {
        ans = true;
      }
      else {
        ans = false;
        break;
      }
    }
    else {
      if ( s.at(i) == 'R' ){
        ans = true;
      }
      else if ( s.at(i) == 'U' ){
        ans = true;
      }
      else if ( s.at(i) == 'D') {
        ans = true;
      }
      else {
        ans = false;
        break;
      }      
    }
  }

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


Measured memory_bytes: 256
#define _USE_MATH_DEFINES 
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <math.h>
#include <unordered_set>
#include <iomanip>
#include <cmath>
#include <set>
#include <locale>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;
//cout << fixed << setprecision(6);
//cout << setfill('0') << right << setw(2);

int main() {
  int a = 0;
  string s;
  cin >> s;
  rep(i, s.length()){
    if(s[i] == '0') a++;
    else a--;
  }
  cout << s.length() - abs(a) << endl;
}

Measured memory_bytes: 512
/*
______________________________
                              |
Shubham Singhal               |
                              |
CodeChef          torque      |
HackerEarth       torque      |
SPOJ              torque      |
HackerRank        torquecode  |
CodeForces        torquecode  |
______________________________| */


// If Tyrion dies, I am gonna riot :P


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

# define MOD         1000000007
# define gc          getchar
# define LL          long long
# define L           long
# define pb          push_back
# define mp          make_pair
# define vi          vector<int>
# define MAXN        100005
# define INF         1e9


int main()
{
    int n;
    cin>>n;
    int l[2*n],ans=0;
    for(int i=0;i<2*n;i++)
        cin>>l[i];
    sort(l,l+2*n);
    for(int i=0;i<2*n;i+=2)
        ans+=l[i];
    cout<<ans<<endl;
    return 0;
}


// Can a man still be brave if he's afraid?  That is the only time a man can be brave !!


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,n,N;
       scanf("%d",&N);
    for(n=1;n<=N;n++){
 
     scanf("%d %d %d",&a,&b,&c);
   
     if((a*a)+(b*b)==(c*c) || (a*a)+(c*c)==(b*b) || (b*b)+(c*c)==(a*a) )
         {  printf("YES\n");  }
       else
         {  printf("NO\n");   }
    }
 
    return 0;
}


Measured memory_bytes: 2048
n,a=int(input()),list(map(int,input().split()))
b=abs(a[0])
for i in range(n-1):b+=abs(a[i]-a[i+1])
b+=abs(a[-1])
print(b+abs(a[1])-abs(a[0])-abs(a[0]-a[1]))
for i in range(1,n-1):print(b+abs(a[i-1]-a[i+1])-abs(a[i-1]-a[i])-abs(a[i]-a[i+1]))
print(b+abs(a[-2])-abs(a[-1])-abs(a[-1]-a[-2]))

Measured memory_bytes: 14176
N = int(input())

mod = 10 ** 9 + 7


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


L = primes(N)

ans = [0] * (N + 1)
for i in range(2, N + 1):
    for j in L:
        if i < j:
            break
        while True:
            if i % j == 0:
                i //= j
                ans[j] += 1
            else:
                break

ans_num = 1
for i in range(2, N + 1):
    if ans[i] >= 1:
        ans_num *= ans[i] + 1 % mod
print(ans_num % mod)


Measured memory_bytes: 9252
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

void solve()
{
    LL X;
    cin >> X;
    LL Y;
    cin >> Y;

    LL ans = 0;

    while (X <= Y)
    {
        ans++;
        X *= 2;
    }

    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

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

using namespace std;
using ll = long long;

constexpr int MAXN = 105;
constexpr int MAXV = 100005;

int n;
ll w;
ll W[MAXN];
ll V[MAXN];
ll dp[MAXN][MAXV];

ll solve(int i, int val) {
  if (val == 0) {
    return 0;
  }
  if (i < 0) {
    return 1e13;
  }
  if (val < 0) {
    return 1e13;
  }
  ll& res = dp[i][val];
  if (res != -1) {
    return res;
  }
  return res = min(solve(i - 1, val), W[i] + solve(i - 1, val - V[i]));
}

int main() {
  cin >> n >> w;
  for (int i = 0; i < MAXN; i++) {
    for (int j = 0; j < MAXV; j++) {
      dp[i][j] = -1;
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> W[i] >> V[i];
  }
  int res = 0;
  for (int i = 0; i < MAXV; i++) {
    if (solve(n - 1, i) <= w) {
      res = i;
    }
  }
  cout << res << '\n';
  return 0;
}


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

using namespace std;

long long int a[3001];

int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }
  long long int res = 0;
  for(int i = 0; i < n; ++i){
    res += a[i] - 1;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N ,K = 0;  
  cin >> N;
  vector<int> p(N);
  
  for (int i = 0; i < N; i++) {
  cin >> p.at(i);
  if(p.at(i) == i + 1){
    K += 0;
  }
  else{
    K +=1;
  }
  }
if(K <3){
  cout << "YES" << endl;
}
else{
  cout << "NO" << endl;
}

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int ans=0,x=1;
		while(x<=N){
			String a=String.valueOf(x);
			if(a.length()%2==1)
				ans++;
			x++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 28372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int,int> vii;
typedef vector<ll,ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef set <int> :: iterator sitr;
typedef set <ll> :: iterator sltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef mset <int> :: iterator msitr;
typedef mset <ll> :: iterator msltr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
int n;
int main(){
    cin>>n;
    if(n==3 || n==5 || n==7){cout<<"YES\n";}
    else cout<<"NO\n";


}


Measured memory_bytes: 256
from collections import deque
n=int(input())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
ans=0
m=0
p=0
pl=deque()
for a,b in zip(al,bl):
    if a<b:
        m+=b-a
        ans+=1
    else:
        p+=a-b
        pl.append(a-b)
if m==0:
    print(0)
    exit()
if m>p:
    print(-1)
    exit()
pl=sorted(pl)
t=0
while t<m:
    t+=pl.pop()
    ans+=1
print(ans)

Measured memory_bytes: 18740
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=2e5+10;
vector<int>g[mx];
bool vis[mx];
void dfs(int u){
  vis[u]=true;
  for(int i=0;i<int(g[u].size());i++){
    int v=g[u][i];
    if(!vis[v]){
      dfs(v);
    }
  }
}
int main(){
  int n,m;
  scanf("%d %d",&n,&m);
  for(int i=0;i<n;i++){
    int cnt,x;
    scanf("%d",&cnt);
    for(int j=0;j<cnt;j++){
      scanf("%d",&x);
      g[i].push_back(x+n);
      g[x+n].push_back(i);
    }
  }
  dfs(0);
  bool ok=true;
  for(int i=0;i<n;i++)if(!vis[i])ok=false;
  if(ok)puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 8832