akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
int n,i,j,A[2000000],x,y;
int fa[2000000],fir[2000000],top,ne[5000000],la[5000000],to[5000000];
bool lost[2000000],win[2000000];
inline void add(int x,int y)
{
	top++,to[top]=y;
	if(fir[x]==0)fir[x]=top;else ne[la[x]]=top;
	la[x]=top;
}
void dfs(int x)
{
	win[x]=false;
	for (int i=fir[x];i;i=ne[i])
	if(to[i]!=fa[x])
	{
		fa[to[i]]=x;
		dfs(to[i]);
		if(win[to[i]]==false&&A[x]>A[to[i]])win[x]=true;
	}
}
void dfs2(int x)
{
	for (int i=fir[x];i;i=ne[i])
	if(to[i]!=fa[x])
	{
		if(win[x]==false&&A[to[i]]>A[x])win[to[i]]=true;
		dfs2(to[i]);
	}
}
inline int read()
{
    char ch=getchar();int ret=0,flag=1;
    while(ch<'0'||ch>'9') {if(ch=='-') flag=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
    return ret*flag;
}
int main()
{
	n=read();
	for (i=1;i<=n;i++)A[i]=read();
	for (i=1;i<n;i++)x=read(),y=read(),add(x,y),add(y,x);
	fa[1]=0;
	dfs(1);
	dfs2(1);
	for (i=1;i<=n;i++)if(win[i])printf("%d ",i);
	return 0;
}

Measured memory_bytes: 12544
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int save=0;
bool first;
int main()
{
    int n,q;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    cin>>q;
    for(int i=0;i<q;i++)
    {
        int index;
        cin>>index;
        first=false;
        for(int j=save;j<n;j++)
        {
            if(a[j]>=index&&first==false)
            {
                cout<<j<<endl;
                first=true;
                 save=j;
                 break;
            }
        }
        if(first==false)
            {
                cout<<n<<endl;
                save=n;
            }
    }
    return 0;
}



Measured memory_bytes: 3468
#include<iostream>
#include<cctype>
#include<vector>
#include <ctype.h>
#include<algorithm>
#include<queue>
#include<string>
#include <math.h>
#include <iomanip>
using namespace std;
long long p=1;
int n;
int main() {
	cin >> n;
	for (size_t i = 1; i < n+1; i++)
	{
		p =p*i;
		p =p%1000000007;
	}
	cout << p<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int n; cin>> n;
  vector<vector<int>> v;
  for(int i=0; i<n-1;++i){
    vector<int> vt(3);
    cin >> vt[0]>>vt[1]>>vt[2];
    v.push_back(vt);
  }
  for(int j=0;j<n-1;++j){
    int s = v[j][0] + v[j][1];
    if(j<n-2){
      for(int k=j+1;k<n-1;++k){
        if (s<v[k][1]){
          s= v[k][1];
        } else {
          int t = s/v[k][2];
          if(s%v[k][2] !=0) ++t;
          s= t*v[k][2];
        }
        s+=v[k][0];
      }
    }
    cout << s << endl;
  }
  cout << 0 << endl;
  return 0;
}

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

const int MAX_N = 300000;

int main() {
	int N;
	std::string S;
	std::cin >> N >> S;

	std::vector<int> left(MAX_N), right(MAX_N), cost(MAX_N);
	int cnt;

	cnt = 0;
	for(int i = 0; i < N; ++i) {
		left[i] = cnt;
		if(S[i] == 'W') ++cnt;
	}

	cnt = 0;
	for(int i = N - 1; i >= 0; --i) {
		right[i] = cnt;
		cost[i] = left[i] + right[i];
		if(S[i] == 'E') ++cnt;
	}

	std::sort(cost.begin(), cost.begin() + N);

	std::cout << cost[0] << std::endl;
 }


Measured memory_bytes: 4228
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define P pair<int, int>
#define Pl pair<ll, ll>
#define dvec vector<vector<ll>>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
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;}
ll INF = 1e+18;
int iINF = 1e9;



int main()
{
  int N; cin >> N;
  vector<vector<int>> arr(N, vector<int>(N));
  rep(i, 0, N) rep(k, 0, N) cin >> arr[i][k];
  vector<vector<int>> dp((1 << N), vector<int>(N + 1, 0));
  dp[0][0] = 1;

  rep(i, 0, N){
    for(int bit = 0; bit < (1 << N); ++bit){
      if(dp[bit][i] == 0) continue;
      rep(k, 0, N){
        if(arr[i][k] && (bit & (1 << k)) == 0){
          dp[bit | (1 << k)][i + 1] += dp[bit][i];
          dp[bit | (1 << k)][i + 1] %= MOD;
        }
      }
    }
  }

  cout << dp[(1 << N) - 1][N] << endl;
}


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

h = n = w = 1
for h in range(1, 3501):
    Nh = N*h
    for n in range(1, 3501):
        div = 4*h*n - N*n - Nh
        if div <= 0:
            continue
        if (Nh*n)%div==0:
            print(h,n,(Nh*n)//div)
            exit()


Measured memory_bytes: 40412
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String a = sc.next();

    if (a.equals("AAA") || a.equals("BBB")) {
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }
  }
}


