akhauriyash/Code-Regression huggingface dataset:
// abc166_f
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, A, B, C;
    cin >> N >> A >> B >> C;

    map<string, int> mp;
    mp["AB"] = 0;
    mp["BC"] = 1;
    mp["AC"] = 2;

    vector<int> Q(N);
    REP(i, N) {
        string S;
        cin >> S;
        Q[i] = mp[S];
    }

    vector<int> card{A, B, C};
    string abc = "ABC";
    vector<char> ans;

    REP(i, N){
        int x = Q[i];
        int y = (Q[i] + 1) % 3;

        if (card[x] == 0 && card[y] == 0){
            print("No");
            return 0;
        } else if (card[x] == 0){
            card[x]++; card[y]--;
            ans.emplace_back(abc[x]);
        } else if (card[y] == 0){
            card[y]++; card[x]--;
            ans.emplace_back(abc[y]);
        } else {
            if (i == N-1){
                card[x]++; card[y]--;
                ans.emplace_back(abc[x]);
            } else {
                int nx = Q[i+1];
                if ((3 + nx - x) % 3 == 2){
                    card[x]++; card[y]--;
                    ans.emplace_back(abc[x]);
                } else {
                    card[y]++; card[x]--;
                    ans.emplace_back(abc[y]);
                }
            }
        }
    }

    print("Yes");
    REP(i, N){
        print(ans[i]);
    }

    return 0;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int h, w, n;
    cin >> h >> w >> n;
    cout << (int)ceil((double)n/max(h, w)) << endl;
    // printf("%d\n", N);
    return 0;
}

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

#define MAX 100000

int N;
long long A, B;
long long X[MAX];

