akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 1e7 + 9, OO = 1e9 + 7, MOD = 1e9 + 7, MOD2 = 998244353;
const ll inf = 1e18;

bool vis[N];
int ans[N];

int main() {
	fastIO;
#ifdef LOCAL
//	freopen("input.in", "rt", stdin);
#endif
	int n, m, l, val;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> l >> val;
		if(vis[l]) {
			if(val != ans[l]) {
				cout << -1;
				return 0;
			}
		} else {
			vis[l] = 1;
			ans[l] = val;
		}
	}
	if(n == 1 && ans[1] == 0) {
		cout << 0;
		return 0;
	}
	if(!vis[1])
		ans[1] = 1;
	if(ans[1] == 0) {
		cout << -1;
		return 0;
	}
	for (int i = 1; i <= n; ++i)
		cout << ans[i];
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
  int h,a,i,s=0,n;
  cin>>h>>a;
  for(i=0;i<a;++i)
  {
    cin>>n;
    s+=n;
  }
  if(s>=h)
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    int ans = INT_MAX;
    for(int i=0; i<n-2; ++i){
        int x = stoi(s.substr(i, 3));
        ans = min(ans, abs(x - 753));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) ll t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf LLONG_MAX
ll mult(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
ll fpow(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1LL)
			res = (res * x) % mod;
		y = y >> 1LL;
		x = (x * x) % mod;
	}
	return res;
}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2);}
bool sa(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.second < b.second);}
bool fd(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.first > b.first);}
bool sd(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.second > b.second);}
ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};
bool valid(ll x, ll y, ll n, ll m) {
	if (x < 0 || y < 0) {
		return false;
	}
	else if (x >= n || y >= m) {
		return false;
	}
	else
		return true;
}
#define MAXN 1000001
ll spf[MAXN];
void sieve()
{
	spf[1] = 1;
	for (ll i = 2; i < MAXN; i++)

		// marking smallest prime factor for every
		// number to be itself.
		spf[i] = i;

	// separately marking spf for every even
	// number as 2
	for (ll i = 4; i < MAXN; i += 2)
		spf[i] = 2;

	for (ll i = 3; i * i < MAXN; i++)
	{
		// checking if i is prime
		if (spf[i] == i)
		{
			// marking SPF for all numbers divisible by i
			for (ll j = i * i; j < MAXN; j += i)

				// marking spf[j] if it is not
				// previously marked
				if (spf[j] == j)
					spf[j] = i;
		}
	}
}
ll dp[3001][3001][2];
ll solve(ll *a, ll i, ll j, ll turn) {
	if (i > j)
		return 0;
	if (dp[i][j][turn] != -1)
		return dp[i][j][turn];
	if (turn == 1)
		return dp[i][j][turn] = max(a[i] + solve(a, i + 1, j, 0), a[j] + solve(a, i, j - 1, 0));
	else
		return dp[i][j][turn] = min(solve(a, i + 1, j, 1), solve(a, i, j - 1, 1));
}

int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	ll n;
	cin >> n;
	ll a[n];
	ll turn = 0, p1 = 0, p2 = 0;
	ll start = 0, end = n - 1;

	memset(dp, -1, sizeof dp);
	ll sum = 0;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	ll scoreX = solve(a, 0, n - 1, 1);
	ll scoreY = sum - scoreX;
	cout << scoreX - scoreY;
	return 0;
}


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

#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)

#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)

#define getI(a) scanf("%d", &a) //next three are handy ways to get ints, it's also force you to use '&' sign
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)

#define wez(n) int (n); scanf("%d",&(n)) //handy if the input is right after the definition of a variable
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))

#define whileZ int T; getI(T); while(T--)
#define lastEle(vec) vec[vec.size()-1]
#define SZ(x) ((int)((x).size()))

#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) // traverse an STL data structure

#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"

#define PRESENT(c,x) ((c).find(x) != (c).end())

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short