Measured memory_bytes: 23892
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC125B
{
    class MainClass
    {

        static int[] v;
        static int[] n;

        static int[] c;
        public static void Main(string[] args)
        {

            n = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            v = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            c = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);

            var div = new List<int>();
            for(int i = 0; i < n[0]; i++)
            {
                div.Add(v[i] - c[i]);
            }

            int ans = 0;

            foreach(int item in div)
            {
                if (item > 0)
                {
                    ans += item;
                }
            }
            Console.WriteLine(ans);


        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi a(n), b(n), c(n);
    rep(i,n) cin >> a.at(i) >> b.at(i) >> c.at(i);
    // 幸福度の最大値と、選択した項目との2つを持つ必要がある
    vvi happy(n, vector<int64_t>(3));
    happy.at(0).at(0) = a.at(0);
    happy.at(0).at(1) = b.at(0);
    happy.at(0).at(2) = c.at(0);
    int64_t plan1, plan2, cmax;
    for(int64_t i=1; i<n; i++){
        plan1 = happy.at(i-1).at(1) + a.at(i);
        plan2 = happy.at(i-1).at(2) + a.at(i);
        happy.at(i).at(0) = max(plan1, plan2);

        plan1 = happy.at(i-1).at(0) + b.at(i);
        plan2 = happy.at(i-1).at(2) + b.at(i);
        happy.at(i).at(1) = max(plan1, plan2);

        plan1 = happy.at(i-1).at(0) + c.at(i);
        plan2 = happy.at(i-1).at(1) + c.at(i);
        happy.at(i).at(2) = max(plan1, plan2);
    }
    vi res = happy.at(n-1);
    sort(res.begin(), res.end(), greater<>());
    cout << res.at(0) << endl;
}

Measured memory_bytes: 8064
import itertools


n,m,x = map(int,input().split())


skills = [list(map(int,input().split())) for _ in range(n)]


zero_one_list = list(itertools.product(range(2), repeat=n))


money_list = []

for z in zero_one_list:
    sum_skills = [0] * m
    sum_money = 0
    for i in range(n):
        if z[i] == 1:
            sum_money += skills[i][0]
            sum_skills = [x + y for (x,y) in zip(sum_skills,skills[i][1:])]
        else:
            continue

    if (all(elem >= x for elem in sum_skills)):
        money_list.append(sum_money)
    else:
        continue

if money_list == []:
    print(-1)
    exit()
else:
    print(min(money_list))
    exit()


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

int countdivisors(int n)
{
  int ans=0;
  for(int i=1;i<=n;i++)
    if(n%i==0)
      ans++;
  return ans;
}
int main()
{
  int n,ans=0;
  cin>>n;
  for(int i=1;i<=n;i+=2)
  {
    if(countdivisors(i)==8)
      ans++;
  }
  cout<<ans<<"\n";
  
  
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        List<Integer> list = new ArrayList<>();

        while (!list.contains(0)) {
            list.add(sc.nextInt());
        }

        for (int i = 0; i < list.size() - 1; i++) {
            System.out.println("Case " + (i + 1) + ": " + list.get(i));
        }

        sc.close();
    }
}


Measured memory_bytes: 45444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll n,m,x,ans=INF,c[15],ch[15][15];
bool ANS,re[15];

void cal(){
	ll sk[15];
	ll cnt=0;
	for(ll i=0;i<m;i++){
		sk[i]=0;
	}
	for(ll i=0;i<n;i++){
		if(re[i]){
			cnt+=c[i];
			for(ll j=0;j<m;j++){
				sk[j]+=ch[i][j];
			}
		}
	}
	for(ll i=0;i<m;i++){
		if(sk[i]<x){
			return;
		}
	}
	ANS=true;
	ans=min(ans,cnt);
}
void dep(ll now){
	if(now==n){
		cal ();
		return;
	}
	re[now]=0;dep(now+1);
	re[now]=1;dep(now+1);
}
int main() {
	cin>>n>>m>>x;
	for(ll i=0;i<n;i++){
		cin>>c[i];
		for(ll j=0;j<m;j++){
			cin>>ch[i][j];
		}
	}
	dep(0);
	if(ANS==false){
		cout << -1;
	}
	else{
		cout <<ans;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
  long long X;
  long long ans = 0;
  
  scanf("%lld", &X);
  
  if(X == 6) {
    printf("1\n");
    return 0;
  }
  ans = 2 * (X / 11);
  
  if(X % 11 == 0) ;
  else if(X % 11 <= 6) ans++;
  else ans += 2; 
  
  printf("%lld\n", ans);
  
  return 0;
}

Measured memory_bytes: 128
n=int(input())
t=list(map(int,input().split()))
m=int(input())
l=[list(map(int, input().split())) for i in range(m)]
#print(l)

for i in range(m):
    print(l[i][1]+sum(t[:l[i][0]-1])+sum(t[l[i][0]:]))



Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
//using Graph = vector<vector<int>>;


const int MOD = 1000000007;
typedef pair<int,int> P;

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

}

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

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}









