akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<ll,int>
#define MA make_pair
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define co(i) cout<<i<<endl
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;

const int max_n=200001;
int bit[max_n+1];
ll a[max_n]={};
ll n;

int sum(int i){
	int s=0;
	while(i>0){
		s+=bit[i];
		i -= i & -i;
	}
	return s;
}

//iの値にx加える
void add(int i, int x){
	while(i<=n){
		bit[i]+=x;
		i += i & -i;
	}
}

int seikika(){
	vector<PA> v;
	FOR(i,0,n) v.PB(PA(a[i],i));
	sort(v.begin(), v.end());
	FOR(i,0,n) a[v[i].SE]=i;
}

int main(){
	int k; cin>>n>>k;
	a[0]=0;
	FOR(i,0,n){
		cin>>a[i+1];
		a[i+1]-=k;
		a[i+1]+=a[i];
	}
	n++;
	//FOR(i,0,n) cout<<a[i]<<" "; cout<<endl;
	seikika();
	//FOR(i,0,n) cout<<a[i]<<" "; cout<<endl;
	ll ans=0;
	FOR(i,0,n){
		ans+=i-sum(a[i]+1);
		add(a[i]+1,1);
	}
	co(n*(n-1)/2-ans);
}

Measured memory_bytes: 7920
#include<iostream>
#include<vector>

using std::cout;
using std::cin;
using std::endl;
using std::vector;

vector<int> initial(int n, int p) {
    vector<int> status(n + 1);
    status[n] = p;
    return status;
}

void operation(vector<int> &status, int player, int n) {
    if (status[n] == 0) {
        status[n] += status[player];
        status[player] = 0;
    } else {
        status[n] --;
        status[player] ++;
    }
}

int nextPlayer(int player, int n) {
    if (player == n - 1) {
        return 0;
    }
    return player + 1;
}

int check(vector<int> status, int n, int p) {
    for (int i = 0; i < n; i ++) {
        if (status[i] == p) {
            return 1;
        }
    }
    return 0;
}

void game(vector<int> status, int n, int p) {
    int player = -1;
    while (check(status, n, p) != 1) { // ??°????????????????????????
        player = nextPlayer(player, n);// player?????´??°
        operation(status, player, n);
    }
    cout << player << endl;
}

int main(void) {
    int n; // ????£?????????°
    int p; // ?????????????????\???????°?????????°
    cin >> n >> p;
    while (n != 0 && p != 0) {
        vector<int> status = initial(n, p);
        game(status, n, p);
        cin >> n >> p;
    }

    return 0; 
}

Measured memory_bytes: 3096
#include <stdio.h>

#define MAX 100
#define NIL -1


typedef struct {
  int parent;
  int left;
  int right;
}Tree;

Tree T[MAX];
int n;

void preOrder(int);
void inOrder(int);
void postOrder(int);

int main(){
  int i;
  int left,right,root;
  int a;

scanf("%d",&n);
for(i=0;i<n;i++){
  T[i].parent=NIL;
}
for(i=0;i<n;i++){
  scanf("%d%d%d",&a,&left,&right);
  T[a].left=left;
  T[a].right=right;
  if(left!=NIL)T[left].parent=a;
  if(right!=NIL)T[right].parent=a;
}

for(i=0;i<n;i++){
  if(T[i].parent==NIL)root=i;
}


printf("Preorder\n");
preOrder(root);
printf("\n");
printf("Inorder\n");
inOrder(root);
printf("\n");
printf("Postorder\n");
postOrder(root);
printf("\n");

return 0;

}


void preOrder(int u){
  if(u==NIL)return ;
  printf(" %d",u);
  preOrder(T[u].left);
  preOrder(T[u].right);
}


void inOrder(int u){
  if(u==NIL)return ;
  inOrder(T[u].left);
  printf(" %d",u);
  inOrder(T[u].right);
}


void postOrder(int u){
  if(u==NIL)return ;
  postOrder(T[u].left);
  postOrder(T[u].right);
  printf(" %d",u);
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	int sx,sy,tx,ty,x,y;
	cin>>sx>>sy>>tx>>ty;
	x=abs(sx-tx);
	y=abs(sy-ty);
	string s;
	for(int i=1;i<=y;i++)
		s+="U";
	for(int i=1;i<=x;i++)
		s+="R";
	for(int i=1;i<=y;i++)
		s+="D";
	for(int i=1;i<=x;i++)
		s+="L";
	s+="L";
	for(int i=1;i<=y+1;i++)
		s+="U";
	for(int i=1;i<=x+1;i++)
		s+="R";
	s+="D";
	s+="R";
	for(int i=1;i<=y+1;i++)
		s+="D";
	for(int i=1;i<=x+1;i++)
		s+="L";
	s+="U";
	cout<<s;
	return 0;
}