//for map, pair
#define mp make_pair
#define fi first
#define se second

// for debug
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,a.size()-1)

//for vectors
#define pb push_back
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;

int a[100005];

int main()
{
    wez3(n,k,s);

    FFE(i,n,1) a[i] = s;

    int ans = -1;
    F(i,2,(int)(sqrt(s))) {
        if (s%i) {
            ans = i;
            break;
        }
    } 
    if (ans==-1) {ans = s+1;}
    FE(i,k+1,n) a[i] = ans;

    FE(i,1,n) cout << a[i] << " ";

    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long
#define db long double
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define W while
#define fn(i,x) for(int i=0;i<x;i++)
#define fs(i,s,x) for(int i=s;i<x;i++)
#define fr(i,x) for(int i=x;i>=0;i--)
#define fit(it,s) for(auto it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 1000000007
#define MAX 1005
using namespace std;
bool cmp(pair<string,ll> a,pair<string,ll> b){
   if(a.fi==b.fi) return a.se > b.se;
   return a.fi < b.fi;
}
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    
    ll n;
    cin >> n;
    pair<string,ll> r[n];
    map<pair<string,ll>,ll > m;
    fn(i,n){
      cin >> r[i].fi >> r[i].se;
      m[r[i]] = i + 1;
    }
    sort(r,r+n,cmp);
    fn(i,n){
      cout << m[r[i]] <<"\n";
    }

    return 0;

}

Measured memory_bytes: 256
n,m,k = map(int, input().split())
arr1 = list(map(int,input().split()))
arr2 = list(map(int,input().split()))

acum1 = [0]
for i in range(n):
    acum1.append(acum1[-1]+arr1[i])

acum2 = [0]
for i in range(m):
    acum2.append(acum2[-1]+arr2[i])

ans = 0
j = m
for i in range(n+1):
    if acum1[i]>k:
        break
    while acum2[j] > k - acum1[i] and j > 0:
        j -= 1
    ans  = max(ans, i+j)

print(ans)

Measured memory_bytes: 47444
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

template <typename T>
class SegmentTree {
   public:
    SegmentTree(vector<T> &base, function<T(T, T)> fn_, T e_) {
        fn = fn_; e = e_;
        n = 1; while (n < base.size()) n *= 2;

        node.resize(2 * n - 1, e);
        REP(i, 0, base.size()) node[n - 1 + i] = base[i];
        for (int i = n - 2; i >= 0; i--) node[i] = fn(node[2 * i + 1], node[2 * i + 2]);
    }