int main() {
 string s;
 cin >> s;
 ll sum = 0;
 rep (i,s.size()){
   sum += s[i]-'0';
 }
 if (sum % 9 == 0) cout << "Yes" << endl;
 else cout << "No" << endl;
}


Measured memory_bytes: 3836
import java.util.Arrays;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			@SuppressWarnings("unchecked")
			Set<Integer>[] sets = new Set[m];
			IntStream.range(0, m).forEach(i -> {
				int k = scanner.nextInt();
				sets[i] = IntStream.range(0, k).map(j -> scanner.nextInt()).boxed().collect(Collectors.toSet());
			});
			int[] p = IntStream.range(0, m).map(i -> scanner.nextInt()).toArray();
			int[] counts = new int[m];
			System.out.println(IntStream.range(0, 1 << n).filter(i -> {
				Arrays.fill(counts, 0);
				IntStream.range(0, n).filter(j -> (i & (1 << j)) > 0).forEach(j -> {
					IntStream.range(0, m).forEach(k -> counts[k] += sets[k].contains(j + 1) ? 1 : 0);
				});
				return m == IntStream.range(0, m).filter(j -> p[j] == (1 & counts[j])).count();
			}).count());
		}
	}
}


Measured memory_bytes: 41096
import sys


def solve(inp):
    N = int(inp.readline())
    D = [int(inp.readline()) for i in range(N)]

    nums = {}
    for d in D:
        if d not in nums:
            nums[d] = 0
        nums[d] += 1

    r = 0
    for n in nums:
        if n > 0:
            r += 1

    return str(r)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
pub struct ProconReader<R: std::io::Read> {
    reader: R,
}

impl<R: std::io::Read> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self { reader }
    }
    pub fn get<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&byte| byte == b' ' || byte == b'\n' || byte == b'\r')
            .take_while(|&byte| byte != b' ' && byte != b'\n' && byte != b'\r')
            .collect::<Vec<_>>();
        std::str::from_utf8(&buf)
            .unwrap()
            .parse()
            .ok()
            .expect("Parse Error.")
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());

    let n: usize = rd.get();
    let a: Vec<i64> = (0..n).map(|_| rd.get()).collect();
    let mut b = a[0];
    let mut ans = 0;
    for i in 1..n {
        if b > a[i] {
            ans += b - a[i];
        }
        b = std::cmp::max(b, a[i]);
    }
    println!("{}", ans);
}

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

int main() {
  int N, M;
  cin >> N >> M;
  map<int, int> MA;
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int i = 0; i < K; i++) {
      int A;
      cin >> A;
      MA[A]++;
    }
  }
  int cnt = 0;
  for (auto ma : MA) if (ma.second == N) cnt++;
  cout << cnt << "\n"; 
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

template<size_t max_N, size_t prime_size>
struct Prime{
    bool sieve[max_N];
    int_fast64_t prime[prime_size];
    size_t counter = 0;
    constexpr Prime() : sieve(), prime() {
        for(int_fast64_t i = 0; i < max_N; ++i)
            sieve[i] = true;
        sieve[0] = sieve[1] = false;
        for(int_fast64_t i = 2; i < max_N; ++i){
            if(sieve[i]){
                prime[counter] = i;
                ++counter;
                if(counter > prime_size)break;
            }
            for(int_fast64_t j = i * i; j < max_N; j += i)
                sieve[j] = false;
        }
    }
};

Prime<1000001, 78498> prime;

ll N, A[10001];
map<ll, int> B;

void append(ll x) {
    ll f = 2;
    while(x > 1) {
        int c = 0;
        if(prime.sieve[x]) f = x;
        while(x % f == 0) {
            x /= f;
            c++;
        }
        if(c > 0) {
            if(B.find(f) == B.end()) {
                B[f] = c;
            } else {
                B[f] = max(B[f], c);
            }
                
        }
        f++;
    }
}