int main() {
	cin >> N >> A >> B;
	for( int i = 0; i < N; i++ ) {
		cin >> X[i];
	}

	long long ans = 0;
	for( int i = 0; i < N - 1; i++ ) {
		ans += min( A * ( X[i + 1] - X[i] ), B );
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    ll N, X;
    cin >> N >> X;
    vector<ll> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x.at(i);
    }

    ll ans = abs(X - x[0]);
    for (int i = 0; i < N; i++) {
        ans = __gcd(abs(X - x[i]), ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
long long dp[61][2][2][2];
int main(){
	long long a,b;
	scanf("%lld%lld",&a,&b);
	dp[60][0][0][0]=1;
	for(int i=60;i>0;i--){
		for(int j=0;j<2;j++)for(int k=0;k<2;k++)for(int l=0;l<2;l++){
			if(!dp[i][j][k][l])continue;
			if(j==0){
				int tk=k;
				int tl=l;
				if(l==1||(b&(1LL<<(i-1)))){
					if(!(a&(1LL<<(i-1))))tk=1;
					dp[i-1][1][tk][l]=(dp[i-1][1][tk][l]+dp[i][j][k][l])%mod;
				}
				if(k==1||!(a&(1LL<<(i-1)))){
					if(b&(1LL<<(i-1)))tl=1;
					dp[i-1][0][k][tl]=(dp[i-1][0][k][tl]+dp[i][j][k][l])%mod;
				}
			}else{
				if(l==1||(b&(1LL<<(i-1)))){
					int tk=k;
					if(!(a&(1LL<<(i-1))))tk=1;
					dp[i-1][1][tk][l]=(dp[i-1][1][tk][l]+dp[i][j][k][l])%mod;
					if(k==1||!(a&(1LL<<(i-1)))){
						dp[i-1][1][k][l]=(dp[i-1][1][k][l]+dp[i][j][k][l])%mod;
					}
				}
				if(k==1||!(a&(1LL<<(i-1)))){
					int tl=l;
					if(b&(1LL<<(i-1)))tl=1;
					dp[i-1][1][k][tl]=(dp[i-1][1][k][tl]+dp[i][j][k][l])%mod;
				}
			}
		}
	}
	long long ret=0;
	for(int i=0;i<2;i++)for(int j=0;j<2;j++)
		ret+=dp[0][1][i][j];
	ret%=mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 128
import java.util.Scanner;

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

    	while(true){
        	int H = scan.nextInt();
        	int W = scan.nextInt();

        	if(H == 0 && W == 0) break;

        	for(int i = 0; i < H; i++){
        		for(int j = 0; j < W; j++){
        			System.out.print("#");
        		}
        		System.out.println();
        	}
        	System.out.println();
    	}

    }
}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


ll dist(ll x1, ll y1, ll x2, ll y2) {
    return abs(x2 - x1) + abs(y2 - y1);
}

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

    vl a(n), b(n), c(m), d(m);
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, m) cin >> c[i] >> d[i];

    rep(i, n) {
        int mi = 0;
        rep(j, m) {
            if (dist(a[i], b[i], c[j], d[j]) < dist(a[i], b[i], c[mi], d[mi]))
                mi = j;
        }
        cout << mi + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	private boolean check(String s, String t) {
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != '?') {
				if (s.charAt(i) != t.charAt(i)) {
					return false;
				}
			}
		}
		return true;
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		String S = sc.next();
		String T = sc.next();

		sc.close();

		int x = -1;

		for (int si = S.length() - T.length(); si >= 0; si--) {
			String s2 = S.substring(si, si + T.length());
			if (check(s2, T)) {
				x = si;
				break;
			}
		}

		if (x == -1) {
			out.println("UNRESTORABLE");
			return;
		}

		StringBuffer sb = new StringBuffer(S);
		sb.replace(x, x + T.length(), T);

		String ans = sb.toString().replace("?", "a");

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 23124
// AOJ 0577
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int num[256][3], ret[256] = {};
	for (int i = 0; i < n; i++){
		for (int j = 0; j < 3; j++){
			cin >> num[i][j];
		}
	}

	for (int j = 0; j < 3; j++){
		map <int, int> d;
		for (int i = 0; i < n; i++){
			d[num[i][j]]++;
		}
		for (int i = 0; i < n; i++){
			if (d[num[i][j]] == 1){
				ret[i] += num[i][j];
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>

int main(void) {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  if (a == b && b != c) printf("%d", c);
  else if (a != b && b == c) {
    printf("%d", a);
  }
  else if (a == c && c != b) {
    printf("%d", b);
  }

  return 0;
}


Measured memory_bytes: 128
N = gets.chomp.to_i
array = gets.chomp.split(' ').map{|p| p.to_i}.sort
result = 0

N.times do |index|
    if index==0
        result = array[0]
    else
        result *= array[index]
        break if 10**18 < result || result == 0
    end
end
if 10**18 >= result
    puts result
else
    puts -1
end

Measured memory_bytes: 24988
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n, m = sc.nextInt
    val p = new Array[Int](m)
    val s = new Array[String](m)
    for (i <- 0 until m) {
      p(i) = sc.nextInt
      s(i) = sc.next
    }
    val acNos = scala.collection.mutable.Set[Int]()
    val penaCounts = scala.collection.mutable.Map[Int, Int]()
    var acs = 0
    for (i <- 0 until m) {
      if (!acNos.contains(p(i))) {
        if (s(i) == "AC") {
          acs += 1
          acNos += p(i)
        } else if (s(i) == "WA") {
          penaCounts.put(p(i), penaCounts.getOrElse(p(i), 0) + 1)
        }
      }
    }

    var penas = 0
    for(i <- acNos.toList) {
      val penaConunt = penaCounts.getOrElse(i, 0)
      penas += penaConunt
    }

    println(acs + " " + penas)
  }

}


Measured memory_bytes: 75980
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b = rs()
n = int(a+b)
c = int(n**0.5)**2
if n == c:
    print('Yes')
else:
    print('No')















Measured memory_bytes: 27152
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;

int sx,sy,n,tmpx,tmpy,nx[10],ny[10];

bool func(){
	int dx[12]={-2,-2,-2,-1,-1,0,0,1,1,2,2,2};
	int dy[12]={1,0,-1,2,-2,2,-2,2,-2,1,0,-1};
	int wx[9]={-1,-1,-1,0,0,0,1,1,1},wy[9]={1,0,-1,1,0,-1,1,0,-1};
	queue<P> que;
	que.push(P(sx,sy));
	for(int i=0;i<n;i++){
		char field[11][11]={0};
		for(int j=0;j<9;j++){
			int cnx=nx[i]+wx[j],cny=ny[i]+wy[j];
			if(cnx>=0&&cnx<=9&&cny>=0&&cny<=9){
				field[cnx][cny]='!';
			}
		}
		for(int j=que.size();j>0;j--){
			for(int k=0;k<12;k++){
				tmpx=que.front().first+dx[k];
				tmpy=que.front().second+dy[k];
				if(tmpx>=0&&tmpx<=9&&tmpy>=0&&tmpy<=9&&field[tmpx][tmpy]=='!'){
					field[tmpx][tmpy]='?';
					que.push(P(tmpx,tmpy));
					if(i==n-1) return true;
				}
			}
			que.pop();
		}
	}
	return false;
}

int main(){
	while(1){
		cin>>sx>>sy;
		if(sx==0&&sy==0) break;
		cin>>n;
		for(int i=0;i<n;i++){
			cin>>nx[i]>>ny[i];
		}
		if(func()) cout<<"OK"<<endl;
		else cout<<"NA"<<endl;
	}
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,k;
    cin >> n >> k;
    ll a[n];
    // memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++)
        cin >> a[i];
   
    set<int> vis;
    // dfs(1,adj,vis);
    int len = 0;
    int cur = 1;
    vector<int> dp;
   
    int last = -1;
    while( true )
    {
        vis.insert(cur);
        dp.push_back(cur);
        cur = a[cur-1];
        if(vis.find(cur)!=vis.end())
        {
            last = cur;
            break;
        }
        
        
    }
    // for(int i=0;i<dp.size();i++)
    //     cout << dp[i] << " ";
    // cout << endl;

    len = 0;
    for(int i=dp.size()-1;i>=0;i--)
    {
        if(dp[i]==last)
        {
            len+=1;
            break;
        }
        len++;
    }
    // cout << len << endl;
    int ind = 0;
    for(int i=0;i<dp.size();i++)
    {
        if(dp[i]==last)
        {
            ind = i;
            break;
        }
    }
    // cout << ind << endl;
    if(k<=ind)
    {
        cout << dp[k] << endl;
    }
    else if(k>ind){
        
    
        
        k = (k-ind)%(len);
        // cout<<k<<endl;
        cout << dp[ind+k] << endl;
    }
    
}

Measured memory_bytes: 14508
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;


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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

template<int mod>
struct Modint{
    int x;
    Modint():x(0){}
    Modint(int64_t y):x((y%mod+mod)%mod){}

    Modint &operator+=(const Modint &p){
			if((x+=p.x)>=mod)
				x -= mod;
			return *this;
		}

		Modint &operator-=(const Modint &p){
			if((x+=mod-p.x)>=mod)
				x -= mod;
			return *this;
		}

		Modint &operator*=(const Modint &p){
			x = (1LL * x * p.x) % mod;
			return *this;
		}

		Modint &operator/=(const Modint &p){
			*this *= p.inverse();
			return *this;
		}

		Modint operator-() const { return Modint(-x); }
		Modint operator+(const Modint &p) const{
			return Modint(*this) += p;
		}
		Modint operator-(const Modint &p) const{
			return Modint(*this) -= p;
		}
		Modint operator*(const Modint &p) const{
			return Modint(*this) *= p;
		}
		Modint operator/(const Modint &p) const{
			return Modint(*this) /= p;
		}

		bool operator==(const Modint &p) const { return x == p.x; }
		bool operator!=(const Modint &p) const{return x != p.x;}

		Modint inverse() const{//非再帰拡張ユークリッド
			int a = x, b = mod, u = 1, v = 0;
			while(b>0){
				int t = a / b;
				swap(a -= t * b, b);
				swap(u -= t * v, v);
			}
			return Modint(u);
		}

		Modint pow(int64_t n) const{//繰り返し二乗法
			Modint ret(1), mul(x);
			while(n>0){
				if(n&1)
					ret *= mul;
				mul *= mul;
				n >>= 1;
			}
			return ret;
		}

		friend ostream &operator<<(ostream &os,const Modint &p){
			return os << p.x;
		}
};

using modint = Modint<mod>;


void solve(){
	int n;
	cin>>n;
	vector<ll>a(n);
	rep(i,n)cin>>a[i];
	modint ans=0;
	vector<modint>sum(n+1);
	rep(i,n){
		sum[i+1]=sum[i]+a[i];
	}
	REP(i,1,n){
		ans+=sum[i]*a[i];
	}
	cout<<ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 5532
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    int n; cin>>n;
    vector <int> b(n-1) ,a(n); 
    rep(i,n-1) cin>>b[i];
    a[0] = b[0];
    rep(i,n-2){
        a[i+1] = min(b[i], b[i+1]);
    }
    a[n-1] = b[n-2];
    int ans = 0;
    rep(i, n) ans += a[i];
    cout<<ans<<endl;
}


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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll lcm = c * d / __gcd(c, d);
  ll n1 = b / c + b / d - b / lcm;
  a --;
  ll n2 = a / c + a / d - a / lcm;
  cout << b - a - n1 + n2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,u,d,c,z,v=0;
	cin>>u>>a>>b;
	d=u+b;
	c=u+a;
	if(a>=b&&c>=d&&d>=a)
	{
		
		cout<<v;
	}
	else if(a>=b&&d>=c&&c>=a)
	{
		
		cout<<v;
	}
	else if(b>=a&&d>=c&&c>=b)
	{
		
		cout<<v;
	}
	else if(b>=a&&c>=b&&d>=b)
	{
		
		cout<<v;
	}
	else
	{
		if(b>c)
		{
			v=b-c;
			cout<<v;
		}
		else if(a>=d)
		{
			v=a-d;
			cout<<v;
		}
	}
	return 0;
}

Measured memory_bytes: 256
(defun int-to-digit (n &key (base 10)) ;; (int-to-digit 123) => (1 2 3)
  (if (zerop n)
      `(0)
      (labels ((rec (n list)
                 (if (= n 0)
                     list
                     (rec (floor n base) (cons (rem n base) list)))))
        (rec n nil))))

(defun palindromep (n &key (base 10)) ;; (palindromep 12321) => t
  (equal (reverse (int-to-digit n :base base)) (int-to-digit n :base base)))

(defun solver ()
  (let ((a (read)) (b (read)) (count 0))
    (loop for i from a to b do
          (when (palindromep i)
            (incf count)))
    (format t "~a~%" count)))

(solver)

Measured memory_bytes: 26984
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort()
ans=0
for i in range(n):
    if m>ab[i][1]:
        ans+=ab[i][0]*ab[i][1]
        m-=ab[i][1]
    else:
        ans+=ab[i][0]*m
        print(ans)
        break

Measured memory_bytes: 27300
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
// #include <atcoder/all>

using boost::multiprecision::cpp_int;
using namespace std;
// using namespace atcoder;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 998244353

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

typedef long long ll;
typedef pair<ll, ll> p;

struct mint {
  ll x; // typedef long long ll;
  mint(ll 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(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<p> v(k);
  rep(i, k) cin >> v[i].first >> v[i].second;
  sort(ALL(v));
  vector<mint> dp(n+5, 0);
  dp[1] = 1;
  for (int i = 2; i < n+4; ++i) {
    rep(j, k){
      int from = v[j].first;
      int to = v[j].second;
      dp[i] += dp[max(0, i-from)] - dp[max(0, i-to-1)];
    }
    dp[i] += dp[i-1];
  }

  cout << (mint)dp[n] - dp[n-1] << endl;

}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/04  Problem: ABC 097 B / Link: http://abc097.contest.atcoder.jp/tasks/abc097_b  ----- */


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

	LL N; 
	cin >> N;

	LL ans = 1;
	FOR(i, 2, N) {
		LL ret = i;
		while (ret*i <= N) {
			ret *= i;
			ans = max(ans, ret);
		}
	}
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int a[2][230];
//int t[100005] , x[100005] , y[100005];
int main(){
	dhoom;
	int n , a;
	cin >> n >> a;
	n = n%500;
	if(a >= n)
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
/*
  A - AtCoDeer and Paint Cans
  Contest 046
  Rakesh Kumar --> 03/08/2020
 */

#include <bits/stdc++.h>

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

    int a = 0, b = 0, c = 0;
    std::cin >> a >> b >> c;
    std::set<int> cans = {a, b, c};
    std::cout << cans.size() << std::endl;

    return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    string s;
    cin >> s;

    if (n % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    rep(i, 0, n / 2) {
        if (s[i] != s[i + n / 2]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef unsigned long long ull; 
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const int INF = 1e18;
const int M = 1e9 + 7;
//__int128


signed main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif
    int n, d;
    cin >> n >> d;
    int x = 2 * d + 1;
    cout << (n + x - 1) / x << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
int a[maxn];
int b[maxn];
int main()
{
    int k,n;
    scanf("%d%d",&k,&n);
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);
    int maxn=0;
    int t=0;
    ll ans=0;
    for(int i=1; i<n; i++)
    {
        b[i]=abs(a[i]-a[i-1]);
        ans+=b[i];
        if(b[i]>maxn)
        {
            t=i;
            maxn=b[i];
        }
    }
    b[n]=k-a[n-1]+a[0];
    ans+=b[n];
    if(b[n]>maxn)t=n;
    printf("%lld",ans-b[t]);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N, K;
    cin >> N >> K;
    vec P(N), C(N);
    Rep (i, N) {
        cin >> P[i];
        P[i]--;
    }
    Rep (i, N) {
        cin >> C[i];
    }

    ll ans = -inf;

    Rep (i, N) {
        ll now = i;
        vector<bool> visited(N, false);
        ll scorePerLoop = 0;
        ll cnt = 0;
        while (!visited[now]) {
            visited[now] = true;
            now = P[now];
            scorePerLoop += C[now];
            cnt++;
        }

        ll loops = K / cnt, rem = K % cnt;

        if (loops) {
            loops--;
            rem += cnt;
        }
        ll tmp = max<ll>(scorePerLoop, 0) * loops;
        ll highest = -inf;
        while (rem--) {
            now = P[now];
            tmp += C[now];
            chmax(highest, tmp);
        }
        chmax(ans, highest);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3744
using System;
using System.IO;
using System.Linq;

class Program
{
    static void Solve()
    {
        var inputs = ReadInts();
        Console.WriteLine((inputs[0] - inputs[2]) * (inputs[1] - inputs[2]) < 0 ? "Yes" : "No");
    }

    static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }

    public static string Read() { return Console.ReadLine(); }
    public static int ReadInt() { return int.Parse(Read()); }
    public static long ReadLong() { return long.Parse(Read()); }
    public static double ReadDouble() { return double.Parse(Read()); }

    public static string[] Reads() { return Console.ReadLine().Split(' '); }
    public static int[] ReadInts() { return Reads().Select(_ => int.Parse(_)).ToArray(); }
    public static long[] ReadLongs() { return Reads().Select(_ => long.Parse(_)).ToArray(); }
    public static double[] ReadDoubles() { return Reads().Select(_ => double.Parse(_)).ToArray(); }
}

Measured memory_bytes: 11348
N = gets.to_i
as = gets.split.map(&:to_i)

hash = Hash.new(0)
as.each do |a|
  hash[(a-1).to_s] += 1
  hash[a.to_s] += 1
  hash[(a+1).to_s] += 1
end

puts hash.max_by { |k, v| v }[1]

Measured memory_bytes: 22404
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    s = 0
    init = i
    while i > 0:
        i, r = divmod(i, 10)
        s += r
    if s >= a and s <= b:
        ans += init
print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  ll a,b,c=0;
  cin>>a>>b;
  b++;
  for(ll i=2;i<100000000000000;i*=2){
    ll d=a/i*(i/2)+max(0LL,a%i-i/2),e=b/i*(i/2)+max(0LL,b%i-i/2);
    if((e-d)%2==1) c+=i/2;
  }
  cout<<c;
}


Measured memory_bytes: 256
x, y = map(int, input().split())
if x * y > 0:
    if x < y:
        ans = abs(x - y)
    else:
        ans = abs(x - y) + 2
elif x * y < 0:
    ans = abs(abs(x) - abs(y)) + 1
else:
    if x < y:
        ans = abs(x - y)
    else:
        ans = abs(x - y) + 1
print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        
        // ans: 2点間距離の最大値(マンハッタン距離)
        
        // how:
        // 答えの候補は、「／」or「＼」
        // -> ／ = → + ↑ (x + y)
        // -> ＼ = → + ↓ (x - y)
        // -> 答えは「max(x+y) - min(x+y)」or「max(x-y) - min(x-y)」
        
        // 二次元座標を反時計回りに45度回転させると、
        // 縦軸が(x+y)軸、横軸が(x-y)軸になる
        // -> 答えは一番右の点から一番左の点までの距離or一番上の点から一番下の点までの距離
        
        int[] x_plus_y = new int[n];
        int[] x_minus_y = new int[n];
        for (int i = 0; i < n; i++) {
            x_plus_y[i] = x[i] + y[i];
            x_minus_y[i] = x[i] - y[i];
        }
        
        Arrays.sort(x_plus_y);
        Arrays.sort(x_minus_y);
        
        int left = x_minus_y[0];
        int right = x_minus_y[n-1];
        int up = x_plus_y[0];
        int down = x_plus_y[n-1];
        
        int ans = Math.max(right-left, down-up);
        System.out.println(ans);
    }
}

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

int main() {
  string S;
  cin>>S;
  reverse(S.begin(), S.end());
  
  string T="";
  int a=0,N=S.size();
  while(a<N-1){
    if(S.at(a)=='m'){
      T+="maerd";
      a+=5;
    }
    else if(S.at(a)=='r'&&S.at(a+1)=='e'&&S.at(a+2)=='m'){
      T+="remaerd";
      a+=7;
    }
    else if(S.at(a)=='e'){
      T+="esare";
      a+=5;
    }
    else if(S.at(a)=='r'&&S.at(a+1)=='e'&&S.at(a+2)=='s'){
      T+="resare";
      a+=6;
    }
    else{
      break;
    }
  }
  if(T==S){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 768
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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 <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int n;s(n);
	ll d;cin>>d;
	d*=d;
	
	int count = 0;
	for(int i = 0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		ll val = x*x + y*y;
		
		if(d >= val) count++;
	}
	
	cout<<count<<endl;
	
	return 0;
}

Measured memory_bytes: 3760
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFerrisWheel solver = new AFerrisWheel();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFerrisWheel {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (a >= 13) out.println(b);
            else if (a > 5) out.println(b / 2);
            else out.println(0);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>

using namespace std;
#define set_precision cout << fixed << setprecision(10)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define replb(i, a, b) for (ll i = a; i >= b; i--)
#define repl(i, a, b) for (ll i = a; i < b; i++)
#define repit(arr) for (auto it = arr.begin(); it != arr.end(); it++)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define search(arr, c) binary_search(arr.begin(), arr.end(), c)
#define pb push_back
#define ll long long
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define castl static_cast<ll>
int fact(int n) 
{ 
    int res = 1; 
    for (int i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
}
int nCr(int n, int r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
}
int cel(int a,int b){return((a-1)/b+1);} 
int gcd(int a, int b)
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a,int b){
    return (a*b)/gcd(a,b);
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t, n;
    cin >> n;
    if(n%1000==0)cout<<0;
    else cout<<1000-(n%1000);
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

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

Measured memory_bytes: 3628
import math

n = int(input())
a = [int(i) for i in input().split(" ")]

sum_length = sum(a)
min_diff = 1e18
r = 0

for i in range(len(a)):
    r += a[i]
    l = sum_length - r
    if(abs(r - l) <= min_diff):
        min_diff = abs(r - l)
        
print(min_diff)

Measured memory_bytes: 25948
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから

void solve(){
  int n,m,q;
  cin>>n>>m>>q;
  vector<vector<int>>sum(n+5,vector<int>(n+5)),cnt(n+2,vector<int>(n+2));
  rep(i,m){
    int l,r;
    cin>>l>>r;
    l--;r--;
    cnt[l][r]++;
  }
  rep(i,n){
    rep(j,n)sum[i+1][j+1]=sum[i+1][j]+sum[i][j+1]-sum[i][j]+cnt[i][j];
  }
  rep(i,q){
    int p,qq;
    cin>>p>>qq;
    qq--;p--;
    cout<<sum[qq+1][qq+1]+sum[p][p]-sum[qq+1][p]-sum[p][qq+1]<<"\n";
  }
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> dp(m+1, vector<int>(1<<n, INF));
    rep(i, m+1) dp[i][0] = 0;

    debug(dp[0]);
    rep(i, m) {
        int cost, box; cin >> cost >> box;
        int x = 0;
        rep(j, box) {
            int y; cin >> y; y--;
            x += 1<<y;
        }
        rep(j, 1<<n) {
            int z = x|j;
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            dp[i+1][z] = min(dp[i][j]+cost, dp[i+1][z]);
        }
        debug(dp[i+1]);
    }
    int ans = dp[m][(1<<n)-1];
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 16256
# 英小文字 c が与えられるので、c が母音であるか判定してください。

# 英小文字を取得
word = gets.chomp

# 結果を格納する変数を宣言
result = String.new

# 英小文字が母音かどうか判定
case word
when "a", "i", "u", "e", "o"
  result = "vowel"
else
  result = "consonant"
end

# 結果を出力
puts result

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;
typedef unsigned long long ull;

inline int scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int sum = a+b;
    ll ans = 0;
    if(sum < c*2)
    {
        ans += sum*min(x, y);
        if(x > y)
        {
            if(c*2 > a)ans += a*(x-y);
            else ans += 2*c*(x-y);
        }
        else
        {
            if(c*2 > b)ans += b*(y-x);
            else ans += 2*c*(y-x);
        }
    }
    else
    {
        ans += c*2*min(x, y);
        if(x > y)
        {
            if(c*2 > a)ans += a*(x-y);
            else ans += 2*c*(x-y);
        }
        else
        {
            if(c*2 > b)ans += b*(y-x);
            else ans += 2*c*(y-x);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>


using namespace std;


int main()
{
    string s;
    cin>>s;
    int ans,cnt;
    for( ans=0;ans<s.size();ans++)
    if(s[ans]=='A')
    break;
    for(cnt=s.size();cnt>=0;cnt--)
    if(s[cnt]=='Z')
    break;
    cout<<cnt-ans+1; 

    return 0;
}    

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int G[10][10];

signed main()
{
    int N,M; cin>>N>>M;
    REP(i,M){
        int a,b; cin>>a>>b;
        a--; b--;
        G[a][b]=G[b][a]=1;
    }
    
    vint a(N);
    REP(i,N) a[i]=i;
    int ans=0;
    do{
        bool ok=true;
        REP(i,N-1) ok&=G[a[i]][a[i+1]];
        if(ok) ans++;
    }while(next_permutation(a.begin()+1,a.end()));
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
A.sort()
A.append(0)
index = 0
ans = 0

while index <= n-1:
    x = A[index]
    j = index+1
    while True:
        if A[j] != x:
            if j-index < x:
                ans += j-index
                index = j
                break
            elif j-index == x:
                index = j
                break
            elif j-index > x:
                ans += j-index-x
                index = j
                break
        else:
            j += 1

print(ans)

Measured memory_bytes: 14692
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)
#define Int long long

int min(int a,int b){
  if(a<b) return a;
  return b;
}
int max(int a,int b){
  if(a>b) return a;
  return b;
}

int gcd(Int a, Int b) {
  return b != 0 ? gcd(b, a % b) : a;
}
int lcm(Int a, Int b) {
  return a / gcd(a, b)*b;
}
// a x + b y = gcd(a, b)
int extgcd(Int a, Int b, Int &x, Int &y) {
  Int g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}

vector<int> g[100010];
int done[100010];



signed main(){
  int n;
  cin>>n;
  lp(i,n-1){
    int a,b;
    cin>>a>>b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  queue<pair<int,int>> q;
  q.push({1,0});
  q.push({n,1});
  done[1]=1;
  done[n]=1;
  int ans[2]={0,0};
  while(!q.empty()){
    int now=q.front().first;
    int color=q.front().second;
    q.pop();
    ans[color]++;
    lp(i,g[now].size()){
      int next=g[now][i];
      if(done[next]==1)continue;
      done[next]=1;
      q.push({next,color});
    }
  }
  if(ans[0]>ans[1])cout<<"Fennec"<<endl;
  else cout<<"Snuke"<<endl;
  return 0;
}
 


Measured memory_bytes: 7424
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

bool ismonth(int x) {
    if (1 <= x && x <= 12) {
        return true;
    }
    return false;
}

void solve(){
    int x;
    cin >> x;

    int head = x / 100, tail = x % 100;
    if (ismonth(head)) {
        if (ismonth(tail)) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else if (ismonth(tail)) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }


    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  int a;
  int count = 0;
	cin >> a ;
  for (int i = 1; i <= a; i++) {
    if (to_string(i).size() % 2 == 1)
      count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
cnt = 0
for i in range(n):
    dm = min(a[i], b[i])
    a[i] -= dm; b[i] -= dm; cnt += dm
    dmn = min(a[i + 1], b[i])
    a[i + 1] -= dmn; b[i] -= dmn; cnt += dmn
print(cnt)

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

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

  for (int i = A; i <= B; i++) {
    if (i % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}

Measured memory_bytes: 3576