Measured memory_bytes: 3592
#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 <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

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

    if(N<=99){
    if(D==0){cout<<N<<endl;}
    else if(D==1){cout<<100*N<<endl;}
    else{cout<<10000*N<<endl;}
    }else{
    if(D==0){cout<<101<<endl;}
    else if(D==1){cout<<10100<<endl;}
    else{cout<<1010000<<endl;}
    }
}

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

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)

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; }

const ll INF = 1LL << 60;

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

  int ans = 0;
  for (int i = 0; 2*i+1 <= n; i++) {
    int nn = 2*i+1;
    int c3=0,c5=0,c7=0,c11=0,c13=0;
    while(nn%3==0) {nn/=3; c3++;}
    while(nn%5==0) {nn/=5; c5++;}
    while(nn%7==0) {nn/=7; c7++;}
    while(nn%11==0) {nn/=11; c11++;}
    while(nn%13==0) {nn/=13; c13++;}
    int g = (c3+1)*(c5+1)*(c7+1)*(c11+1)*(c13+1);
    if(g == 8) ans++;
    //printf("%d %d %d %d\n",2*i+1,c3,c5,c7 );
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

//累乗 O(log N)
long long power(long long x, long long N){
	if(N == 0) return 1LL;
	if(N == 1) return x;
	long long tmp = power(x, N/2);
	if(N%2 == 0) return tmp * tmp % MOD;
	else return tmp * tmp % MOD * x % MOD;
}

//逆元 O(log x)
long long inverse(long long x){
	return power(x, MOD-2);
}

// f(r,c) = (r+c)Cr = (r+c)!/(r!c!)

// r を固定、 c を 5 から 8 で変化させると、
// (r+4)!*(r+5) / (r!4!*5) + (r+4)!*(r+5)(r+6) / (r!4!*5*6)

// これはパスカルの三角形であるから、f(r,c) = f(r-1,c) + f(r,c-1)

ll r1, c1, r2, c2;
ll fac[2000001], inv[2000001];

/*ll f(ll r, ll c){
	return fac[r+c] * inv[r] % MOD * inv[c] % MOD;
}*/

ll memo[2000001]; //パスカルの三角形の 1～i 段目の和

ll sum(ll x, ll y, ll s){
	ll ret = 0;
	for(ll i=0; i<s; i++){
		ll tmp = fac[x+i+y-1] * inv[x+i] % MOD * inv[y-1] % MOD;
		ret += tmp * memo[s-i];
		ret %= MOD;
	}
	for(ll i=0; i<s; i++){
		ll tmp = fac[x-1+y+i] * inv[x-1] % MOD * inv[y+i] % MOD;
		ret += tmp * memo[s-i];
		ret %= MOD;
	}
	return ret;
}

signed main(){
	cin >> r1 >> c1 >> r2 >> c2;
	fac[0] = 1;
	inv[0] = inverse(fac[0]);
	for(ll i=1; i<=r2+c2; i++){
		fac[i] = fac[i-1] * i % MOD;
		inv[i] = inverse(fac[i]);
	}

	/*for(ll i=1; i<=10; i++){
		for(ll j=1; j<=10; j++){
			cout << f(i,j) << "\t";
		}
		cout << endl;
	}*/

	memo[0] = 0;
	for(ll i=1; i<=r2+c2; i++){
		memo[i] = memo[i-1] + power(2, i-1);
		memo[i] %= MOD;
	}

	/*cout << sum(1, 1, 3) << endl;
	cout << sum(3, 1, 1) << endl;
	cout << sum(1, 3, 1) << endl;*/

	//cout << sum(7, 2, 3) << endl;

	cout << ( sum(r1, c1, r2-r1+c2-c1+1) + MOD - sum(r2+1, c1, c2-c1) + MOD - sum(r1, c2+1, r2-r1) ) % MOD << endl;
}

Measured memory_bytes: 47104
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 5000001
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<int>> graph;
vector<vector<bool>> reached;


int main(){
    ll X,Y;
    cin >> X >> Y;
    ll ans = 0;
    while(Y >= X){
        ans++;
        X *= 2;
    }
    cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

vector<ll> fact(1000100,1),refact(1000100,1);

ll modpow(ll n,ll r){
  ll res = 1;
  while(r){
    if(r & 1)res = res*n%MOD;
    n = n*n%MOD;
    r >>= 1;
  }
  return res;
}
ll comb(ll n,ll r){
  ll res = fact[n]*refact[r]%MOD;
  res = res*refact[n-r]%MOD;
  return res;
}

int main(){

  rep(i,1000000)fact[i+1] = fact[i]*(i+1)%MOD;
  refact[1000000] = modpow(fact[1000000],MOD-2);
  for(ll i = 1000000;i > 0;i--)refact[i-1] = refact[i]*i%MOD;
  
  ll n,k;
  cin >> n >> k;
  if(k >= n){
    cout << comb(2*n-1,n) << endl;
    return 0;
  }
  ll res = 1;
  for(ll i = 1;i <= k;i++){
    ll sum = comb(n-1,i)*comb(n,i)%MOD;
    (res += sum)%=MOD;
  }
  cout << res << endl;
  
  
  return 0;
}

Measured memory_bytes: 18604
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <tuple>

using namespace std;

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "Yes" : "No")
#define mod(a, b) (b + (a % b)) % b
#define MOD  (ll)1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<pii> vpii;

void solve(){
    ll x;
    cin >> x;
    ll n = 0;
    while(x > 1){
        x /= 2;
        n++;
    }
    n += 1;
    cout << (ll)pow(2, n) - 1;
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}


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

using namespace std;

const int MAX_N = 50, MAX_M = 50, INDEX = 1;

int n, m, a[MAX_M + INDEX], b[MAX_M + INDEX], ans[MAX_N + INDEX];

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

    cin >> n >> m;

    for (int i = 1; i <= m; i++) {
        cin >> a[i] >> b[i];
    }

    for (int i = 1; i <= n; i++) {
        ans[i] = 0;
    }

    for (int i = 1; i <= m; i++) {
        ans[a[i]]++;
        ans[b[i]]++;
    }

    for (int i = 1; i <= n; i++) {
        cout << ans[i] << '\n';
    }

    return 0;
}


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