int main() {
    fastio();
	cin >> N;
	REP(i, N) {
	    cin >> A[i];
        append(A[i]);
	}
    ll num = 1;
	for(auto e : B) {
	    REP(i, e.second) num = (num * e.first) % MOD;
	}
	ll ans = 0;
    REP(i, N) {
        ans += (num * modpow(A[i], MOD - 2)) % MOD;
    // 	cerr << num << " " << A[i] << endl;
    }
    cout << ans % MOD << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <vector>
#include <cmath>

struct coor{ long double x, y;};
class smallest_enclosing_circle{
private:
    std::vector<coor> points;
    coor c;
    long double r;

    long double dist(coor P, coor Q) const {
        long double dx = P.x - Q.x;
        long double dy = P.y - Q.y;
        return std::sqrt(dx*dx + dy*dy);
    }

    long double max_dist(long double x, long double y){
        long double res = 0;
        coor P = {x, y};
        for(coor& Q : points){
            res = std::max(res, dist(P, Q));
        } 
        return res;
    }

    long double min_y(long double x){
        long double left = 0, right = 1000;
        for(int i = 0; i < 100; i++){
            long double y1 = (left*2 + right) / 3.0;
            long double y2 = (left + right*2) / 3.0;

            if(max_dist(x, y1) > max_dist(x, y2)) left = y1; 
            else right = y2;
        }
        return left; 
    }

public:
    smallest_enclosing_circle() = delete;
    smallest_enclosing_circle &operator=(const smallest_enclosing_circle) = delete;
    smallest_enclosing_circle(std::vector<coor>&& p) : points(p) {}
    void solve(){
        long double left = 0, right = 1000;
        for(int i = 0; i < 100; i++){
            long double x1 = (left*2 + right) / 3.0;
            long double x2 = (left + right*2) / 3.0;

            long double y1 = min_y(x1);
            long double y2 = min_y(x2);

            if(max_dist(x1, y1) > max_dist(x2, y2)) left = x1;
            else right = x2;
        }

        long double x = left;
        long double y = min_y(x);

        c = {x, y};
        r = max_dist(x, y);
    }

    coor center(){ return c; }
    long double radius(){ return r; }
};

#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    int N;
    cin >> N;

    vector<coor> points(N);
    for(int i = 0; i < N; i++){
        long double x, y;
        cin >> x >> y;
        points[i] = {x, y};
    }

    smallest_enclosing_circle Sec(std::move(points));
    Sec.solve();

    cout << setprecision(12) << Sec.radius() << endl; 
}

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