    // 0-origin
    void update(int i, T x) {
        i += n - 1;
        node[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            node[i] = fn(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    // 0-origin, [a, b)
    int query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return e;
        if (a <= l && r <= b) return node[k];

        T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return fn(vl, vr);
    }

    void print(int w = 4) {
        int prev = 0;
        for (int i = 1; i <= n; i *= 2) {
            for (int j = prev; j < prev + i; j++) {
                cout << setw(n * w / i) << setfill(' ') << node[j];
            }
            cout << endl;
            prev += i;
        }
    }

   private:
    int n;
    vector<T> node;
    function<T(T, T)> fn;
    T e;
};

int main() {
    int N; cin >> N;
    vector<int> A(N + 2, 0);
    REP(i, 1, N + 1) cin >> A[i];

    SegmentTree<int> seg(A, [](auto l, auto r){ return __gcd(l, r); }, 0);
    int ans = 0;
    REP(i, 1, N + 1) {
        ans = max(ans, __gcd(seg.query(0, i), seg.query(i + 1, N + 2)));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    int a, b;
    cin >> a >> b;
    if (a < 10 && b < 10) cout << a * b << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	n, t := scanInt(), scanInt()
	b := scanInt()
	ans := 0
	for i := 0; i < n-1; i++ {
		x := scanInt()
		ans += min(x-b, t)
		b = x
	}
	ans += t
	fmt.Println(ans)
}


Measured memory_bytes: 3840
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

double solve(int n, double d1, double dSum, double x){
    double d2 = d1 + x, d2n_1 = d1 + (2 * n - 2) * x, d2n = d1 + (2 * n - 1) * x;
    cout<<n<<' '<<d1<<' '<<dSum<<endl;
    if(!n){ return 0; }
    return dSum / 2 / n + solve(n - 1, d1 + d1 / n + 5.0 / 2 / n * x, dSum - (d1 + d2 + d2n_1 + d2n) / 2 / n, x + 2 * x / n);
}

int main(){
	double n, d1, x, ans = 0;
	cin >> n >> d1 >> x;
    // cout << fixed << setprecision(10) << solve(n, d1, d1 * 2 * n + 2 * n * x * (2 * n - 1) / 2, x) << endl;

    // double dSum = d1 * 2 * n + 2 * n * x * (2 * n - 1) / 2;
    // while(n){
    //     ans += dSum / 2 / n;
    //     double d2 = d1 + x, d2n_1 = d1 + (2 * n - 2) * x, d2n = d1 + (2 * n - 1) * x;
    //     dSum -= (d1 + d2 + d2n_1 + d2n) / 2 / n;
    //     d1 += d1 / n + 5.0 / 2 / n * x;
    //     x += 2 * x / n;
    //     n--;
    // }

    d1 = d1 + d1 + x;
    x*= 4;
    double dSum = d1 * n + x * n * (n - 1) / 2;
    while(n){
        // cout<<d1<<' '<<dSum<<endl;
        ans += dSum / 2 / n;
        double dn = d1 + x * (n - 1);
        dSum -= (d1 + dn) / 2 / n;
        d1 += d1 / n + 3 * x / 2 / n;
        x += 2 * x / n;
        n--;
    }
    // cout<<dSum<<endl;
    cout << fixed << setprecision(10) << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        int min = x - k + 1;
        int max = x + k - 1;
        for (int i = min ; i <= max ; i++) {
            System.out.print(i);
            System.out.print(" ");
        }
    }

}


Measured memory_bytes: 21716
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $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("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      ws: [i64; n],
    }
    let mut ans = 1 << 32;
    for t in 0..n-1 {
        let s1: i64 = (&ws[0..t+1]).iter().sum::<i64>();
        let s2: i64 = (&ws[t+1..n]).iter().sum::<i64>();
        // debug!(t, s1, s2);
        ans = min(ans, (s1-s2).abs());
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//int v[100001],v1[100001];

int main()
{
    ll a,b,c,d,e;
    cin>>a>>b;
    c=a+b;
    d=a-b;
    e=a*b;
    cout<<max(c,max(d,e))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N,K;

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

  cin >> N >> K;
  double ans = 0;
  FOR(i,1,N+1) {
    int a = i;
    double p = 1;
    while (a < K) {
      a *= 2;
      p *= 0.5;
    }
    ans += (double)p/N;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<int> hs;
vector<int> ns;

int main(void) {
    int N, M;
    cin >> N >> M;

    hs.resize(N);
    ns.resize(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> hs[i];
    }

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        chmax(ns[a], hs[b]);
        chmax(ns[b], hs[a]);
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (hs[i] > ns[i]) {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

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

    vint ls;
    ls.push_back(1);
    ll tmp = 1;
    while (1) {
        tmp *= 6;
        if (tmp > n) break;
        ls.push_back(tmp);
    }
    tmp = 1;
    while (1) {
        tmp *= 9;
        if (tmp > n) break;
        ls.push_back(tmp);
    }
    sort(all(ls));
    vint dp(n+1, INF);
    dp[0] = 0;
    srep(i, n+1, 1) {
        rep(j, ls.size()) {
            if (i - ls[j] < 0) break;
            dp[i] = min(dp[i], dp[i-ls[j]]+1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 640
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y: return False
    #sizeの大きいほうがx
    if par[x] > par[y]: x,y = y,x
    par[x] += par[y]
    par[y] = x
    return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

n, m, k = map(int, input().split())
friend = [[] for _ in range(n)]
enemy = [[] for _ in range(n)]
par = [-1]*n


for _ in range(m):
    a, b = map(int, input().split())
    unite(a-1, b-1)
    friend[a-1].append(b-1)
    friend[b-1].append(a-1)
for _ in range(k):
    a, b = map(int, input().split())
    enemy[a-1].append(b-1)
    enemy[b-1].append(a-1)
ans = []
for i in range(n):
    block = 0
    for j in enemy[i]:
        if same(i, j): block += 1
    ans.append(size(i)-len(friend[i])-block-1)
print(*ans)

Measured memory_bytes: 50040
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum[2][300000], ans, dp[30][200000], a[200000], b[200000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<Edge>>vec;
vector<edge>ed;
vector<LL>v;
map<LL,LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
map<LL,LL> zip;
LL unzip[300000];

int compress(vector<LL> &x) {
	sort(x.begin(), x.end());
	x.erase(unique(x.begin(), x.end()), x.end());
	for (int i = 0; i < x.size(); i++) {
		zip[x[i]] = i;
		unzip[i] = x[i];
	}
	return x.size();
}

int main() {
	cin >> n >> m;
	rep(i, n) {
		cin >> a[i];
		v.push_back(a[i]);
		k += a[i];
	}
	rep(i, m) {
		cin >> b[i];
		v.push_back(b[i]);
	}
	v.push_back(0);
	compress(v);
	rep(i, n)a[i] = zip[a[i]], sum[0][a[i]]++, sum[1][a[i]] += unzip[a[i]];
	rep(i, m)b[i] = zip[b[i]];
	rep(i, 210000)sum[0][i + 1] += sum[0][i],sum[1][i + 1] += sum[1][i];

	rep(i, m) {
		ans += (n-sum[0][b[i]]) * unzip[b[i]] +sum[1][b[i]];
	}
	cout << ans << endl;
	return 0;
}
/*
 245
3
1
5
*/


Measured memory_bytes: 23400
//Volume2-0218
import java.util.*;

public class Main {

	public static void main(String[] args) {

		//declare
    	int    n,pm,pe,pj;
    	String ret;

    	//input
    	Scanner sc = new Scanner(System.in);
    	while(true){
    		n = sc.nextInt();
    		if(n == 0){break;}
    		while(n-- > 0){
    			pm = sc.nextInt();
    			pe = sc.nextInt();
    			pj = sc.nextInt();
    			
    			//calculate
    			if((pm == 100 || pe == 100 || pj == 100)||
 				  ((pm+pe)   /2 >= 90)||
 				  ((pm+pe+pj)/3 >= 80)){
    				ret = "A";
    			} else if(((pm+pe+pj)/3 >= 70) ||
    					 (((pm+pe+pj)/3 >= 50) &&
    					   (pm >= 80 || pe >= 80))){
    				ret = "B";
    			} else {
    				ret = "C";
    			}
    			
    			//output
    			System.out.println(ret);
    		}
    	}
	}
}

Measured memory_bytes: 28232
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)


ll modpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        ll h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

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

int main() {
    int K; cin >> K;
    int ans = K/2;

    if(K%2) ans *= ans + 1;
    else  ans *= ans;

    cout << ans << endl;

    return 0;
}


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

int main(void) {
    string S;

    cin>>S;

    int countC=0;
    int little=0;

    int leng = (int)S.size();

    if(S[0] != 'A') {
      cout<<"WA"<<endl;
      return 0;
    }

    for (int j=0;j<(int)S.size();j++){
      if(((j>=2)&&(j<((int)S.size()-1))) && (S[j] == 'C')) countC++;
      if(((int)S[j]>=97) && ((int)S[j]<=122)) little++;
    }

    if((countC==1) && ((leng-2) == little)) {cout<<"AC"<<endl;
    return 0;
}else{
     cout<<"WA"<<endl;
     return 0;}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;

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

    ll n, d = 0, sum = 0, tmp;
    cin >> n;
    while (true)
    {
        tmp = powl(26, d + 1);
        sum += tmp;
        d++;
        if (n <= sum)
            break;
    }
    string s = "";
    sum = n;
    for (ll i = 0; i < d; i++)
    {
        sum--;
        s += char('a' + sum % 26);
        sum /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl;
#define mod 1000000007
#define pb push_back
#define endl '\n'
#define mp make_pair
#define degreesToRadians(angleDegrees) (angleDegrees * M_PI / 180.0)
#define radiansToDegrees(angleRadians) (angleRadians * 180.0 / M_PI)



int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(0);
	long double a,b,h,m;
	cin>>a>>b>>h>>m;

	// long double ang1 = (m*6);  // in degree
	long double ang2 = 30*h + (long double)(m/2) - 6*m;
	ang2 = degreesToRadians(ang2);
	long double ans = a*a + b*b - (2*a*b*cos(ang2));

	cout<<fixed << setprecision(12)<<sqrtl(ans);


}



Measured memory_bytes: 4176
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int N = sc.nextInt();
		int C = sc.nextInt();
		int[][] table = new int[364364][C];
		for (int i = 0; i < N; i++) {
			int s = sc.nextInt() * 2;
			int t = sc.nextInt() * 2;
			int c = sc.nextInt() - 1;
			table[s - 1][c]++;
			table[t][c]--;
		}
		int[] cs = new int[table.length];
		for (int j = 0; j < C; j++) {
			for (int i = 1; i < table.length; i++) {
				table[i][j] += table[i - 1][j];
				if (table[i][j] > 0) cs[i]++;
			}
		}
		int max = 0;
		for (int i = 0; i < cs.length; i++) {
			max = Math.max(max, cs[i]);
		}

		out.println(max);
		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) return true;
		else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) return false;
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) return buffer[ptr++];
		return -1;
	}

	private boolean isPrintableChar(byte c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}

	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}
}

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



int main() {
	int N,C;
	string S;
	C = 1;

	cin >> N >> S;

	for (int i = 0; i < N-1; i++) {
		if (S.at(i) != S.at(i + 1)) {
			C++;
		}
	}
		cout << C << endl;

}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> bs(n-1);
    for(int i=0; i<n-1; i++) cin >> bs.at(i);

    int ans = bs.front() + bs.back();
    for(int i=0; i<n-2; i++)
    {
        ans += min(bs.at(i), bs.at(i+1));
    }
    cout << ans << '\n';

    return 0;
}


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

int a_max;

vector<bool> f(1e6 + 1, true);
vector<int> d(1e6 + 1, 0);
void sieve(void)
{
    rep(i, 1e6 + 1) d[i] = i;
    f[0] = false, f[1] = false;
    for (int i = 2; i * i <= a_max; ++i)
    {
        d[i] = min(d[i], i);
        if (f[i])
        {
            for (int j = 2 * i; j <= a_max; j += i)
            {
                f[j] = false;
                d[j] = i;
            }
        }
    }
}

map<ll, ll> prime_factory(int x)
{
    map<ll, ll> res;
    if (x == d[x])
        res[x]++;
    else
    {
        res[d[x]]++;
        for (auto i : prime_factory(x / d[x]))
            res[i.first] += i.second;
    }
    return res;
}

void solve(void)
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    a_max = *max_element(a.begin(), a.end());
    sieve();
    map<ll, ll> mp;
    rep(i, n)
    {
        for (auto i : prime_factory(a[i]))
            mp[i.first] += 1;
    }
    bool flag = true;
    bool flag_x = true;
    for (auto i : mp)
    {
        if (i.first == 1)
            continue;
        if (i.second > 1)
            flag = false;
        if (i.second == n)
            flag_x = false;
    }
    if (flag)
        cout << "pairwise coprime" << endl;
    else
    {
        if (flag_x)
            cout << "setwise coprime" << endl;
        else
            cout << "not coprime" << endl;
    }
}
int main(void)
{
    solve();

    // cin >> a_max;
    // sieve();
    // for (auto i : prime_factory(a_max))
    //     cout << i.first << " " << i.second << endl;
}

Measured memory_bytes: 20084
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace std;
#define ll long long int
#define ld long double
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> in_set;
#define rep(n) for(ll i=0;i<(n);i++)
#define jrep(n) for(ll j=0;j<(n);j++)
#define all(a) (a).begin(), (a).end()
#define dpp(a) cout<<(a).first<<" "<<(a).second<<endl;
#define append push_back
#define mod 1000000007
#define ff first
#define ss second
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fast ios::sync_with_stdio(0);
ll pw(ll x,ll y,ll p=mod){ll r=1; x=x%p;while(y>0){ if(y&1)r=(r*x)%p;
y=y>>1;x=(x*x)%p;} return r; } vector<ll> uniq(vector<ll> arr)
{vector<ll>brr;sort(all(arr));brr.append(arr[0]);
for(auto i:arr)if(brr.back()!=i)brr.append(i);return brr;}
 
void solve(){
    ld a; cin>>a; a/=3;
    cout<<std::setprecision (9)<<std::showpoint<<std::fixed<<a*a*a<<endl;
}
 
int main(){
    ffast
    ll t=1;
    //cin>>t;
    rep(t) solve();
}
 
 
// *p.find_by_order(n) : nth value (0 indexed)
// p.order_of_key(7): index of 7 (0 indexed)

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

using namespace std;

void solve() {
    long long n, d, count = 0;
    cin >> n >> d;

    for (int i = 0; i < n; ++i) {
        long long x, y;
        cin >> x >> y;

        if (x*x + y*y <= d*d)
            ++count;
    }

    cout << count << endl;
}

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

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    // cin >> t;

    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, x;
  cin >> n >> x;
  
  vector<int> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A.at(i);
  }
  
  int64_t ans = 0;
  int64_t c = 0;
  
  if(A.at(0) > x) {
    ans = abs(x - A.at(0));
    A.at(0) = x;
  }

  
  for (int i = 0; i < n-1; i++) {
    if (A.at(i) + A.at(i+1) > x) {
      c = A.at(i+1);
      A.at(i+1) = abs(x - A.at(i));
      ans += abs(c- A.at(i+1));

    }
  }
      


  
  cout << ans << endl;

  
 
}
             
 

Measured memory_bytes: 3768
package main

import (
        "fmt"
)

func solution(s string) string {
        const KEY = "keyence"
        if s == KEY {
                return "YES"
        }
        for i := 0; i < len(s); i++ {
                for j := i + 1; j < len(s); j++ {
                        if KEY == s[:i]+s[j:] {
                                return "YES"
                        }
                }
        }
        return "NO"
}

func main() {
        var s string
        fmt.Scan(&s)
        fmt.Println(solution(s))
}

Measured memory_bytes: 2024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < 3; ++i) {
        if (s[i]=='1') ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;

int n;
int a[100005];
int ans;
int flag;
int b[100005];
int ib;
int main()
{
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)
	{
		if(i==0||a[i]!=a[i-1])
		{
			b[ib]=a[i];
			ib++;
		}
	}
	if(ib<3)
	{
		cout<<1<<endl;
		return 0;
	}
	rep2(i,1,ib)
	{
		if(i==1)
		{
			if(b[i]>b[i-1])flag=1;
			else flag=0;
		}
		else
		{
			if(flag==1&&b[i]<b[i-1])
			{
				//cout<<i<<"w"<<endl;
				ans++;
				i++;if(i==ib)break;
				if(b[i]>b[i-1])flag=1;
				else flag=0;
				
			}
			else if(flag==0&&b[i]>b[i-1])
			{
				//cout<<i<<"e"<<endl;
				ans++;
				i++;if(i==ib)break;
				if(b[i]>b[i-1])flag=1;
				else flag=0;
			}
		}
	}
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll N, M;
    cin >> N >> M;

    ll from1[N + 1];
    ll toN[N + 1];
    REP(i, N){
        from1[i] = 0;
        toN[i] = 0;
    }

    ll a, b;
    rep(i, M){
        cin >> a >> b;
        if(a == 1){
            from1[b] = 1;
        }else if(b == 1){
            from1[a] = 1;
        }else if(a == N){
            toN[b] = 1;
        }else if(b == N){
            toN[a] = 1;
        }
    }

    bool possible = false;
    REP(i, N){
        if(from1[i] == 1 && toN[i] == 1){
            possible = true;
            break;
        }
    }

    if(possible){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 6532
#include<bits/stdc++.h>
using namespace std;
const long long int mod=1e9+7;
int main(){
    int n;
    cin >> n;
    int a;
    long long int ans=1;
    int r=0; int g=0; int b=0;
    for(int i=0;i<n;i++){
        cin >> a;
        ans *= ((a==r)+(a==g)+(a==b));
        ans %=mod;
        if(a==r)r++;
        else if(a==g)g++;
        else b++;
    }
    cout << ans;
}

Measured memory_bytes: 3636
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  int a;
  bool flag = true;
  rep(i,n){
    cin >> a;
    if(a%2 == 0){
      if(a%3 != 0 && a%5 != 0){
        printf("DENIED\n");
        return 0;
      }
    }
  }
  printf("APPROVED\n");
  return 0;
}


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

int main()
{
    int N, M, C;
    cin >> N >> M >> C;

    int B[ M ];
    for( int i=0 ; i<M ; i++ ) 
    {
        cin >> B[ i ];
    }

    int count = 0;
    int temp;

    for( int i=0 ; i<N ; i++ )
    {
        int sum=0;

        for( int j=0 ; j<M ; j++ ) 
        {
            cin >> temp;
            sum += temp * B[j];
        }

        if( 0 < (sum + C) ) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int x = sc.nextInt();
        boolean answer = false;
        outside:
        while (!answer) {
            for (int i = 2; i < x; i++) {
                if (x % i == 0) {
                    x++;
                    continue outside;
                }
            }
            answer = true;
        }
        System.out.println(x);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a,b,c=1;
	cin>>a>>b;
	fo(i,a){
	if(c<b)
		c*=2;
	else
		c+=b;
	}
	cout<<c<<endl;
}

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

using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll gcd(ll a, ll b) {//最大公約数
	if (a < b)swap(a, b);
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

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

int a[2010], b[2010], c[2010];
ll dist[2010];
bool judge[2010] = {false};

int main() {

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

	rep(i, m) {
		cin >> a[i] >> b[i] >> c[i];
		c[i] = -c[i]; //ベルマンフォード法を使うための準備
	}

	Fill(dist,linf);
	dist[1] = 0;

	rep(i,n -1) {
		rep(j, m) {
			if (dist[b[j]] == inf)continue;
			chmin(dist[b[j]], dist[a[j]] + c[j]);
		}
	}

	ll ans = dist[n];

	rep(i, n) {
		rep(j, m) {
			if (dist[a[j]] == inf)continue;
			
			if (dist[b[j]] > dist[a[j]] + c[j]) {
				chmin(dist[b[j]], dist[a[j]] + c[j]);
				judge[b[j]] = true;
			}
			if (judge[a[j]]) judge[b[j]] = true;
		}
	}

	if (judge[n])pr("inf");
	else pr(-ans);

	//system("pause");
	return 0;
}



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

using namespace std;

int a[105];

int main() {
    int n;
    scanf("%d", &n);

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

    int res = 1e9;

    for (int i = 1; i <= 100; i++) {
        int dist = 0;
        for (int j = 0; j < n; j++) {
            dist += (a[j] - i) * (a[j] - i);
        }
        res = min(res, dist);
    }

    printf("%d\n", res);
}


Measured memory_bytes: 3796
#include <iostream>
#include <vector>
using namespace std;
int ab(int x)
{
	if(x<0)
		return -1*x;
	return x;
}
int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> h;
	h.resize(n+1);
	int i,j;
	h[0] = -1000000;
	for(i=1;i<=n;i++)
		cin>>h[i];
	vector<int> mincost;
	mincost.resize(n+1);
	mincost[0] = 0;
	mincost[1] = 0;
	for(i=2;i<=n;i++)
	{
		mincost[i] = mincost[i-1] + ab(h[i]-h[i-1]);
		for(j=i-2;j>=max(i-k,0);j--)
			mincost[i] = min(mincost[i],mincost[j] + ab(h[i]-h[j]));
	}
	cout<<mincost[n]<<endl;
	return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n, d = input_to_int_map()
    xy = [input_to_int_tuple() for i in range(n)]

    import  math

    cnt = 0
    for x, y in xy:
        distnce = math.sqrt((x ** 2) + (y ** 2))
        if distnce <= d:
            cnt += 1

    print(cnt)

if __name__ == "__main__":
    main()


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

int main(){
  int a, b, k, i, count = 0, divisor;
  cin >> a >> b >> k;
  for(i = 100; i >= 1; i--){
    if(a%i == 0 && b%i == 0){
      divisor = i;
      count++;
    }
    if(count == k){
      cout << divisor << endl;
      return 0;
    }
  }
}


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

signed main () {

    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if ( c-1 <= a+b ) {
        b += c;
    }
    else {
        b += a+b+1;
    }
    printf("%d\n", b);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
vector<int>v[100005];
int u[100005];
int ans[100005];
int n,m;
void bfs(){
	u[0]=1;
	queue<int>q;
	q.push(0);
	while (sz(q)){
		int fr=q.front();
		q.pop();
		for (int i=0;i<sz(v[fr]);i++)
			if (!u[v[fr][i]]){
				u[v[fr][i]]=1;
				ans[v[fr][i]]=fr;
				q.push(v[fr][i]);
			} 
	}
}
signed main()
{
	cin>>n>>m;
	for (int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		v[a].pb(b);
		v[b].pb(a);
	}
	bfs();
	cout<<"Yes"<<endl;
	for (int i=1;i<n;i++){
		if (i-1)  puts("");
		cout<<ans[i]+1;
	}
	re 0;
}

Measured memory_bytes: 13744
#include<iostream>
#include<string>

using namespace std;

bool check(string str)
{
	for (int i = 0; i < str.size() / 2; i++) {
		if (str[i] != str[str.size() - i - 1])
			return false;
	}
	return true;
}

int main()
{
	string str,sub;
	cin >> str;
	int n = str.size();

	if (!check(str)) {
		cout << "No" << endl;
		return 0;
	}
	sub = str.substr(0, n/2);
	//cout << sub << endl;
	if (!check(sub)) {
		cout << "No" << endl;
		return 0;
	}
	sub = str.substr((n+3)/2-1, n/2);
	//cout << sub << endl;
	if (!check(sub)) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;

}

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

int main() {
    long long n;
    cin >> n;
    vector<long long> l(n+1);
    l.at(0)=2;
    l.at(1)=1;
    for(long long i=2;i<=n;i++){
        l.at(i)=l.at(i-1)+l.at(i-2);
    }
    cout << l.at(n) << endl;
}

Measured memory_bytes: 256