using namespace std;

int main(){
  int N;
    cin>>N;
  
  
 int B[N-1];
  for(int j=0;j<N-1;++j){
    cin>>B[j];
  }
  int ans = 0;
  ans += B[0]+B[N-2];
  for(int i=0;i<N-2;++i){
    if(B[i]<=B[i+1]){
  ans += B[i];
    }else{
      ans += B[i+1];
    }
  }
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  
  //INPUT
  int N,K;
  cin >> N >> K;
  
  bool flag[N];
  for(int i=0;i<N;i++) flag[i] = true;

  
  int person_amount;
  int person_number;
  
  for(int i=0;i<K;i++){
    
    cin >> person_amount;
    
    for(int j=0;j<person_amount;j++){
    	cin >> person_number;
      	flag[person_number - 1] = false;
    }
  }
  
  int answer=0;
  for(int i=0;i<N;i++){
   if(flag[i]==true) answer++; 
  }
  
  cout << answer <<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using st = string;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) { x = max(x, y); }
#define chmin(x, y) { x = min(x, y); }
#define mp(x, y) make_pair(x, y)
#define mt(x, y, z) make_tuple(x, y, z)

int main() {
    int n;
    cin >> n;
    vector<tuple<string, int, int>> sp(n);
    rep(i, n){
        string s;
        int p;
        cin >> s >> p;
        int x = i + 1;
        sp.at(i) = mt(s, p, x);
    }
    sort(sp.begin(), sp.end());
    rep(i, n - 1){
        mrep(j, i + 1, n){
            string s1 = get<0>(sp.at(i));
            string s2 = get<0>(sp.at(j));
            if(s1 == s2){
                int i1 = get<1>(sp.at(i));
                int i2 = get<1>(sp.at(j));
                if(i1 < i2){
                    tuple<string, int, int> t = sp.at(i);
                    sp.at(i) = sp.at(j);
                    sp.at(j) = t;
                }
            }
        }
    }
    rep(i, n){
        string s;
        int p;
        int x;
        tie(s, p, x) = sp.at(i);
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 3552
# import itertools
# import math


def solve(H, A):
    ans = H // A
    if H % A != 0:
        ans += 1
    return ans


# N = int(input())
# S = input()
H, A = map(int, input().split())
# A = list(map(int, input().split()))

# P = []
# S = []
# for i in range(N):
#     pp, ss  = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(H, A))


Measured memory_bytes: 2940
///In the name of GOD
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 4e5 + 10;
ll n, a, b, c, d;
vector<ll> vec;
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> n >> b;;
    for(int i = 1; i <= n; i ++) cin >> a, vec.push_back(a);
    sort(vec.begin(), vec.end());
    for(int i = 0; i < b; i ++){
        c += vec[i];
    }
    cout << c;
    return 0;
}
/*!
    I CHOOSE TO HAVE FAITH,
    BECAUSE WITHOUT THAT,
    I HAVE NOTHING....
    ITS THE ONLY THING THAT'S KEEPING ME GOING.
*/
//! N.N


Measured memory_bytes: 3620
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> M;
	long long int ans = 0;
	long long int sum = 0;
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		sum += L * R;
		ans += R;
	}
	ans--;
	ans += (sum-1) / 9;
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] g = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				g[i][j] = 0;
			}
		}

		for (int i = 0; i < n; i++) {
			int u = sc.nextInt();
			u--;
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int v = sc.nextInt();
				v--;
				g[u][v] = 1;
			}
		}
		sc.close();

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (j != 0) {
					System.out.print(" ");
				}
				System.out.print(g[i][j]);
			}
			System.out.print("\n");
		}
	}
}

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

