akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
struct mint {
    int x;
    mint(int x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return *this *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
mint F[2100010];
void fact(void) {
	F[0] = mint(1);
	F[1] = mint(1);
	for (int i = 2; i <= 2100000; i++) {
        mint x(i);
		F[i] = x * F[i - 1];
	}
}
 
mint square(mint x) {
    return x * x;
}
 
mint power(mint x, int y) {
    if (y == 0) return mint(1);
    else if (y == 1) return x;
    else if (y % 2 == 0) return square(power(x, y / 2));
    else return square(power(x, y / 2)) * x;
}
 
mint P(int n, int r) {
	if (n < r || n < 0 || r < 0) return mint(0);
	return F[n]/F[n - r];
}
 
mint C(int n, int r) {
	if (n < r || n < 0 || r < 0) return mint(0);
	mint ret;
	ret = F[n]/(F[n - r] * F[r]);
	return ret;
}
mint H(int n, int r) {
	if (n == 0 && r == 0) return mint(1);
	return C(n + r - 1, r);
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    fact();
    int N; cin >> N;
    if(N == 1) {cout << 0 << endl; return 0;}
    mint ALL = power(10, N);
    mint ans0 = power(9, N);
    mint ans9 = power(9, N);
    mint ans09 = power(8, N);
    cout << (ALL - ans0 - ans9 + ans09).x << endl;


    return 0;
}
// o, o, o, o, o

Measured memory_bytes: 19976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const int maxn=300010;
int n;
ll a,b,k,jc[maxn],ivjc[maxn],ans;
ll ksm(ll x,ll y) {
	if (y==0) return 1;
	if (y==1) return x%mod;
	ll res=ksm(x,y/2);
	res*=res; res%=mod;
	if (y%2==1) res*=x,res%=mod;
	return res;
}
ll C(ll x,ll y) {
	return jc[x]*ivjc[y]%mod*ivjc[x-y]%mod;
}
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%d %lld %lld %lld",&n,&a,&b,&k);
	jc[0]=1;
	for (int i=1;i<=n;i++) jc[i]=jc[i-1]*i%mod;
	ivjc[n]=ksm(jc[n],mod-2);
	for (int i=n-1;i>=0;i--) ivjc[i]=ivjc[i+1]*(i+1)%mod;
	for (ll x=0;x<=k/a+1&&x<=n;x++) {
		ll y=(k-x*a)/b;
		if ((k-a*x)%b!=0||y>n||y<0) continue;
		ans+=C(n,x)*C(n,y)%mod; ans%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <bitset>
const int MAXN = 2000 + 10;

int n;
int a[MAXN];
namespace solver1 {
  std::bitset<MAXN * MAXN> appear;
  void main() {
    int sum = 0;
    for (int i = 1; i <= n; i++) sum += a[i];
    
    appear[0] = 1;
    for (int i = 1; i <= n; i++) {
      appear |= appear << a[i];
    }
    for (int i = (sum + 1) / 2; i <= sum; i++) {
      if (appear[i]) {printf("%d\n", i); return;}
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  solver1::main();
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long N, K;
	cin >> N >> K;
	
	long long ans = 0;
	long long r = N % K;
	if(r != 0){
		ans = min(abs(K - r), abs(r));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3732
import java.util.Scanner;

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

        int n=r*100+g*10+b;
        if(n%4==0) {
        	System.out.println("YES");
        }else {
        	System.out.println("NO");
        }
    }
}

Measured memory_bytes: 35732
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    if (a < b)
        return gcd(b, a);
    else if (a % b)
        return gcd(b, a % b);
    else
        return b;
}
int main()
{
    int a,b;
    double t;
    cin>>a>>b>>t;
    int x;
    for(int i=0; i<100; i++){
        if(a*(i+1)>t+0.5){
            x=i;
            break;
        }
    }
    cout<<x*b<<endl;
}

Measured memory_bytes: 256
def main():
    from sys import stdin
    input = lambda :stdin.readline().rstrip()
    N,H = map(int,input().split())
    A = []
    B = []
    for i in range(N):
        a,b = map(int,input().split())
        A.append(a)
        B.append(b)
    A.sort()
    B.sort() #
    a = A.pop()
    b = B.pop()
    ans = 0
    from math import ceil
    while H > 0:
        if b > a:
            ans += 1
            H -= b
            if B:
                b = B.pop()
            else:
                b = 0
                
            
        else:
            ans += ceil(H/a)
            break
    print(ans)
    return

main()
        

        

Measured memory_bytes: 51420
fun main(args :Array<String>) {
    val n = readInteger()
    val testimonyMap = hashMapOf<Int, Map<Int, Int>>()
    for (i in 1..n) {
        val a = readInteger()
        val testimony = hashMapOf<Int, Int>()
        for (j in 0 until a) {
            val (x, y) = readIntegerList()
            testimony[x] = y
        }
        testimonyMap[i] = testimony
    }

    var ans = 0
    for (i in 0 until (1 shl n)) {
        var shouldCount = true
        for (j in 0 until n) {
            if (((i shr j) and 1) == 1) {
                val testimony = testimonyMap[j + 1]
                val falseList = testimony!!
                    .entries
                    .filter {
                        val tmp = (i shr (it.key - 1)) and 1
                        tmp != it.value
                    }

                if (falseList.isNotEmpty()) {
                    shouldCount = false
                    break
                }
            }
        }

        if (shouldCount) {
            var count = 0
            for (k in 0 until n) {
                // print(((i shr k) and 1))
                if (((i shr k) and 1) == 1) {
                    count++
                }
            }
            ans = Math.max(ans, count)
            // println()
        }
    }

    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 41176
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
#define p 1000000007
using namespace std;
namespace ywy{
	ll f[1000001],sums[1000001];
	void ywymain(){
		int n;cin>>n;f[0]=1;f[1]=n;f[2]=((ll)n*(ll)n)%p;sums[0]=1;sums[1]=n+1;sums[2]=(f[2]+sums[1])%p;
		for(register int i=3;i<=n;i++){
			f[i]=(f[i-1]+sums[i-3]+n-i+1)%p;f[i]+=(ll)(n-1)*(ll)(n-1);f[i]%=p;sums[i]=(sums[i-1]+f[i])%p;
		}cout<<f[n]<<endl;
	}
}
int main(){
	ywy::ywymain();return(0);
}

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

using namespace std;

int main(){
    int N,K;
    cin>>N>>K;
    int ans=1;
    for(int i=0;i<N;i++){
        if(ans*2<ans+K) ans*=2;
        else ans+=K;
    }
    cout<<ans;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    X,N=mis()
    p = lmis()
    score = INF
    ans = None
    for a in range(-1000, 1000):
        if a not in p:
            if abs(X-a) < score:
                ans = a
                score = abs(X-a)
    print(ans)

main()



Measured memory_bytes: 9956
N, L = map(int, input().split())
l = []
idx = (10**6, -1)

for i in range(1, N + 1):
    l.append(L + i - 1)
    if abs(L + i - 1) < idx[0]:
        idx = (abs(L + i - 1), i)
ans = 0
for i in range(1, N + 1):
    if i != idx[1]:
        ans += l[i - 1]
print(ans)


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int a,b;
	cin >> a >> b;
	if(a>=13) cout << b << endl;
	else if(a<=5) cout << '0' << endl;
	else cout << b/2 << 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;
using P = pair<int, int>; 
using ll = long long;

int main()
{
  int n, ans;
  double t, a, q;
  cin >> n >> t >> a;
  double x[n];
  rep(i, n) cin >> x[i];
  double mini = 1000000;
  rep(i, n){
    q = t - x[i] * 0.006;
    mini = min(mini, abs(a - q));
  }
  rep(i, n){
    q = t - x[i] * 0.006;
    if(abs(q - a) == mini) ans = i + 1;
  }
    
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3764
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k,t;
    cin >> k >> t;
    vint a(t);
    REP(i,t)cin>> a[i];
    sort(ALL(a));
    int mx = a[t-1];
    int rm = k-mx;
    cout << max(mx-rm-1,0) << endl;
    return 0;
}   

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let n: u32 = input();

    let mut sum = 0.0;
    for _ in 0..n {
        let line: String = input();
        let vec: Vec<String> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
        let x: f32 = vec[0].parse().unwrap();
        let u = &vec[1];
        if u == "JPY" {
            sum += x;
        } else {
            sum += x * 380000.0;
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 2148
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int fib (int a) {
    if (a <= 1) return 1;
    else return fib(a - 1) + fib(a - 2);
}

constexpr int MOD = 1000000007;

// + - * / ^
int mod(int a)
{
    int res = a % MOD;
    if(res < 0) {
        return res + MOD;
    }
    return res;
}
int mul_mod(int a, int b)
{
    ll res = ((ll)a * (ll)b) % MOD;
    return mod((int)res);
}
int pow_mod(int a, int b)
{
    ll res = 1;
    while (b > 0) {
        if(b & 1) {
            res = res * (ll)a % (ll)MOD;
        }
        a = mul_mod(a, a);
        b >>= 1;
    }
    return (int)res;
}
int inv_mod(int a)
{
    return pow_mod(a, MOD - 2);
}
int div_mod(int a, int b)
{
    return mul_mod(a, inv_mod(b));
}

// ! C
constexpr int FAC_MAX = 3000001;
ll fac[FAC_MAX], finv[FAC_MAX], inv[FAC_MAX];
void com_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < FAC_MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll com_mod(int a, int b){
    if (a < b) return 0;
    if (a < 0 || b < 0) return 0;
    return fac[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k; cin >> h >> w >> k;
    vector<vector<int> > dp(h + 1, vector<int>(w, 0));
    vector<vector<int> > way(w, vector<int>(w, 0));
    rep (i, w) {
        rep (j, w) {
            if (i == j) {
                way[i][j] = fib(i) * fib(w - 1 - i);
            } else if (abs(i - j) == 1) {
                int a = min(i, j), b = max(i, j);
                way[i][j] = fib(a) * fib(w - 1 - b);
            }
            // eprintf("%2d ", way[i][j]);
        }
        // eprintf("\n");
    }
    dp[0][0] = 1;
    rep (i, h) {
        rep (x, w) {
            rep (y, w) {
                dp[i + 1][y] = mod(dp[i + 1][y] + mul_mod(way[x][y], dp[i][x]));
            }
        }
    }
    cout << dp[h][k - 1] << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int gback(int pos,int goal)
{
  if(pos>goal) return goal*2-pos;
  else return pos;
}
int main(void)
{
  for(;;){
    int n,t,l,b;
    cin >> n >> t >> l >> b;
    if(!n&&!t&&!l&&!b) return 0;
    int lose[128]={},back[128]={};
    REP(i,l){
      int tmp;
      cin >> tmp;
      lose[tmp]++;
    }
    REP(i,b){
      int tmp;
      cin >> tmp;
      back[tmp]++;
    }
    double dp[128][128];
    REP(i,128){
      REP(j,128){
	dp[i][j]=0.0;
      }
    }
    dp[0][0]=1.0;
    REP(i,t){
      REP(j,n){
	REP(k,6){
	  int nextpos=gback(j+(k+1),n);
	  if(lose[nextpos]) dp[i+2][nextpos]+=dp[i][j]/6;
	  else if(back[nextpos]) dp[i+1][0]+=dp[i][j]/6;
	  else dp[i+1][nextpos]+=dp[i][j]/6;
	}
      }
    }
    REP(i,t)
      dp[i+1][n]+=dp[i][n];
    cout << fixed << setprecision(8) << dp[t][n] << endl;
  }
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  int rate[10] = {};
  int pro = 0;
  rep(i, n) {
    int a; cin >> a;
    if (1 <= a && a <= 399) ++rate[1];
    else if (400 <= a && a <= 799) ++rate[2];
    else if (800 <= a && a <= 1199) ++rate[3];
    else if (1200 <= a && a <= 1599) ++rate[4];
    else if (1600 <= a && a <= 1999) ++rate[5];
    else if (2000 <= a && a <= 2399) ++rate[6];
    else if (2400 <= a && a <= 2799) ++rate[7];
    else if (2800 <= a && a <= 3199) ++rate[8];
    else ++pro;
  }

  int colorcnt = 0;
  for (int i = 1; i <= 8; ++i) if (rate[i]) ++colorcnt;

  if (colorcnt == 0 && pro != 0) {
    cout << 1 << ' ' << pro << "\n";
  }
  else cout << colorcnt << ' ' << colorcnt + pro << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;


int main()
{
	int a, b;
	cin >> a >> b;
	
	if(b % a == 0) {
		cout << a + b << endl;
	}
	else {
		cout << b - a << endl;
	}
	
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>

using namespace std;

class Board {
    friend bool operator==(const Board &b1, const Board &b2);
    friend bool operator!=(const Board &b1, const Board &b2);

private:
    uint64_t board;

public:
    Board() {
        board = 0;
    }

    void set(int32_t r, int32_t c, int64_t v) {
        uint32_t shift = 4 * (r * 3 + c);
        uint64_t mask = 0xf;
        board = (board & ~(mask << shift)) | (v << shift);
        return;
    }

    int32_t get(int32_t r, int32_t c) const {
        int32_t shift = 4 * (r * 3 + c);
        return (board >> shift) & 0xf;
    }

    void swap(int32_t r1, int32_t c1, int32_t r2, int32_t c2) {
        int32_t temp = get(r1, c1);
        set(r1, c1, get(r2, c2));
        set(r2, c2, temp);
        return;
    }

    void show() const {
        cout << hex << board << endl;
    }
};

bool operator==(const Board &b1, const Board &b2) {return b1.board == b2.board;};
bool operator!=(const Board &b1, const Board &b2) {return !(b1 == b2);}

int32_t manhattan(const Board &board) {
    int32_t d = 0;

    for (int32_t r = 0; r < 3; r++) {
        for (int32_t c = 0; c < 3; c++) {
            int32_t v = board.get(r, c);
            if (v != 0) d += abs(r - (v-1) / 3) + abs(c - (v-1) % 3);
        }
    }

    return d;
}

vector<Board> children(const Board &board) {
    vector<Board> c;
    int32_t zr, zc;

    for (int32_t z = 0; z < 9; z++) {
        if (board.get(z/3, z%3) == 0) {
            zr = z/3;
            zc = z%3;
            break;
        }
    }

    array<int32_t, 4> dr = {1, 0, -1, 0}, dc = {0, 1, 0, -1};

    for (int32_t i = 0; i < 4; i++) {
        if (0 <= zr+dr[i] && zr+dr[i] < 3 && 0 <= zc+dc[i] && zc+dc[i] < 3) {
            Board board_new = board;
            board_new.swap(zr, zc, zr+dr[i], zc+dc[i]);
            c.push_back(board_new);
        }
    }

    return c;
}

bool dfs(const Board &board, const Board &parent, int32_t depth, int32_t dist, int32_t limit) {
    if (dist == 0) {
        cout << depth << endl;
        return true;
    }

    if (depth + dist > limit) return false;

    bool flag = false;
    for (Board child : children(board)) {
        if (child != parent) {
            if (dfs(child, board, depth + 1, manhattan(child), limit)) {
                flag = true;
                break;
            }
        }
    }

    return flag;
}


int main() {
    Board board;

    for (int32_t r = 0; r < 3; r++) {
        for (int32_t c = 0; c < 3; c++) {
            int32_t v;
            cin >> v;
            board.set(r, c, v);
        }
    }

    int32_t limit = 0;

    while (!dfs(board, board, 0, manhattan(board), limit)) limit++;

    return 0;
}

Measured memory_bytes: 3108
N = int(input())
d = dict()
for _ in range(N):
  s = input()
  if s in d:
    d[s] += 1
  else:
    d[s] = 1
max = max(d.values())
f = filter(lambda x:x[1] == max, d.items())
for p in sorted(f):
  print(p[0])

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int a,b;
void solve(){
	cin >> a >> b;
	
	if(a >= 13) cout << b << endl;
	else if(a >= 6) cout << b/2 << endl;
	else cout << 0 << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#include <string.h>

int main(void){

    int mm;

    char ymd[9];

    scanf("%s",ymd);

    if(strcmp(ymd,"2019/04/30")<=0){

        printf("Heisei\n");

    }else{

        printf("TBD\n");

    }

    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int main(){

    int a,b;
    while(cin>>a>>b&&!(a==0&&b==0)){
        set<int> as,bs;
        for(int i = 2; i*i<=a; i++){
            if(a%i==0){
                while(1){
                    if(a%i!=0)
                        break;
                    as.insert(i);
                    a/=i;
                }
            }
        }
        if(a!=1)as.insert(a);
        for(int i = 2; i*i<=b; i++){
            if(b%i==0){
                while(1){
                    if(b%i!=0)
                        break;
                    bs.insert(i);
                    b/=i;
                }
            }
        }
        if(b!=1)bs.insert(b);
        int asum,bsum;
        asum=bsum=0;
        for(set<int>::iterator it=as.begin();it!=as.end();it++){
            set<int>::iterator iit=it;
            if(++iit==as.end()){
                asum+=*it;
            }
            else
                asum-=*it;
        }
        for(set<int>::iterator it=bs.begin();it!=bs.end();it++){
            set<int>::iterator iit=it;
            if(++iit==bs.end()){
                bsum+=*it;
            }
            else
                bsum-=*it;
        }
        if(asum>bsum)
            cout<<"a"<<endl;
        else
            cout<<"b"<<endl;
    }

    return 0;
}

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

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

set<long long> prime_factor(long long n) {
  set<long long> nums;
  for(long long i=2; i*i<=n; i++) {
    while(n%i==0) {
      nums.insert(i);
      n /= i;
    }
  }
  if(n!=1){
    nums.insert(n);
  }
  return nums;
}

long long A, B;
long long sum;

int main() {
  cin >> A >> B;
  long long C = gcd(A, B);
  auto ans = prime_factor(C);
  cout << ans.size()+1 << endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
from math import log


def change_into_int(lists):
    tmps = lists.split(' ')
    num_list = []
    for n in tmps:
        num_list.append(int(n))
    return num_list


if __name__ == "__main__":
    lines = []
    result_list = []
    # 入力
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    # int
    num1 = change_into_int(lines[0])
    data = change_into_int(lines[1])
    i = 0
    while(True):
        ans = data[i] - data[i+num1[1]]
        if ans < 0:
            print("Yes")
        else:
            print("No") 
        i = i + 1
        if i+num1[1] == len(data):
            break



Measured memory_bytes: 35288
_,A,B = map(int,input().split())
s = list(input())

ab = 0
b = 0

for i in s:
    res = "No"
    
    if i == "a":
        if ab < A+B:
            ab += 1
            res = "Yes"
            
    if i == "b":
        if ab < A+B and b < B:
            ab += 1
            b += 1
            res = "Yes"
            
    print(res)

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

const ll p = 1e9+7;
const int MAXN = 2e5+5;

int n, m, ct[MAXN];
bool can[MAXN];

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		ct[i] = 1;
	can[0] = 1;
	for (int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b;
		a--; b--;
		if (can[a])
			can[b] = 1;
		ct[a]--; ct[b]++;
		if (ct[a] == 0)
			can[a] = 0;
	}

	int tot = 0;
	for (int i = 0; i < n; ++i)
		tot += can[i];
	cout << tot << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<int> o(H * W, 0);
  vector<char> data(H * W);
  for (int i = 0; i < H * W; i++) {
  cin >> data.at(i);
  }
  
  for (int i = 0; i < H * W; i++) {
    if (data.at(i) == '#') {
      if (i % W != 0 && i > W && data.at(i - W - 1) != '#') o.at(i - W - 1)++;
      if (i > W - 1 && data.at(i - W) != '#') o.at(i - W)++;
      if (i % W != W - 1 && i > W - 1 && data.at(i - W + 1) != '#') o.at(i - W + 1)++;
      if (i % W != 0 && i > 0 && data.at(i - 1) != '#') o.at(i - 1)++;
      if (i % W != W - 1 && i < H * W - 1 && data.at(i + 1) != '#') o.at(i + 1)++;
      if (i % W != 0 && i < H * W - W && data.at(i + W - 1) != '#') o.at(i + W - 1)++;
      if (i < H * W - W && data.at(i + W) != '#') o.at(i + W)++;
      if (i % W != W - 1 && i < H * W - W - 1 && data.at(i + W + 1) != '#') o.at(i + W + 1)++;
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data.at(i * W + j) == '#') {
        cout << data.at(i * W + j);
      }
      else {
        cout << o.at(i * W + j);
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int x,sum,N,ma;
int main()
{
	cin >> N;
	
	for(int i=0; i<N; i++)
	{
		cin >> x;
		sum+=x;
		ma=max(x,ma);
	}
	
	sum-=ma/2;
	cout << sum << "\n";
}

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

using namespace std;

int main(){
    string A, B;
    cin >> A >> B;
    if (A.length() > B.length()){
        cout << "GREATER" << endl;
    }else if (A.length() < B.length()){
        cout << "LESS" << endl;
    }else{
        bool flag = true;
        for (int i = 0; i < A.length(); i++){
            int a = A[i];
            int b = B[i];
            if (a > b){
                cout << "GREATER" << endl;
                flag = false;
                break;
            }else if (a < b){
                cout << "LESS" << endl;
                flag = false;
                break;
            } 
        }
        if (flag == true){
                cout << "EQUAL" << endl;
        }  
    }

    return 0;
}

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

using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define all(v) v.begin(),v.end()
#define v vector
#define vi vector<int>
#define vi2 vector<vi>
#define vl vector<long long>
#define vl2 vector<vl>

template <class T> T maxAny(T a, T b){
    if(a > b) return a;
    else return b;
}

template <class T> T minAny(T a, T b){
    if(a > b) return b;
    else return a;
}

int main(){
    long long n, sumLeaf = 0, nowPoint = 1, ans = 1;
    cin >> n;
    int a[n+1];
    rep(i, n+1){
        cin >> a[i];
        sumLeaf += a[i];
    }
    rep(i,n+1){
        sumLeaf -= a[i];
        if(nowPoint < a[i]){
            cout << -1 << endl;
            return 0;
        }
        else nowPoint -= a[i];
        if(sumLeaf >= nowPoint*2){
            ans += nowPoint*2;
            nowPoint = nowPoint*2;
        }
        else if((nowPoint < sumLeaf)&&(sumLeaf < nowPoint*2)){
            ans += sumLeaf;
            nowPoint = sumLeaf;
        }
        else if(sumLeaf == nowPoint) ans += nowPoint;
    }
    cout << ans << endl;
}

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

using namespace std;

long ans[200020], ps[200020];

void dfs(vector<int> g[], int v = 0, int p = -1, long r = 0)
{
    ans[v] = r + ps[v];
    for (int nv : g[v])
    {
        if (p == nv) continue;
        dfs(g, nv, v, r+ps[v]);
    }
}

void solve()
{
    int n, q;
    cin >> n >> q;
    vector<int> g[n];
    for (int i = 0; i < n-1; i++)
    {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    while(q--)
    {
        int p, x;
        cin >> p >> x;
        ps[p-1] += x;
    }
    dfs(g);
    for (int i = 0; i < n; i++)
    {
        cout << ans[i] << ' ';
    }
    cout << endl;

}

int main()
{
    solve();
    cerr << "努力不足ですね！" << endl;
    return 0;
}

Measured memory_bytes: 31872
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;
//const int INF = 1001001001;
const int MOD = 1000003;

int main(){
    int n;
    cin >> n;
	int s = 0;
  	int m = n;
  	while(m){
      s += m%10;
      m /= 10;
    }
  	if(n%s)cout << "No" << endl;
  	else cout << "Yes" << endl;
  	return 0;
}

Measured memory_bytes: 3568
n = int(input())
l = [0]*5

for i in range(n):
    a = input()
    if a[0] == "M":
        l[0] += 1
    elif a[0] == "A":
        l[1] += 1
    elif a[0] == "R":
        l[2] += 1
    elif a[0] == "C":
        l[3] += 1
    elif a[0] == "H":
        l[4] += 1
ans = 0
for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            ans += l[i]*l[j]*l[k]
print(ans)

Measured memory_bytes: 74836
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;

int main() {
	long long A, B, N;
	cin >> A >> B >> N;
	long long ans;
	long long x;
	if (N < B)
		x = N;
	else
		x = B - 1;
	ans = (A * x) / B;

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = sc.nextInt();
    int cost_n = 0;

    for (int i = 0; i < m; i++) {
      int am = sc.nextInt();
      if (am > x) {
        cost_n++;
      }
    }

    System.out.println(Math.min(cost_n, m - cost_n));
  }
}


Measured memory_bytes: 21844
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>

using namespace std;

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

//10^9 + 7
const ll MOD = 1000000007;

int main() {
	ll A, B;
	cin >> A >> B;


	ll N = -1;
	ll tmpA, tmpB;
	rep(i, 1250) {
		tmpA = floor(i * 0.08);
		tmpB = floor(i * 0.1);
		if (floor(i * 0.08) ==  A && floor(i * 0.1) == B) {
			N = i;
			break;
		}
	}
	cout << N << endl;
}

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

using namespace std;
typedef vector<vector<int> > field;

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

void erase(field &f, int y, int x)
{
    f[y][x] = 0;
    for(int i=0; i<8; i++)
    {
        if(f[y+dy[i]][x+dx[i]]) erase(f, y+dy[i], x+dx[i]);
    }
}

int main()
{
    int w, h;
    while(cin >> w >> h, w|h)
    {
        field f(h+2, vector<int>(w+2, 0));
        for(int y=1; y<=h; y++)
        {
            for(int x=1; x<=w; x++)
            {
                int c;
                cin >> c;
                f[y][x] = c;
            }
        }
        int ct = 0;
        for(int y=1; y<=h; y++)
        {
            for(int x=1; x<=w; x++)
            {
                if(f[y][x])
                {
                    ct++;
                    erase(f, y, x);
                }
            }
        }
        cout << ct << endl;
    }
}

Measured memory_bytes: 3132
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):#要素xが属するグループの根を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):#要素xが属するグループと要素yが属するグループとを併合する
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):#要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]
 
    def same(self, x, y):#要素x, yが同じグループに属するかどうかを返す
        return self.find(x) == self.find(y)
 
    def members(self, x):#要素xが属するグループに属する要素をリストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):#すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):#グループの数を返す
        return len(self.roots())
 
    def all_group_members(self):#{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):#print()での表示用 ルート要素: [そのグループに含まれる要素のリスト]を文字列で返す
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


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

ab = []
for _ in range(m):
    a, b = map(int,input().split())
    ab.append((a-1, b-1))
    
ans = 0
for i in range(m):
    uf = UnionFind(n)
    for j, r in enumerate(ab):
        if j == i:
            continue
        a, b = r
        uf.union(a, b)
    if uf.group_count() > 1:
        ans += 1
        
print(ans)

Measured memory_bytes: 68072
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N, W, M = NMI()
    
    BOMB_HW = [NLI() for _ in range(M)]
    
    bomb_h,bomb_w = zip(*BOMB_HW)
    
    dd = defaultdict(bool)
    for m in range(M):
        dd[str(bomb_h[m]) + "-" + str(bomb_w[m])] = True
    
    c_h = collections.Counter(bomb_h)
    c_w = collections.Counter(bomb_w)
    
    bomb_most_h = c_h.most_common()[0]
    bomb_most_w = c_w.most_common()[0]

    bh_destroy = bomb_most_h[1]
    bw_destroy = bomb_most_w[1]
 
    candidate_h = [i[0] for i in c_h.items() if i[1] == bh_destroy]
    candidate_w = [i[0] for i in c_w.items() if i[1] == bw_destroy]

    ans = bh_destroy+bw_destroy
    

    for bh in candidate_h:
        for bw in candidate_w:   
            if not(dd[str(bh) + "-" + str(bw)]):
                print(ans)
                sys.exit()
    print(ans-1)
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 147672
#include <bits/stdc++.h>
using namespace std;
int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
	return a*a + b*b;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &x[i], &y[i]);
		X += x[i]; Y += y[i];
	}
	X /= n; Y /= n;
	double P = 0.1;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = dist(X - x[0], Y - y[0]);
		for (int j = 1; j < n; j++) {
			e = dist(X - x[j], Y - y[j]);
			if (d < e) { d = e; f = j; }
		}
		X += (x[f] - X)*P;
		Y += (y[f] - Y)*P;
		P *= 0.999;
	}
	cout << setprecision(9) << sqrt(d) << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(_) for _ in input().split()]
for i in range(n-1):
    print(a[i], end=" ")
print(a[n-1])
for i in range(1, n):
    insert = a[i]
    # print('i', i)

    for j in range(i-1, -1, -1):
        # print('j', j)
        if a[j] > insert:
            a[j+1] = a[j]
            a[j] = insert
        else:
            break
    for i in range(n-1):
        print(a[i], end=" ")
    print(a[n-1])



Measured memory_bytes: 5976
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

template <typename F>
class
#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
    [[nodiscard]]
#elif defined(__GNUC__) && __GNUC_PREREQ(3, 4)
    __attribute__((warn_unused_result))
#endif  // defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
    FixPoint : F {
      public :
          explicit constexpr FixPoint(F&& f) noexcept : F(std::forward<F>(f)) {}

      template <typename... Args>
      constexpr decltype(auto)
      operator()(Args&&... args) const {
        return F::operator()(*this, std::forward<Args>(args)...);
}
}
;  // class FixPoint

template <typename F>
static inline constexpr decltype(auto)
makeFixPoint(F&& f) noexcept {
  return FixPoint<F>{std::forward<F>(f)};
}

int main() {
  int N;
  while (cin >> N) {
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    int r1 = 0, r2 = 0, r3 = 0;
    for (int i = 0; i < N; i++) {
      if (a[i] == 1) {
        ++r1;
      } else if (a[i] == 2) {
        ++r2;
      } else if (a[i] == 3) {
        ++r3;
      }
    }
    vec<double, 3> dp = make_v(N + 1, N + 1, N + 1, -1.0);
    auto solve = makeFixPoint([&](auto f, int r1, int r2, int r3) -> double {
      int r0 = N - r1 - r2 - r3;
      double& res = dp[r1][r2][r3];
      if (res >= 0) return res;
      if (r0 == N) return res = 0;
      res = 1;
      if (r1 > 0) {
        res += f(r1 - 1, r2, r3) * r1 / N;
      }
      if (r2 > 0) {
        res += f(r1 + 1, r2 - 1, r3) * r2 / N;
      }
      if (r3 > 0) {
        res += f(r1, r2 + 1, r3 - 1) * r3 / N;
      }
      res /= (1 - (double)r0 / N);
      return res;
    });
    double res = solve(r1, r2, r3);
    printf("%.20f\n", res);
  }
  return 0;
}


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

int main(){
  int n,k;
  cin>>n>>k;
  vector<bool>a(n,false);
  for(int i=0;i<k;i++){
    int d;
    cin>>d;
    for(int j=0;j<d;j++){
      int s;
      cin>>s;
      a[s-1]=true;
    }
  }
  int countt=0;
  for(int i=0;i<n;i++){
    if(a[i]==false){
      countt++;
    }
  }
  cout<<countt<<endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main()
{
    long N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<long> A(N);
    for (long i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    sort(A.begin(), A.end());
    //全部同じ数の時
    if (A.at(0) == A.at(N - 1)) {
        cout << N << endl;
        return 0;
    }

    long boundary = A.at(N - P); //この数を超えればよい    
    auto itr0 = lower_bound(A.begin(), A.end(), boundary - M); //boundaryを超えうる数がある最左端
    auto itr1 = lower_bound(A.begin(), A.end(), boundary); //boundaryと同値の数の最左端
    auto itr2 = A.end() - P; //boundaryのある場所

    
    long num0 = itr0 - A.begin(); //itr0より小さい数の個数
    long num1 = V - (P - 1); //boundaryより右の数に割り振った残り

    if ( (num1 - 1 -num0) <= 0) {
       cout << N - num0 << endl;
       return 0;
    }



    long sum = 0, flag = 0;
    auto ok = itr1;
    auto ng = itr0;
    auto judge = itr0;
    while(ok - ng > 1) {        
        num0 = judge - A.begin();
        sum = 0;
        flag = 0;
        //if ((num1 - 1 - num0) <= 0) {
        //    cout << N - num0 << endl;
        //    return 0;
        //}

        long t_boundary = max(boundary, *judge + M);
        for (auto itr = judge + 1; itr < itr2 + 1; itr++) {
            if ((t_boundary - *itr) == 0) {
                break;
            }

            sum += min((t_boundary - *itr), M); //
            if (sum >= M * (num1 - 1 - num0)) {
                flag = 1;
                break;
            }
        }

        
        if (flag) {
            ok = judge;
        }
        else {
            ng = judge;
        }
        judge = (ok - ng) / 2 + ng;

    }
    itr0 = ok;
    num0 = itr0 - A.begin(); //この時itr0 = itr1
    cout << N - num0 << endl;
    return 0;        
}

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

int main(){
    int a;
    int b;
    int c;
    int d;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    int i=(c+b-1)/b;
    int j=(a+d-1)/d;
    int k;
    if (i<=j){
        k=i;
    }
    else{
        k=j;
    }
    if (c-b*k<=0){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" <<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int top,S[10000];

void push(int x);
int pop();
int main(void){
	int a,b;
	top=0;
	char s[1000];
	while(scanf("%s",s)!=EOF){
		if(s[0] =='+'){
			a = pop();
			b = pop();
			push(a+b);
		}else if(s[0] =='-'){
			b = pop();
			a = pop();
			push(a-b);
		}else if(s[0] =='*'){
			a = pop();
			b = pop();
			push(a*b);
		}else{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	return 0;
}
void push(int x){
	S[++top]=x;
}
int pop(){
	return S[top--];
}


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

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

    int q = 0;
    int w = 0;
    if(N % 4 == 0){
        q = N / 4;
    }else{
        q = N / 4 + 1;
    }

    if(N % 7 == 0){
        w = N / 7;
    }else{
        w = N / 7 + 1;
    }

    int frag = 0;

    for(int i = 0; i <= q; i++){
        for(int j = 0; j <= w; j++){
            if(4 * i + 7 * j == N){
                frag = 1;
                break;
            }
        }
        if(frag == 1){
            break;
        }
    }

    if(frag == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.io.DataInputStream;
	import java.io.FileInputStream;
	import java.io.IOException;
	import java.util.ArrayList;
	import java.util.Arrays;
	import java.util.PriorityQueue;
	import java.util.*;
	
	public class Main {
		public static class pair implements Comparable<pair> {
			int id;
			int ans;
	
			pair(int x, int y) {
	
				id = x;
				ans = y;
	
			}
	
			public pair() {
	
			}
	
			public int compareTo(pair o) {
				// TODO Auto-generated method stub
	
				return this.id - o.id;
			}
		}
	
	//	static int mod = (int) 998244353.;
		static ArrayList<Integer> gr[];
		static long ar[];
		static Scanner sc = new Scanner(System.in);
		static int pri[] = new int[(int) 1e6 + 5];
		static StringBuilder out = new StringBuilder();
	
		//static long dp[];
	
		public static void main(String[] args) throws IOException {
			int t =1;// sc.nextInt();
			
			while (t-- > 0) {
	
				long x=sc.nextLong();
				HashMap<Long,Integer>hm=new HashMap<>();
				for(int i=-1000;i<=1000;i++) {
					
					hm.put((long)Math.pow(i, 5L), i);
					
				}
				long a=-1,b=-1;
				for(int i=-1000;i<1000;i++) {
					long val=(long)Math.pow(i, 5L)-x;
					if(hm.containsKey(val)) {
						a=i;
						b=hm.get(val);
						break;
					}
				}
			System.out.println(a+" "+b);
			}
	
		}

	
    }

Measured memory_bytes: 43092