int main() {
  int N, ans = 0;
  string A, B, C;
  cin >> N >> A >> B >> C; 
  for(int i = 0; i < N; i++) {
    if(A[i] != B[i] && B[i] != C[i] && A[i] != C[i]) ans+=2;
    else if(A[i] != B[i])ans++;
    else if(A[i] != C[i])ans++;
    else if(B[i] != C[i])ans++;
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 1000000000

int main() {
    int n,k,x,y,ans;
    cin >> n >> k >> x >> y;
    ans = min(k,n)*x+max(0,n-k)*y;
    cout << ans << endl;
}

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

int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
import java.util.Scanner;

class Main{

public static void main(String args[]){

Scanner scan =new Scanner(System.in);

int w =scan.nextInt();

int h =scan.nextInt();

int x =scan.nextInt();

int y =scan.nextInt();

int r =scan.nextInt();


if(h>=y+r && w>=x+r && x-r>=0 && y-r>=0){System.out.println("Yes");}

else {System.out.println("No");}

}}


Measured memory_bytes: 26352
import sys
sys.setrecursionlimit(10**9)

n, m = map(int, input().split())
E = [[] for _ in range(n)]

for _ in range(m):
	u, v = map(int, input().split())
	E[u].append(v)
	E[v].append(u)

color = [None]*n
cnt = 0 # now color

def dfs(v)->bool:
	if color[v] is not None: return False
	color[v] = cnt
	for nv in E[v]:
		if color[nv] is not None: continue
		dfs(nv)
	return True

for v in range(n):
	cnt += dfs(v)

q = int(input())
for _ in range(q):
	u, v = map(int, input().split())
	print("yes" if color[u]==color[v] else "no")



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

const long INF = 1e18;
int n, m;
int A[1000];
int B[1000];
long DP[1 << 12];
long sub() {
  for (int s = 1; s < (1 << n); ++s) {
    DP[s] = INF;
  }
  
  for (int j = 0; j < m; ++j) {
    for (int s = 0; s < (1 << n); ++s) {
      int t = s | B[j];
      DP[t] = min(DP[t], DP[s] + A[j]);
    }
  }
  
  return DP[(1 << n) - 1];
}

int main() {
  cin >> n >> m;
  for (int j = 0; j < m; ++j) {
    int k;
    cin >> A[j] >> k;
    for (int p = 0; p < k; ++p) {
      int a;
      cin >> a;
      --a;
      B[j] |= 1 << a;
    }
  }
  
  long ans = sub();
  cout << (ans == INF ? -1 : ans) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int count(vector<vector<bool>>& map, int n, int m, int i, int j)
{
	int ans = 0;
	FOR_LT(x, 0, n) {
		if (i & (1 << x)) continue;
		FOR_LT(y, 0, m) {
			if (j & (1 << y)) continue;
			if (map[x][y]) ans++;
		}
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, m, k; cin >> n >> m >> k;
	vector<vector<bool>> map(n, vector<bool>(m));

	FOR_LT(x, 0, n) {
		FOR_LT(y, 0, m) {
			char c; cin >> c;
			if (c == '#') map[x][y] = true;
		}
	}

	int ans = 0;
	FOR_LT(i, 0, (1 << n)) {
		FOR_LT(j, 0, (1 << m)) {
			if (count(map, n, m, i, j) == k) ans++;
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

const int M = 1000000007;

ll h, w, a, b, ans;
ll fac[200005];
ll inv[200005];

ll pow(ll p, ll q) {
    ll re = 1;
    for(; q; q >>= 1, p = p * p % M) {
        if(q&1) re = re * p % M;
    }
    return re;
}

int main()
{
    scanf("%lld%lld%lld%lld", &h, &w, &a, &b);
    fac[0] = 1;
    for(ll i = 1; i <= 200000; i++) fac[i] = fac[i - 1] * i % M;
    inv[200000] = pow(fac[200000], M - 2);
    for(ll i = 199999; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % M;
    for(ll i = b; i < w; i++)
    {
        ll h1 = h - a - 1;
        ll t1 = fac[h1 + i] * inv[h1] % M * inv[i] % M;
        ll h2 = a - 1;
        ll t2 = fac[h2 + w - i - 1] * inv[h2] % M * inv[w - i - 1] % M;
        ans += t1 * t2;
        ans %= M;
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 3328
def main():
	sx, sy, tx, ty = map(int, input().split())
	dx = tx-sx
	dy = ty-sy
	ans = ""
	offset_x = ["", "R", "L"]
	offset_y = ["", "U", "D"]
	def move(x, y):
		res = ""
		if y != 0:
			res += offset_y[y//abs(y)]*abs(y)
		if x != 0:
			res += offset_x[x//abs(x)]*abs(x)
		return res

	ans += move(dx, dy)
	ans += move(-dx, -dy)
	ans += move(-dx//abs(dx), 0)
	ans += move((dx//abs(dx))*(abs(dx)+1), (dy//abs(dy))*(abs(dy)+1))
	ans += move(dx//abs(dx), -dy//abs(dy))
	ans += move((-dx//abs(dx))*(abs(dx)+1), (-dy//abs(dy))*(abs(dy)+1))
	ans += move(0, dy//abs(dy))

	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(M)]

    g = defaultdict(list)

    for n in ab:
        g[n[0]].append(n[1])

    if 1 not in g:
        print('IMPOSSIBLE')
        exit()

    for i in g[1]:
        if i not in g:
            continue
        for j in g[i]:
            if j == N:
                print('POSSIBLE')
                exit()

    print('IMPOSSIBLE')


if __name__ == "__main__":
    main()


Measured memory_bytes: 66920
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<int> v(3);
    for (auto& x: v) cin >> x;
    sort(v.begin(), v.end());
    for (int i = 0; i < 3; i++) {
        if (i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<limits>
#include<deque>
#include<string>
#include<map>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>

using namespace std;


int main() {
	long long int a, b, c; cin >> a >> b >> c;

	if (b >= c) {
		cout << b + c << endl; return 0;
	}
	else if (b < c) {
		long long int ans = 2 * b + 1;
		c = c - (b + 1);
		if (a >= c) { ans += c; }
		else { ans +=a; }
		cout << ans << endl; return 0;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

double graph[1002][1002];
double dist(pair<double, double> p1, pair<double, double> p2){
    return sqrt(pow(p1.first-p2.first, 2)+pow(p1.second-p2.second, 2));
}

int main ()
{
  prep();
  double sx, sy, fx, fy;
  cin >> sx >> sy >> fx >> fy;
  int n;
  cin >> n;
  tuple<double, double, double> before[n];
  for (int i=1; i<=n; i++){
      double x, y, r;
      cin >> x >> y >> r;
      for (int j=1; j<i; j++){
          tuple<double, double, double> p = before[j-1];
          double distt = dist({get<0>(p), get<1>(p)}, {x, y});
          graph[i][j] = max(distt-get<2>(p)-r, 0.0);
          graph[j][i] = max(distt-get<2>(p)-r, 0.0);
      }
      before[i-1] = tuple<double, double, double> (x, y, r);
  }
  for (int j=1; j<=n; j++){
      tuple<double, double, double> p = before[j-1];
      double distt = dist({get<0>(p), get<1>(p)}, {sx, sy});
      double distt2 = dist({get<0>(p), get<1>(p)}, {fx, fy});
      graph[0][j] = max(distt-get<2>(p), 0.0);
      graph[j][0] = max(distt-get<2>(p), 0.0);
      graph[n+1][j] = max(distt2-get<2>(p), 0.0);
      graph[j][n+1] = max(distt2-get<2>(p), 0.0);
  }
  graph[0][n+1] = dist({sx, sy}, {fx, fy});
  graph[n+1][0] = dist({sx, sy}, {fx, fy});
  // from 0 to n+1
  int q[100001];
  int cur = 1;
  q[0] = 0;
  double curdist[n+2];
  for (int i=0; i<=n+1; i++){
      curdist[i] = 1000000000000000001.0;
  }
  curdist[0] = 0;
  while (cur != 0){
      int node = q[cur-1];
      cur--;
      
      for (int i=1; i<=n+1; i++){
         
          if (curdist[node]+graph[node][i] < curdist[i]){
              q[cur] = i;
              cur++;
              curdist[i] = curdist[node]+graph[node][i];
          }
      }
  }
  printf("%.9lf", curdist[n+1]);
  return 0; 
}

Measured memory_bytes: 8192
var a: array[1..1000] of longint;
    dp, p: array[-10..150, -110000..200000] of longint;    
    i, j, N, K: longint;
begin
    readln(N, K);
    for i:=1 to N do
        read(a[i]);
    for i:=0 to a[1] do
    begin
        dp[1,i]:=1;
    end;
    for i:=0 to K do
        p[1,i]:=p[1,i-1]+dp[1,i];
    for i:=2 to N do
    begin
        for j:=0 to K do
        begin
            dp[i,j]:=(p[i-1,j]-p[i-1,j-a[i]-1]) mod 1000000007;
            if dp[i,j]<0 then
                dp[i,j]:=dp[i,j]+1000000007;
            p[i,j]:=(p[i,j-1]+dp[i,j]) mod 1000000007;
//            write(dp[i,j], ' ');
        end;
//        writeln;
    end;
    writeln(dp[N,K]);
end.

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

using namespace std;

const int maxn = 20;
const int INF = 1e9 + 100;

int a[1500][1500];

int main() {
    //freopen("input", "r", stdin);
    //freopen("output", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, m, d;
    cin >> n >> m >> d;
    for (int i = 0; i < n + m; ++i) {
        for (int j = 0; j < n + m; ++j) {
            a[i][j] = ((i / d) % 2) + (((j / d) % 2) * 2);
        }
    }
    string s = "RBGY";
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            int x = i + j;
            int y = n - i + j;
            cout << s[a[x][y]];
        }
        cout << endl;
    }

    return 0;
}


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

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define REP(i,n) for(ll i = 1; i < (n); i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n")
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1; 


signed main(){

  ll n, y;
  cin >> n >> y;
  for(ll i = 0; i <= n; i++){
    for(ll j = 0; j <= n-i; j++){
      ll k = n-(j+i);
      if(i*10000 + j*5000 + k*1000 == y){
        printf("%lld %lld %lld\n",i,j,k);
        return 0;
      }
    }
  }
  printf("-1 -1 -1");
}

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

//{{{
/********************************************************************/
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)
#define endl '\n'

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int H, int W) { return y >= 0 && x >= 0 && y < H && x < W; }
inline int in() { int x; std::cin >> x; return x; }
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << '\n';
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

/****************************************************************/
//}}}

signed main()
{
  int n = in();
  deque<int> d;

  for (int i = 0; i < n; i++) {
    if (n % 2) {
      if (i % 2 == 0) d.push_front(in());
      else d.push_back(in());
    }
    else {
      if (i % 2) d.push_front(in());
      else d.push_back(in());
    }
  }
      
  printf("%d", d[0]);
  for (int i = 1; i < n; i++) printf(" %d", d[i]);
  printf("\n");

  return (0);
}

Measured memory_bytes: 3072
n, t = map(int, input().split())
dishes = [tuple(map(int, input().split())) for _ in range(n)]

t -= 1
dp1 = [[0] * (t+1) for _ in range(n+1)]
dp2 = [[0] * (t+1) for _ in range(n+2)]

# from top
for i in range(n):
    for time in range(t+1):
        if time - dishes[i][0] >= 0:
            dp1[i+1][time] = max(
                dp1[i][time-dishes[i][0]] + dishes[i][1],
                dp1[i][time]
            )
        dp1[i+1][time] = max(dp1[i][time], dp1[i+1][time])


for j in reversed(range(2, n+2)):
    i = j-2
    for time in range(t+1):
        if time - dishes[i][0] >= 0:
            dp2[j-1][time] = max(
                dp2[j][time-dishes[i][0]] + dishes[i][1],
                dp2[j][time]
            )
        dp2[j-1][time] = max(dp2[j][time], dp2[j-1][time])


ans = 0
for i in range(1, n+1):
    for time in range(t+1):
        ans = max(
            ans,
            dp1[i-1][time] + dishes[i-1][1] + dp2[i+1][t - time]
        )
print(ans)

Measured memory_bytes: 217024
// 2014/02/06 Tazoe

#include <iostream>
using namespace std;

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

	int S[100000];
	S[0] = 0;
	for(int i=1; i<n; i++){
		int s;
		cin >> s;

		S[i] = S[i-1]+s;
	}

	int sum = 0;

	int X = 1;
	for(int i=0; i<m; i++){
		int a;
		cin >> a;

		if(a>0){
			sum += (S[X+a-1]-S[X-1]);
		}
		else{
			sum += (S[X-1]-S[X+a-1]);
		}
		sum %= 100000;

		X = X+a;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1552
#include <stdio.h>
#include <string.h>

int main(void){
	char str[1000][33];
	char max[33];		//Å·¶ñ
	int len = 0;		//êIÈ¶ñ·Û¶p
	int mlen = 0;		//Å¶ñ·
	int n=0;			//Pê
	char strtemp[33];	//êIÈ¶ñ
	int cnt;			//êIÈpx
	char mfstr[33];		//ÅpxÌ¶ñ
	int mfreq = 0;		//Åpx
	int i, j;
		
	while(scanf("%s", str[n]) != EOF){
		len = strlen(str[n]);
		if(mlen < len){
		   	mlen = len;
			strcpy(max, str[n]);	
		}
		n++;
	}
	for(i=0; i < n; i++){
		cnt = 0;
		strcpy(strtemp, str[i]);	
		for(j=0; j < n; j++){
			if(strcmp(str[j], strtemp) == 0) cnt++;	
		}	
		if(mfreq < cnt){
			mfreq = cnt;
			strcpy(mfstr, strtemp);
		}
	}
	
	printf("%s %s\n", mfstr, max);
	
	return 0;	
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
	string s;
	int n;
	cin >> n;
	if(n == 1){
		cout << "Hello World" << endl;
	}else{
		int a,b;
		cin >> a >> b;
		cout << a+b << endl;
	}
	return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
void Men(int,int,int);
int MAX;
int main(void)
{
	int i,Q,c,a,n;
	scanf("%d",&Q);
	for(i=0;i<Q;i++){
		MAX = 0;
		scanf("%d %d %d",&c,&a,&n);
		Men(c,a,n);
		printf("%d\n",MAX);
	}
	return 0;
}

void Men(int c,int a,int n)
{
	int min;
	if(c <= a && c <= n)
		min = c;
	else if(a <= c && a<= n)
		min = a;
	else
		min = n;
	if(c > 0 && a > 0 && n > 0){
		c = c - min; a = a - min; n = n - min;
		MAX = MAX + min;
	}
	if(c > 0 && a > 0){
		if(c/2 <= a)
			min = c/2;
		else 
			min = a;
		c = c - min*2; a = a - min;
		MAX = MAX + min;
	}
	if(c > 0){
		MAX = MAX + c/3;
	}
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}

vector < ll > v;
ll A[N];
ll B[N],ans[N];

int main(){
 // 	freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
	int n,q;scanf("%d %d",&n,&q);
	v.pb(n);
	REP(i,q){
		ll x;scanf("%lld",&x);
		while(v.size() && v.back()>=x) v.pop_back();
		v.pb(x);
	}
	// REP(i,v.size()) printf("%lld ",v[i]);printf("\n");
	
	A[v.size()-1] = 1;
	for(int i = (int)v.size()-1;i>=1;i--){
		ll cnt = A[i];
		ll p = v[i];
		while(p>v[0]){
			int in = lower_bound(all(v),p) - v.begin();
			in--;
			// printf("%d\n",in);
			A[in] += cnt*(p/v[in]);
			p = p%v[in];
			// printf("%lld\n",p);
		}
		B[p]+=cnt;
	}
	B[v[0]]+=A[0];
	for(int i=v[0];i>0;i--){
		ans[i] = B[i]+ans[i+1];
	}
	REPP(i,1,n+1)	printf("%lld\n",ans[i]);
	return 0;
}




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

void solve(std::string T){
    for(int i=0;i<T.size();i++){
        if(T[i] =='?'){
            T[i] = 'D';
        }
    }
    cout << T << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string T;
    std::cin >> T;
    solve(T);
    return 0;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main(){
  int d;
  cin >> d;
  if (d == 22) {
    cout << "Christmas Eve Eve Eve";
  } else if (d == 23) {
    cout << "Christmas Eve Eve";
  } else if (d == 24) {
    cout << "Christmas Eve";
  } else {
    cout << "Christmas";
  }
}

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

int main(){
  int a,b;
  string s;
  cin>>a>>b>>s;
  bool flag=false;
  if(s.at(a)=='-') flag=true;
  for(int i=0;i<a;i++){
    if(s.at(i)=='-'){
      flag=false;
      break;
    }
  }
  for(int i=a+1;i<b+a+1;i++){
    if(s.at(i)=='-'){
      flag=false;
      break;
    }
  }
  if(flag) cout<<"Yes";
  else cout<<"No";
  cout<<endl;
}

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

int main() {
   int n,k;
   cin >> n >> k;
   int ans = 1;
   rep(i,n){
     ans = min(ans*2,ans+k);
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
program ec12;
var 
	n,m,i,j,sum:longint;
	t:array[0..101] of longint;
	a:array[1..101] of longint;
begin 
	fillchar(t,sizeof(t),0);
	readln(n);
	sum:=0;
	for i:=1 to n do
	begin 
		readln(a[i]);
		inc(t[a[i]]);
		sum:=sum+a[i];
	end;
	if sum mod 10>0 then 
	begin 
		writeln(sum);
		halt;
	end;
	for i:=1 to 100 do 
	begin 
		if (t[i]>0) and (i mod 10>0) then 
		begin 
			writeln(sum-i);
			halt;
		end;
	end;
	writeln(0);
end. 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s.size()==2)
        cout<<s<<endl;
    else{
        for(int i=s.size()-1;i>=0;i--)
            printf("%c",s[i]);
        printf("\n");
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	vector<ll> sum(n);
	sum[0] = a[0];
	rrep(i, n) sum[i] = sum[i - 1] + a[i];
	int ans = 1;
	for (int i = n - 2; i >= 0; --i) {
		if (sum[i] * 2 >= a[i + 1]) {
			ans++;
		}
		else break;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, INF = 1e9;
string s;
vector<int> g[2000];

int sum(int v, int h, int p) {
	int c = h * (s[v] - '0');
	RF(e, g[v]) {
		if(e == p) { continue; }
		c += sum(e, h + 1, v);
	}
	return c;
}

array<int, 3> dfs(int v, int p) {
	vector<array<int, 3>> va;
	RF(e, g[v]) {
		if(e == p) { continue; }
		auto x = dfs(e, v);
		x[0] += x[2];
		x[1] += x[2];
		va.PB(x);
	}
	sort(RALL(va));
	
	array<int, 3> ans = { 0, 0, 0 };
	RF(e, va) {
		ans[0] += e[0];
		ans[2] += e[2];
	}
	if(SI(va) > 0) {
		ans[1] = max(ans[0] % 2, va.front()[1] - (ans[0] - va.front()[0]));
	}
	ans[2] += (s[v] - '0');
	
	// cout << "   " << v + 1 << ": " << ans[0] << " " << ans[1] << " " << ans[2] << endl;
	
	return ans;
}

int f(int v) {
	auto x = dfs(v, -1);
	if(x[1] == 0) {
		int s = sum(v, 0, -1);
		return (s % 2 == 0 ? s : INF);
	} else { return INF; }
}

int main() {
	cin >> n >> s;
	inc(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].PB(b);
		g[b].PB(a);
	}
	
	
	int ans = INF;
	inc(i, n) { setmin(ans, f(i)); }
	
	inc(i, 0) {
		cout << i + 1 << ": " << endl;
		int x = f(i);
		setmin(ans, x);
		cout << x << "\n----\n\n";
	}
	
	cout << (ans == INF ? -1 : ans / 2) << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int n, k;
vector<int> a;

bool is_ok(int m) {
    ll cnt = 0;
    rep(i, n) {
        cnt += (ll)((a[i] + m - 1) / m - 1);
    }
    if (cnt <= (ll)k) {
        return true;
    }
    else {
        return false;
    }
}

int main()
{
    cin >> n >> k;
    a.resize(n);
    rep(i, n) {
        cin >> a[i];
    }

    int l = 0;
    int r = 1000000000;
    while ((r - l) > 1) {
        int mid = (l + r) / 2;
        if (is_ok(mid)) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3960
import java.util.*;

import java.math.*;


public class Main { 
	static long[] dp;
    static int mod=(int)1e9+7;
    public static  void help(String s, int k) {
      dp=new long[200000];
     
      fun(s);
    }
    
    
 
    static	void  fun(String s) {
		int n = s.length();

		long rem[] = new long[2019];

		int digit = 0, power = 1;
      rem[0]++;
		for (int i = n - 1; i >= 0; --i) {
			digit = (power * (s.charAt(i) - '0') + digit) % 2019;
			power = (power * 10) % 2019;
			++rem[digit];

		}
		
		long ans = 0;
		for (int i = 0; i < 2019; ++i) {
			if (rem[i] > 0) {
				ans += (rem[i] * (rem[i] - 1)) / 2;
			}
		}
		System.out.println(ans);
	}

   
	    
	public static void main(String args[] ) throws Exception {
		Scanner s=new Scanner(System.in);
	//	String hs="1817181712114";
		String hs=s.next();
		help(hs,2019);
		
}


} 


Measured memory_bytes: 41916
#include <iostream>
using namespace std;
static const int LEN=100;
static const int INF=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[LEN][LEN];

void dijkstra()
{
    int minc;
    int d[LEN],color[LEN];

    for(int i=0;i<n;i++){
        d[i]=INF;
        color[i]=WHITE;
    }
    d[0]=0;
    color[0]=GRAY;
    while(1){
        minc=INF;
        int u=-1;
        for(int i=0;i<n;i++){
            if(d[i]<minc&& color[i]!=BLACK){
                minc=d[i]; u=i;
            }
        }
        if(u==-1) break;
        color[u]=BLACK;
        for(int i=0;i<n;i++){
            if(color[i]!=BLACK && M[u][i]!=INF){
                if(d[u]+M[u][i]<d[i]){
                    d[i]=d[u]+M[u][i];
                    color[i]=GRAY;
                }
            }
        }
    }
        for(int i=0;i<n;i++){
            cout<< i << " " <<(d[i]==INF?-1:d[i]) <<endl;
        }
}

int main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)
            M[i][j]=INF;
    }
    int k,u,c,v;
    for(int i=0;i<n;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>v>>c;
            M[u][v]=c;
        }
    }
    dijkstra();
    return 0;
}





Measured memory_bytes: 3148