int main() {
  int n;
  cin >> n;
  long a, mina, maxa, suma = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (i == 0) {
      mina = a;
      maxa = a;
    }
    mina = min(mina, a);
    maxa = max(maxa, a);
    suma += a;
  }
  printf("%ld %ld %ld\n", mina, maxa, suma);
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0;
  cin >> n;
  long long a[n],b[n],c[n],cnt1=0,cnt2=n;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  reverse(c,c+n);

  for(int i=0;i<n;i++){
    while(cnt1<n){
      if(a[cnt1]<b[i]){
        cnt1++;
      }else{
        break;
      }
    }
    while(cnt2>0){
      if(c[cnt2-1]<=b[i]){
        cnt2--;
      }else{
        break;
      }
    }
    ans+=cnt1*cnt2;
  }
  cout << ans << endl;
  return 0;
}  

Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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


int main(){
    int n, h; cin >> n >> h;
    VI a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i];
    RSORT(a); RSORT(b);
    int cnt = 0;
    REP(i, n){
        if(a[0] > b[i]) break;
        if(h <= 0) break;
        h -= b[i]; ++cnt;
    }
    if(h > 0){
        cnt += (h + a[0]-1)/a[0];
    }
    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 1024
//
// Created by yamunaku on 2020/05/30.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    string s;
    cin >> s;
    int n = s.size();
    rep(i, n) if(s[i] == '?') s[i] = 'D';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3756
def main():
    N = int(input())
    acts = []
    for _ in range(N):
        a, b, c = map(int, input().split())
        acts.append([a,b,c])
    dp = [[0] * 3 for _ in range(N + 5)]

    dp[0][0] = acts[0][0]
    dp[0][1] = acts[0][1]
    dp[0][2] = acts[0][2]
    for i in range(1,N):
        for j in range(3):
            if j == 0:
                score = max(dp[i-1][1], dp[i-1][2])
            if j == 1:
                score = max(dp[i-1][0], dp[i-1][2])
            if j == 2:
                score = max(dp[i-1][1], dp[i-1][0])
            dp[i][j] = acts[i][j] + score

    print(max(dp[N-1]))



if __name__ == "__main__":
    main()

Measured memory_bytes: 103736
var n = readInt()
var name = ""

while n != 0 {
    var x = n % 26
    n /= 26
    if x <= 0 {
        x += 26
        n -= 1
    }
    let char = Character.init(Unicode.Scalar.init(0x60 + x)!)
    name.insert(char, at: name.startIndex)
}
print(name)

// MARK: -----------------------------------------------------------------------


func readInt() -> Int {
    Int(readLine()!)!
}

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating get {
            if let note = dictionary[argument] {
                return note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                return result
            }
        }
    }
}


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

int main(){
	int n,m,x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	rep(i,n){
		cin >> c[i];
		rep(j,m) cin >> a[i][j];
	}
	int ans = 100100100;
	rep(is,1<<n){
		int cost = 0;
		vector<int> d(m);
		rep(i,n){
			if(is>>i&1){
				cost += c[i];
				rep(j,m){
					d[j] += a[i][j];
				}
			}
			bool ok = true;
			rep(j,m){
				if(d[j] < x) ok = false;
			}
			if(ok){
				ans = min(ans,cost);
			}
		}
	}
	if(ans == 100100100) cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 3644
N=int(input())
X=[0 for i in range(N)]
Y=[0 for i in range(N)]
U=[0 for i in range(N)]
V=[0 for i in range(N)]
for i in range(N):
    X[i],Y[i]=map(int,input().split())
flag=(X[0]+Y[0])%2
for i in range(N):
    if flag!=(X[i]+Y[i])%2:
        print(-1)
        exit()
    U[i]=X[i]+Y[i]+1-flag
    V[i]=X[i]-Y[i]+1-flag
m=31
d=[2**i for i in range(m)]
S=["" for i in range(N)]
T=["" for i in range(N)]
W=["" for i in range(N)]
for i in range(N):
    k=(U[i]+(2**31-1))//2
    w="0"*(31-len(bin(k)[2:]))+bin(k)[2:]
    S[i]=w
    k=(V[i]+(2**31-1))//2
    w="0"*(31-len(bin(k)[2:]))+bin(k)[2:]
    T[i]=w
for i in range(N):
    if flag==0:
        W[i]="L"
    for j in range(m)[::-1]:
        if (S[i][j],T[i][j])==("0","0"):
            W[i]=W[i]+"L"
        elif (S[i][j],T[i][j])==("1","1"):
            W[i]=W[i]+"R"
        elif (S[i][j],T[i][j])==("0","1"):
            W[i]=W[i]+"D"
        else:
            W[i]=W[i]+"U"
arm=[]
if flag==0:
    arm.append(1)
for i in range(m):
    arm.append(d[i])
print(len(arm))
print(" ".join([str(i) for i in arm]))
for i in range(N):
    print(W[i])


Measured memory_bytes: 3572
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,MOD=1e9+7,a,b,ans,bik[200001],dp[200000],par[200000],num[200000],dp2[200000];
vector<ll> v[200000];
ll f(ll x,ll y){
    if(y==0)return 1;
    if(y%2==0)return f(x,y/2)*f(x,y/2)%MOD;
    return x*f(x,y-1)%MOD;
}
ll comb(ll x, ll y){
    return bik[x]*f(bik[x-y],MOD-2)%MOD*f(bik[y],MOD-2)%MOD;
}
void dfs(int a){
    for(int x:v[a]){
        if(x==0||par[x]!=-1)continue;
        par[x]=a;
        dfs(x);
        num[a]+=num[x];
        //cout<<comb(num[a],num[x])<<" "<<dp[a]<<" <<endl;
        dp[a]*=dp[x]*comb(num[a],num[x])%MOD;
        dp[a]%=MOD;
    }
    num[a]++;
    return ;
}
void dfs2(int a){
    if(a==0)dp2[a]=dp[a];
    else{
        dp2[a]=dp[a];
        dp2[a]*=comb(n-1,num[a]-1)*dp2[par[a]]%MOD*f(dp[a]*comb(n-1,num[a])%MOD,MOD-2)%MOD;
        //cout<<dp[a]<<" "<<dp2[a]<<" "<<dp2[par[a]]<<" "<<f(dp[a]*comb(num[par[a]]-1,num[a])%MOD,MOD-2)%MOD<<" "<<dp[a]*comb(num[par[a]]-1,num[a])<<endl;
        dp2[a]%=MOD;
    }
    for(int x:v[a]){
        if(x==par[a])continue;
        dfs2(x);
    }
    return ;
}
int main(void){
    cin>>n;
    bik[0]=1;
    for(ll i=1;i<=200000;i++){
        bik[i]=bik[i-1]*i;
        bik[i]%=MOD;
    }
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=0;i<n;i++)par[i]=-1;
    for(int i=0;i<n;i++)dp[i]=1;
    dfs(0);
    dfs2(0);
    for(int i=0;i<n;i++){
        cout<<dp2[i]<<endl;
    }
    
}


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

using namespace std;
using ll = long long;


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

    int cur = 1;
    for(int i = 0; i < n; i++){

        if(cur<<1 > cur + k)cur += k;
        else cur <<= 1;
    }
    cout << cur << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
ll N;

int main()
{
	string s;
	cin >> s;
	if ( s == "ABC")
		cout << "ARC" << endl;
	else
		cout << "ABC" << endl;

	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

    int n;
    cin>>n;
    int ans = 0;
    for(int a=1;a<n;a++){
        int b=n/a;
        if(n%a==0){
            b--;
        }
        ans+=b;

    }
    cout<<ans<<endl;



    
return 0;
}


Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int MAX_N = 510;

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<int>> data(MAX_N, vector<int>(MAX_N, 0));
    for (int i = 0; i < M; i++) {
        int l, r;
        scanf("%d%d", &l, &r);
        data[l][r]++;
    }
    for (int i = 0; i <= N; i++) for (int j = 0; j <= N; j++) {
        data[i+1][j+1] += (data[i+1][j] + data[i][j+1] - data[i][j]);
    }
    
    for (int i = 0; i < Q; i++) {
        int l, r;
        scanf("%d%d", &l, &r);
        l--;
        int ans = data[r][r] - data[l][r] - data[r][l] + data[l][l];
        printf("%d\n", ans);
    }
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

// くそ雑魚回答
/*
int color(char c){
	if(c == 'R') return 0;
	else if(c == 'G') return 1;
	else return 2;
}

vector<bool> flg(3,true);
int flg_check(){
	if(flg[0]) return 0;
	else if(flg[1]) return 1;
	else return 2;
}
*/

int main(){
	#define int ll
	cin.tie(0);
	ios::sync_with_stdio(false);
	// ここに処理を記述

	int N;
	cin >> N;

	ddvi C(3,vi(0));
	string S;
	cin >> S;
	REP(i,N){
		if(S[i] == 'R'){
			C[0].eb(i);
		}
		else if(S[i] == 'G'){
			C[1].eb(i);
		}
		else{
			C[2].eb(i);
		}
	}


	if(C[0].size() == 0 || C[1].size() == 0 || C[2].size() == 0){
		cout << "0" << "\n";
		return 0;
	}

	// すべての文字が異なり('R', 'G', 'B'が揃う)
	// その配置が等間隔でない
	ll ans = 0;

	// くそ雑魚回答
	/*
	REP(i,N-1){
		flg[color(S[i])] = false;
		FOR(j,i+2,N){
			flg[color(S[j])] = false;
			if(S[i] == S[j]) continue;
			// 残った色の配列についてにぶたんで上界下界を探索
			auto left = upper_bound(C[flg_check()].begin(), C[flg_check()].end(), i);
			int left_pos = distance(C[flg_check()].begin(), left);
			auto right = upper_bound(C[flg_check()].begin(), C[flg_check()].end(), j);
			int right_pos = distance(C[flg_check()].begin(), right);
			if(right_pos == 0) continue;

			// cout << "[" << i << "," << j << "]" << "\n";
			// cout << left_pos << "," << right_pos << "\n";
			if((i+j)%2 == 0 && S[(i+j)/2] != S[i] && S[(i+j)/2] != S[j]){
				// cout << "ouch!\n";
				ans -= 1;
			}

			ans += right_pos - left_pos;
			flg[color(S[j])] = true;
		}
		flg[color(S[i])] = true;
	}
	*/

	REP(i,C[0].size()){
		REP(j,C[1].size()){
			int big = max(C[0][i],C[1][j]);
			int small = min(C[0][i],C[1][j]);
			ans += C[2].size();

			// B---small---bigの場合
			if(small - (big - small) >= 0){
				if( binary_search(C[2].begin(), C[2].end(), small - (big - small)) ){
					ans -= 1;
				}
			}
			// small---B---bigの場合
			if((small + big) % 2 == 0){
				int mid = (small + big) / 2;
				if( binary_search(C[2].begin(), C[2].end(), mid) ){
					ans -= 1;
				}
			}
			// small---big---Bの場合
			if(big + (big - small) < N){
				if( binary_search(C[2].begin(), C[2].end(), big + (big - small)) ){
					ans -= 1;
				}
			}
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3736
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
i64 A, B, X[101010];

int main()
{
	scanf("%d%lld%lld", &N, &A, &B);
	for (int i = 0; i < N; ++i) scanf("%lld", X + i);

	i64 ret = 0;
	for (int i = 1; i < N; ++i) ret += min(B, A * (X[i] - X[i - 1]));
	printf("%lld\n", ret);

	return 0;
}


Measured memory_bytes: 1024
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Summarize count of factor within list -- START --
def summarizeList(l):
  sl=sorted(l)

  a=sl[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append([a,c])
      a=x
      c=1
  res.append([a,c])

  return res
# Summarize count of factor within list --- END ---

# 累積和の書き方がよくないやつ
def main():
  s=S()
  n=len(s)

  l=[]
  mul=1
  for x in s[::-1]:
    l.append(mul*int(x)%2019)
    mul*=10
    mul%=2019

  for i in range(n-1):
    l[i+1]+=l[i]
    l[i+1]%=2019

  sl=summarizeList(l)
  # print(sl)

  ans=0
  for x,c in sl:
    if x==0:
      ans+=c
    if c>1:
      ans+=c*(c-1)//2

  return ans

# main()
print(main())


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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes";
    else cout<<"No";
}



Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
sum = a.inject(:+)

if sum%(n*(n+1)/2)!=0
  puts "NO"
  exit
end

k = sum/(n*(n+1)/2)

d = n.times.map{|i| a[i] - a[i-1] - k}
f = true

n.times{|i|
  x = -d[i]/n
  next if x<0
  k -= x
  d[i] += x*n if k>=0
  f = false if d[i]!=0
}

puts (f)? "YES":"NO"


Measured memory_bytes: 9356
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut a:usize = read();
    let mut b:usize = read();
    let mut c:usize = read();
    if a == b && b == c {
        if a % 2 == 0 {
            println!("-1");
        } else {
            println!("0");
        }
        return
    }
    for i in 0..10000000 {
        if a % 2 != 0 || b % 2 != 0 || c % 2 != 0 {
            println!("{}", i);
            break;
        }
        let tmpa = a;
        let tmpb = b;
        let tmpc = c;
        a = (tmpb + tmpc) / 2;
        b = (tmpa + tmpc) / 2;
        c = (tmpa + tmpb) / 2;
    }
}


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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; ++i)cin >>a[i];
  int ans = 0;
  for(int i = 0; i < n; ++i){
    for(int j = i+1; j < n; ++j){
      ans+= a[i]*a[j];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}/*swap 交換*/
ll max2(ll a,ll b){return a>=b?a:b;}/*2つのうち大きい数を返す*/ 
ll min2(ll a,ll b){return a>=b?b:a;}/*2つのうち小さい数を返す*/ 
ll ABS(ll a){return a>=0?a:(-a);}/*絶対値*/ 
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    // ll n,ans=0;
    char s[5];
    scanf("%s",s);
    // ll [n];
    // rep(i,0,n){
    //     scanf("%lld",&[i]);
    // }
    if(s[0]=='A'){
        if(s[1]=='A'&&s[2]=='A'){
            printf("No\n");
        }else{
            printf("Yes\n");
        }
    }else{
        if(s[1]=='B'&&s[2]=='B'){
            printf("No\n");
        }else{
            printf("Yes\n");
        }
    }
    // if(s=='AAA' || s=='BBB'){
    //     printf("No\n");
    // }else{
    //     printf("Yes\n");
    // }
    // printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif

static void C_4divN();

int main()
{
	C_4divN();

	fflush(stdout);
	return 0;
}

void binSearch(U_L_LONG prm1, U_L_LONG prm2)
{

}

static void C_4divN()
{
	const L_LONG ConstVal = 4;
	const L_LONG UpperLimit = 3500;
	const L_LONG SqUpperLim = 3500 * 3500;

	L_LONG N = 0, h = 0, n = 0, w = 0;

	scanf(" %lld", &N);
	//	-------------------------------
	//	4/N = 1/h + 1/w + 1/n
	//	α = hn/(n + h) とすると
	//	1/α + 1/w = 4/N
	//	→	4αw = N(a + w) 
	//	-------------------------------


	bool find = false;
	for (n = 1; n <= UpperLimit; n++) {
		for (h = 1; h <= UpperLimit; h++) {
			L_LONG numer = N * (h * n);
			L_LONG denom = (ConstVal * h * n) - (N * (n + h));
			
			if ((denom != 0) &&
				((numer / denom) > 0) &&
				((numer % denom) == 0)) {
				find = true;
				w = numer / denom;
				break;
			}

		}
		if (find) {
			break;
		}
	}

	printf("%llu %llu %llu\n", h, n, w);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
//TLEだが成長した

// int main(){
//     int n;
//     cin >> n;
//     vector<int>A(n);
//     REP(i,n){cin >> A[i];}
//     int q,m;
//     cin >> q;
//     REP(k,q){
//         bool flag = false;
//         cin >> m;
//         for(int bit = 0; bit < (1<<n);++bit){
//             int sum = 0;
//             vector<int>S;
//             REP(i,n)if(bit &(1<<i))S.push_back(i);
//             REP(i,(int)S.size()){sum += A[S[i]];}
//             if(sum == m ){flag = true;break;}
//         }
//         if(flag){cout << "yes" << endl;}
//         else{cout << "no" << endl;}
//     }
//     return 0;
// }

int n,A[50];
int solve(int i, int m){
    if(m == 0)return 1;
    if(i >= n)return 0;
    int res = solve(i+1,m)||solve(i + 1,m - A[i]); //tf
    return res;
}
int main(){
    int q,M,i;
    cin >> n;
    REP(i,n){cin >> A[i];}
    cin >> q;
    REP(i,q){
        cin >> M;
        if(solve(0,M))cout<<"yes"<<endl;
        else cout << "no" << endl;
    }
    return 0;
}


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

int main(){
  int n,m; cin>>n>>m;
  vector<pair<int,int>>vec;
  for(int i=0;i<n;i++){
    int a,b; cin>>a>>b;
    vec.push_back(make_pair(a,-b));
  }
  sort(vec.begin(),vec.end());
  int64_t sum1=0; int sum2=0;
  int yes=0;
  for(int i=0;i<n;i++){
    for(int j=1;j<=vec[i].second*(-1);j++){
      sum1+=vec[i].first;
      sum2++;
      if(sum2>=m){
        yes=1;
        break;
      }
    }
    if(yes==1) break;
  }
  cout<<sum1<<endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, ll> T;

int N;
vector<int> x(101, 0);
vector<int> y(101, 0);
vector<ll> h(101, 0);

int main(void){
    
	scanf("%d", &N);
	for(int i = 0; i < N; ++i) scanf("%d %d %lld", &x[i], &y[i], &h[i]);
	
	vector<T> v;
	for(int i = 0; i <= 100; ++i){
	    for(int j = 0; j <= 100; ++j){
	        for(int k = 0; k < N; ++k){
	            v.push_back(make_tuple(i, j, h[k] + abs(i - x[k]) + abs(j - y[k])));
	        }
	    }
	}
	
	for(int i = 0; i < v.size(); ++i){
	    int a, b; ll c; tie(a, b, c) = v[i];
	    int cnt = 0;
	    for(int j = 0; j < N; ++j){
	        
	        if(h[j] == max(c - abs(x[j] - a) - abs(y[j] - b), (ll)0)) ++cnt;
	    }
	    if(cnt == N) { printf("%d %d %lld\n", a, b, c); return 0; }
	}
	
    return 0;
}

Measured memory_bytes: 18796
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

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

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

	int m2 = pow(2, M);

	int ans = (100 * (N-M) + 1900 * M) * m2;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }


int main(){
    string s; cin >> s;
    int out=0;
    if(s=="SUN") out = 7;
    if(s=="MON") out = 6;
    if(s=="TUE") out = 5;
    if(s=="WED") out = 4;
    if(s=="THU") out = 3;
    if(s=="FRI") out = 2;
    if(s=="SAT") out = 1;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int N, M, masu[1000], num[1000], i, count, j;

  while(1){
    scanf("%d%d", &N, &M);
    if(N == 0 && M == 0) break;

      for(i = 0; i < N; i++) scanf("%d", &masu[i]);
      for(i = 0; i < M; i++) scanf("%d", &num[i]);

      count = 0, j = 0;

      for(i = 0; i < M; i++){
	j += num[i];
	j += masu[j];
	count++;
	if(j >= N) break;
      }
	printf("%d\n", count);
  }
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll s;
    while(cin>>s){
        ll t = s;
        ll x = sqrt(s);
        if(x*x>=s) t = x*x;
        else{
            x++;
            t=x*x;
        }
        ll x1,x2,y1,y2;
        x1 = y2 = x;
        x2 = 1, y1 = t-s;
        cout<<0<<' '<<0<<' '<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<endl;
    }
}


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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vp;

int main()
{
	int a, b;
	sii(a, b);
	int ans = -1;
	for(int i = 1; i <= 10000; i++)
	{
		if((i*8)/100 == a && (i/10) == b)
		{
			ans = i;
			break;
		}
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N;
	cin >> N;
	int ans = 0;

	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		ans += tmp - 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if ( a < b ) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if ( a > b ) { a = b; return 1; } return 0;}

const ll INF = 1LL << 60;
const int MAX = 100010;

// input 
int N;
ll h [MAX];

// dp table
ll dp[MAX];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; i++) cin >> h[i];

    // init
    for (int i = 0; i < MAX; i++) dp[i] = INF;
    
    dp[0] = 0;

    // loop
    for (int i = 1; i < N; i++) {
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i - 2]));
    }

    // 0-index
    cout << dp[N-1] << '\n';
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];
ll gcd(ll a,ll b){
   if (a%b == 0){
        return(b);
    }
   else{
       return(gcd(b, a%b));
    }
}
//ax+by=gcd(a,b)を満たす(x,y)
ll extgcd(ll a,ll b,ll &x,ll &y){
    ll d=a;
    if(b==0){
      x=1,y=0;
    }
    else{
      d=extgcd(b,a%b,y,x);
      y-=(a/b)*x;
    }
    return d;
}
//最小公倍数
ll lcm(ll a,ll b){
   return (a  / gcd(a, b))*b;
}


int main(){
  ll n,ans=1LL;cin>>n;
  rep(i,0,n){
    ll a;cin>>a;
    ans=lcm(ans,a);
    
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#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())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
  double n;
  cin >> n;
  double sum = 0;
  FOR(i,0,n-1) {
    double a;
    cin >> a;
    sum += 1/a;
  }

  cout << 1/sum << endl;





}



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

int main(){
    int n;
    set<int> data;
    bool flag = true;
    cin>>n;

    for(int i=0; i<n; i++)
    {
        int a;
        cin>>a;
        if(data.count(a)){
            flag = false;
            break;
        }
        data.insert(a);
    }

    if(flag) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;

}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); ++i)
typedef long long ll;
int main(){
    ll n,m; cin >> n >> m;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    ll asum[n+1]; asum[0] = 0; rep(i,n) asum[i+1] = asum[i] + a[i];
    map<ll,ll> memo; rep(i,n+1) memo[asum[i]%m]++;
    ll ans = 0; for(auto i: memo) ans += i.second*(i.second-1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 5760