akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = s; i < b; i+=d)
#define lpsb(i, s, b) for(size_t i = s; i < b; i++)
#define lpn(i, n) for(size_t i = 0; i < n; i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)

using namespace std;
using ull = unsigned long long;

const ull MOD = 1000000007;

int main(void)
{
    int N, M;
    cin >> N >> M;
    int k;
    auto s = vc(vector<int>, M);
    auto p = vc(bool, M);
    int temp;
    fa(i, s)
    {
        cin >> k;
        i.resize(k);
        fa(j, i)
        {
            cin >> temp;
            j = 1 << (temp - 1);
        }
    }
    for(auto &&i: p)
    {
        cin >> temp;
        i = temp == 1;
    }
    int ans = 0;
    int i;
    bool sum;
    for (int bit = (1 << N) - 1; bit >= 0; bit--)
    {
        for (i = 0; i < M; i++)
        {
            sum = false;
            fa(j, s[i]) sum = sum != bool(bit & j);
            if (sum != p[i]) break;
        }
        if (i == M) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

const int MAXN = 81000;

int dp[MAXN][11];

int main(void) {
    string s;
    while (cin >> s) {
        if (s == "0") break;
        int n = s.size();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 11; j++) {
                dp[i][j] = 0;
            }
        }
        int first = s[0] - '0';
        if (first != 0) dp[0][first] = 1;
        for (int i = 1; i < n; i++) {
            int tmp = s[i] - '0';
            if (tmp != 0) dp[i][tmp] += 1;
            for (int j = 0; j < 11; j++) {
                int tmp1 = (j * 10 + tmp) % 11;
                dp[i][tmp1] += dp[i-1][j];
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans += dp[i][0];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4752
#include <iostream>
#include <stdlib.h>
#define llint long long

using namespace std;

llint N;
llint x[105], y[105], h[105];

llint dist(llint x, llint y, llint a, llint b){
	return abs(x-a) + abs(y-b);
}

int main(void)
{
	cin >> N;
	for(int i = 1; i <= N; i++) cin >> x[i] >> y[i] >> h[i];
	
	for(int cx = 0; cx <= 100; cx++){
		for(int cy = 0; cy <= 100; cy++){
			llint lb = 0, ub = 1e18;
			bool flag = true;
			for(int i = 1; i <= N; i++){
				llint H = h[i]+dist(x[i], y[i], cx, cy);
				if(h[i] == 0) ub = min(ub, H);
				else{
					if(H >= lb && H <= ub) lb = ub = H;
					else{
						flag = false;
						break;
					}
				}
			}
			if(ub == lb && flag){
				cout << cx << " " << cy << " " << ub << endl;
				return 0;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
int main(){
    ll n,k;
    cin >> n >> k;
    vl count(n,0);
    rep(i,n){
        int a;cin >> a;
        count[a-1]++;
    }
    sort(all(count));
    reverse(all(count));
    ll ans=0;
    rep(i,k){
        ans+=count[i];
    }
    cout << n-ans << endl;
}

Measured memory_bytes: 1792
def sum_from_1(n):
    return n * (n + 1) // 2


def main():
    n, k = map(int, input().split())
    answer = 0
    mod = 10 ** 9 + 7
    for i in range(k, n + 2):
        answer += sum_from_1(n) - sum_from_1(n - i) - sum_from_1(i - 1) + 1
        answer %= mod
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 9132
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>

#define rep(i,x,y) for (int i=x;i<=y;i++)
#define dep(i,y,x) for (int i=y;i>=x;i--)
#define sz(x) (int)(x.size())

using namespace std;

typedef long long LL; 
typedef unsigned long long uLL;

const int maxn=1000+7;

int n,a[maxn],ans;

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

 rep(i,1,n) scanf("%d",&a[i]);

 sort(a+1,a+n+1);

 for (int i=1;i<=n;i+=2) ans+=a[i];
 
 printf("%d\n",ans);

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


Measured memory_bytes: 128
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

vector<int> pos[26];


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.length(); i++) {
        pos[s[i] - 'a'].push_back(i);
    }
    ll ans = 0;
    int x = -1;
    for (int j = 0; j < t.length(); j++) {
        int c = t[j] - 'a';
        if (pos[c].empty()) {
            cout << -1;
            return 0;
        }
        int it = upper_bound(pos[c].begin(), pos[c].end(), x) - pos[c].begin();
        if (it == pos[c].size()) {
            ans += pos[c][0] - x + s.length();
            x = pos[c][0];
        } else {
            ans += pos[c][it] - x;
            x = pos[c][it];
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std; 
using namespace __gnu_pbds;
 
#define ll long long int
#define pb push_back
#define endl "\n"
#define F first
#define S second

#define pq priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>
#define MAX  *max_element
#define MIN  *min_element
#define des_sort(v) sort(v.begin(),v.end(),greater<int>())
 
#define c_ones(number) __builtin_popcountll(number)
#define flip_bits(number) static_cast<unsigned>(~number)
 
#define all(X) X.begin(),X.end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(itr,n) for(itr=n.begin();itr!=n.end();itr++)
 
#define FLUSH fflush(stdout)
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb_ds tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define mod 1000000007
#define INF 1e18
 
const double PI = acos(-1);
 
bool compare(pair<int,int>a , pair<int,int>b){
	return a.first==b.first ? a.second<b.second : a.first < b.first;
}
 
struct hash_pair{ 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};


int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    ll dp[n][n];
    rep(i,n)dp[i][i]=a[i];
    for(int i=1;i<=n;i++){
    	for(int j=0;j<n-i;j++){
    		dp[j][j+i] = max(a[j]-dp[j+1][j+i],a[j+i]-dp[j][j+i-1]);
		}
	}
	cout<<dp[0][n-1]<<endl;
}

Measured memory_bytes: 49768
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
using namespace std;

using int64 = long long;
using int128 = __int128;

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

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

  int N, K;
  cin >> N >> K;

  int cnt = 0;
  for (int n = 1; n <= N; n += 2) {
    cnt++;
  }

  if (cnt >= K) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb(t) push_back(t)
#define pt(num) cout << num << "\n"
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;





int main(void) {
    ll N, Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    ll i, j;
    ll sum[MAX]={};
    
    for(i=1; i<s.size(); i++) {
        sum[i]=sum[i-1];
        if(s[i-1]=='A' && s[i]=='C')
            sum[i]+=1;
    }
    
    for(i=0; i<Q; i++) {
        ll l, r;
        cin >> l >> r;
        l--; r--;
        pt(sum[r]-sum[l]);
        
    }
    
    
}








Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
int main(){
    int ar[4][4];
    for(int i=1;i<=3;i++){
        for(int j = 1;j<=3;j++){
            cin>>ar[i][j];
        }
    }
    int m;
    I(m);
    for(int i=1;i<=m;i++){
        int x;
        I(x);
        for(int j=1;j<=3;j++){
            for(int k=1;k<=3;k++){
                if(ar[j][k] == x)ar[j][k] = -1;
            }
        }
    }
    bool fl =0;
    for(int i=1;i<=3;i++){
        if(ar[i][1] == -1 && ar[i][1] == ar[i][2] && ar[i][2] == ar[i][3])fl =1;
        if(ar[1][i] == ar[2][i] && ar[3][i] == ar[2][i])fl =1;
    }
    if(ar[1][1] ==ar[2][2] && ar[3][3] == ar[2][2] && ar[1][1] == -1)fl =1;
     if(ar[1][3] ==ar[2][2] && ar[3][1] == ar[2][2] && ar[1][3] == -1)fl =1;
    if(fl)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

using namespace std;
mt19937_64 rng(58);

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    vector<ll> scarf(n);
    ll sum = 0;
    for (int i=0; i<n; i++) {
        cin >> scarf[i];
        sum ^= scarf[i];
    }
    for (int i=0; i<n; i++) {
        cout << (scarf[i] ^ sum) << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4780
N, M, X = gets.split.map(&:to_i)
Ary = readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }

result = Float::INFINITY

(0...1<<N).each do |i|
  cost = 0
  scores = Array.new(M, 0)
  N.times do |j|

    if i>>j&1 == 1
      cost += Ary[j][0]
      scores = Ary[j][1..-1].zip(scores).map do |e, s|
        e + s
      end
    end
  end

  if scores.all? { |e| e >= X }
    if result > cost
      result = cost
    end
  end
end

if result == Float::INFINITY
  puts -1
else
  puts result
end


Measured memory_bytes: 14360
#include<iostream> 
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
vector<int>e[1000010];//边
int u[100010],c[100010];//标记数组和答案数组
queue<int>q;
int main()
{
	int n,m;cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;cin>>a>>b;
		e[a].push_back(b);	e[b].push_back(a);//构造邻边		
	}
	int cnt=1;//联通的点的个数 
	q.push(1);
	u[1]=1;//已经遍历过
	while(!q.empty()) //bfs 
	{
		int x=q.front();q.pop();//取栈顶元素
		for(int i=0;i<e[x].size();i++) {//取邻边和端点 
			int y=e[x][i];
			if(u[y]==1) continue;//已经遍历
			c[y]=x;
			u[y]=1;
			q.push(y);
			cnt++;
		}
	}
	if(cnt<n) cout<<"No"<<endl;
	cout<<"Yes"<<endl;
	for(int i=2;i<=n;i++){
		printf("%d\n",c[i]);
	}
	return 0;
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 100100;
int c[MAX],vis[MAX];
vector<int> d[MAX];
vector<int> rest,ak;
int n,m;
void dfs(int v){
  if(vis[v])return;
  vis[v] = 1;
  ak.PB(c[v]);
  for(int el:d[v])dfs(el);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> m;
  R(i,n){
    cin >> c[i];
  }
  R(i,m){
    int a,b;
    cin >> a >> b;
    d[a].PB(b);
    d[b].PB(a);
  }
  int res = 0;
  int il = 0;
  R(i,n){
    if(vis[i] == 0){
      dfs(i);
      sort(ALL(ak));
      res+=ak[0];
      il++;
      for(int j = 1;j < SZ(ak);j++){
        rest.PB(ak[j]);
      }
      ak.clear();
    }
  }
  if(il == 1){
    cout << "0\n";
  }else{
    if(SZ(rest) < il-2){
      cout << "Impossible\n";
      return 0;
    }
    sort(ALL(rest));
    R(i,il-2){
      res += rest[i];
    }
    cout << res << "\n";
  }
}


Measured memory_bytes: 10104
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, K): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (a, b): (Vec<usize>, Vec<usize>) = {
        let (mut a, mut b) = (vec![], vec![]);
        for _ in 0..N {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            a.push(iter.next().unwrap().parse().unwrap());
            b.push(iter.next().unwrap().parse().unwrap());
        }
        (a, b)
    };

    let A = {
        let mut I = (0..N).collect::<Vec<_>>();
        I.sort_by_key(|&i| a[i]);
        I.iter().scan(0, |s, &i| {
            *s += b[i];
            Some((a[i], *s))
        }).collect::<Vec<_>>()
    };
    let (ans, _) = *A.iter().find(|&&(x, y)| y >= K).unwrap();

    println!("{}", ans);
}

Measured memory_bytes: 12540
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e6+69, INF=2e9+6969;

int qq;

int main()
{
	
	string s;
	cin>>s;
	cout<<s[0]<<s[1]<<s[2]<<"\n";
	return 0;
}


Measured memory_bytes: 3628
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll n,f;cin>>n;
	f=n/500;n%=500;
	f=f*1000+5*(n/5);cout<<f<<endl;
}



Measured memory_bytes: 256
def main
  over90_num = eq90_num = less90_num = 0
  while s = ARGF.gets&.split&.map(&:to_i)&.sort

    # 三角形？
    # 短辺 + 短辺 <= 最長辺 なら三角形にならない
    break if s[0] + s[1] <= s[2]

    d = s[0]**2 + s[1]**2 - s[2]**2
    if d == 0
      eq90_num += 1
    elsif 0 < d
      # 鋭角
      less90_num += 1
    else
      # 鈍角
      over90_num += 1
    end
  end

  puts "#{over90_num + eq90_num + less90_num} #{eq90_num} #{less90_num} #{over90_num}"
end

if __FILE__ == $0
  main
end



Measured memory_bytes: 6876
#include<iostream>
#include<vector>
#include<map>
using namespace std;
int main() {

	int N;
	cin >> N;

	map<int,int> D;
	int tmp;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		D[tmp]++;
	}

	int M;
	cin >> M;

	vector<int> T(M);

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

	bool flag = false;
	/*for (int i = 0; i < M; i++) {
		flag = false;
		for (auto itr = D.begin(); itr != D.end(); itr++) {
			if (itr->second > 0) {
				if (itr->first == T[i]) {
					itr->second--;
					flag = true;
					break;
				}
			}
		}
		if (!flag) {
			cout << "NO" << endl;
			return 0;
		}

	}*/

	for (int i = 0; i < M; i++)
	{
		if (D[T[i]] > 0) {
			D[T[i]]--;
		}
		else {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int sum = a+b+c;
    if(sum >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int A, B, C, D;
int main(int argc, char const *argv[]) {
  cin >> A >> B >> C >> D;
  int ans = max(min(B, D) - max(A, C),0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
	using namespace std;

	int main() {

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

		if (A < C&&C < B) {
			cout << "Yes" << endl;
		}
		else if (A > C&&C > B) {
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
		return 0;
	}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	vector<int>a(n); rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			if (a[i] > a[j]) {
				ans += k * (k + 1) / 2;
				ans %= MOD;
			}
			else if (a[i] < a[j]) {
				ans += k * (k - 1) / 2;
				ans %= MOD;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(){
  int n;
  string s;
  int ans;
  cin >> n >> s;
  for(int i=0;i<n-2;i++){
	if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
	ans += 1;
    }
  }
  cout << ans;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,M,K;
  
  cin>>N>>M>>K;
  vector<int>A(N+1);vector<int>B(M+1);vector<int>C(N+1);vector<int>D(M+1);
  for(int i=1;i<=N;i++){cin>>A[i];C[i]=C[i-1]+A[i];}
  for(int i=1;i<=M;i++){cin>>B[i];D[i]=D[i-1]+B[i];}
  vector<int>E(N+1,0);
  int count=M;
  for(int i=0;i<=N;i++){
    for(int j=count;j>=0;j--){
      if(K>=C[i]+D[j]){E[i]=i+j;count=j;break;}
    }
  }
  sort(E.begin(),E.end());
  cout<<E[N]<<endl;
}


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

using namespace std;
vector<long long> factors;
#define ll long long


#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m)
{ return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//


int main()
{
	IOS

	double coef = 380000;
	int n;
	cin >> n;
	double total = 0;
	for(int i = 0; i < n; ++i){
		string st;
		double m = 0;
		cin >> m >> st;
		if(st[0] == 'J'){
			total += m;
		}else{
			total += m * coef;
		}
	}
	cout << setprecision(20) << total;
	return 0;
}

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

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

    long K, X;

    cin >> K >> X;

    for(int i= X-K+1; i<=X; ++i)
    {
        cout << i << endl;
    }

    for(int i= X+1; i<=X+K-1; ++i)
    {
        cout << i << endl;
    }

    return 0;

}

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

using namespace std;

typedef long long ll;

int a[100001];

int main(){
  int N; cin >> N;
  for(int i=0; i<N; ++i)
    cin >> a[i];
  sort(a, a+N);
  vector<pair<int,int> > v;
  for(int i=0, c=1; i<N; ++i){
    if(i<N-1 && a[i] == a[i+1]) ++c;
    else v.push_back(make_pair(a[i], c)), c=1;
  }
  N = v.size();
  int mx = v[0].second;
  for(int i=1; i<N; ++i){
    if(v[i].first-2 == v[i-1].first)
      mx = max(mx, v[i].second+v[i-1].second);
    int s = v[i].second;
    if(i<N-1 && v[i+1].first == v[i].first+1)
      s += v[i+1].second;
    if(v[i-1].first+1 == v[i].first)
      s += v[i-1].second;
    mx = max(mx, s);
  }
  cout << mx << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> Vec;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define sum(v) accumulate(ALL(v),0)

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

ll ans[100005];
static const ll MOD = 1e9+7;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll lcount=0;
    ll ans=1;

    vector<string> v(n*2);
    rep(i,n*2){
        if(s[i]=='B'){
            if(i%2==0){
                v[i]='L';
            }else{
                v[i]='R';
            }
        }else{
            if(i%2==0){
                v[i]='R';
            }else{
                v[i]='L';
            }
        }
    }
    rep(i,v.size()){
        if(v[i]=="L"){
            lcount++;
        }else{
            ans *= lcount;
            ans %= MOD;
            lcount--;
        }
        if(lcount<0){
            cout << 0 << endl;
            return 0;
        }
    }
    vector<string> w = v;
    sort(ALL(w));
//    dbg(w);
//    dbg(w[n]);
//    dbg(w[n+1]);
    if(w[n-1]!="L"||w[n]!="R"){
        cout << 0 << endl;
        return 0;
    }
    ll m = n;
    while (m>0){
        ans *= m;
        ans %= MOD;
        m--;
    }
    cout << ans << endl;
    return  0;
}


Measured memory_bytes: 12948
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/







int N, K; ll A[1010];
ll sm[1010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> A[i];

    sm[0] = A[0];
    rep(i, 1, N) sm[i] = sm[i - 1] + A[i];

    vector<ll> v;
    rep(l, 0, N) rep(r, l, N) {
        ll tot = sm[r];
        if (l) tot -= sm[l - 1];
        v.push_back(tot);
    }
    int n = v.size();
    vector<int> ok(n, 1);

    ll ans = 0;
    rrep(d, 60, 0) {
        ll msk = 1LL << d;
        int cnt = 0;
        rep(i, 0, n) if (v[i] & msk and ok[i]) cnt++;
        if (K <= cnt) {
            ans += msk;
            rep(i, 0, n) if (!(v[i] & msk) and ok[i]) ok[i] = 0;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 6384
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;

string encode(int s) {
    char buf[10];
    int h = s / 3600;
    s -= h * 3600;
    int m = s / 60;
    s -= m * 60;
    sprintf(buf, "%02d:%02d:%02d", h, m, s);
    return string(buf);
}

int main() {
    int h, m, s;
    while (cin >> h >> m >> s) {
        if (h == -1 && m == -1 && s == -1) break;
        int rs = 120 * 60 - h * 3600 - m * 60 - s;
        int rs_3 = rs * 3;
        cout << encode(rs) << endl << encode(rs_3) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    string s;
    cin >> s;
    string c = "CODEFESTIVAL2016";
    int ans = 0;
    rep(i,s.length()){
        if(s[i] != c[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int H,W,A,B;
    cin >> H >> W >> A >> B;
    rep(i,H){
        rep(j,W){
            if(i<B ^ j<A) cout << 1;
            else cout << 0;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int x,a,b;
cin>>x>>a>>b;
if(abs(x-a)>abs(x-b))cout<<'B'<<endl;
else cout<<'A'<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May  3 21:27:26 JST 2020
 **/

signed main() {
    Int n, A, B, C;
    std::cin >> n >> A >> B >> C;
    std::vector<std::string> s(n);
    REP(i, n) std::cin >> s[i];
    std::vector<char> ans;
    std::vector<Int> rem = {A, B, C};
    auto dfs = [&](auto f, Int idx) -> void {
        if (idx == n) {
            std::cout << "Yes" << std::endl;
            for (char c : ans) std::cout << c << "\n";
            exit(0);
        }
        Int x = s[idx][0] - 'A', y = s[idx][1] - 'A';
        REP(_, 2) {
            if (rem[x] > 0) {
                ans.push_back('A' + y);
                rem[x]--, rem[y]++;
                f(f, idx + 1);
                rem[x]++, rem[y]--;
                ans.pop_back();
            }
            std::swap(x, y);
        }
    };
    dfs(dfs, 0);
    std::cout << "No" << std::endl;
}


Measured memory_bytes: 19524
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <iomanip>
#include <functional>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));




signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout<<fixed<<setprecision(10);
    int A,B,C;
    cin>>A>>B>>C;
    bool flag=false;
    if(A==B && B!=C) flag=true;
    if(B==C && A!=B) flag=true;
    if(A==C && A!=B) flag=true;
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
n,m=map(int,input().split())
l=[0]*n
o=0
for i in sys.stdin:
  s,c=map(int,i.split())
  if s==1 and c==0 and n!=1:
    o=-1
    break
  elif l[s-1]==0 or l[s-1]==c:
    l[s-1]=c
  else:
    o=-1
    break
if o==0:
  if l[0]==0 and n>1:
    l[0]=1
  o=''.join([str(i) for i in l])
print(o)

Measured memory_bytes: 3064
//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef unsigned long long ull;
typedef long long  ll;
#define MOD 1000000007
#define MX 1000000000
#define MXL 1000000000000000000
#define PI 3.14159265
#define pb push_back
using namespace std;
#define sc second
#define endl '\n'
#define fr first

int main(){
    startt
    ll a,b, c, d;
    cin >> a >> b >> c >> d;
    if(b >= 0 && d >= 0)
    {
        if( a <= 0 && c <= 0 && a*c >= b*d)
        {
            cout << a*c << endl;
            return 0;
        }
        cout << b*d << endl;
        return 0;
    }
    if( a <= 0 && c <= 0)
    {
        cout << a*c << endl;
        return 0;
    }
    if(b <= 0 && c <= 0 && d>= 0)
    {
        cout << 0 << endl;
        return 0;
    }
    if(a <= 0 && d <= 0 && b >= 0)
    {
        cout << 0 << endl;
        return 0;
    }
    if(a < 0 && b < 0 && c > 0 && d > 0)
    {
        cout << max(a,b)*min(c,d);
        return 0;
    }
    if(a > 0 && b > 0 && c < 0 && d < 0)
    {
        cout << min(a,b)*max(c,d);
        return 0;
    }
    cout << a*d << endl;
}


Measured memory_bytes: 3644
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    worst_score = 10 ** 12

    n, k = ns()
    a = na()
    f = na()
    a.sort()
    f.sort(reverse=True)
    score = [ai * fi for ai, fi in zip(a, f)]

    l = 0
    r = worst_score

    while True:
        middle = (l + r) // 2

        tmp_k = k
        for i in range(n):
            tmp = (score[i] - middle + f[i] - 1) // f[i]
            tmp_k -= max(0, tmp)

            if tmp_k < 0:
                break

        if r - l == 1:
            print(middle if tmp_k >= 0 else middle + 1)
            exit(0)

        if tmp_k < 0:
            l = middle
        else:
            r = middle





if __name__ == '__main__':
    main()


Measured memory_bytes: 126584
#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>

#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>
#define deb(x)		cout << #x << " " << x << endl

using namespace std;
using ll  = long long;
using lld = long double;

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;

const int N = 3003;
lld dp[N][N];
lld ar[N];

signed main(){

#ifndef ONLINE_JUDGE
	//freopen("in.txt" , "r" , stdin);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);
    
    int n;
    cin >> n;
    fo(i , n) cin >> ar[i];
    
    dp[0][0] = 1.00;
    fo(i , n)
        for(int j = 0 ; j <= i ; j ++){
            dp[i + 1][j + 1] += dp[i][j] * ar[i];        
            dp[i + 1][j] += dp[i][j] * (1.00 - ar[i]);
        }
    

    lld ans = 0;
   
    for(int j = n ; j > n / 2 ; j--)
        ans += dp[n][j];


    cout << fixed << setprecision(10) << ans << '\n';
    
    return 0;

}



Measured memory_bytes: 85572
MOD = 10**9+7
n, c = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sig = [[0 for _ in range(max(b)+1)] for _ in range(c+1)]
for i in range(c+1):
	for j in range(1, max(b)+1):
		sig[i][j] = sig[i][j-1] + pow(j, i, MOD)
		sig[i][j] %= MOD

def sigma(C, A, B):
	return (sig[C][B] - sig[C][A-1]) % MOD

dp = [[0 for _ in range(c+1)] for _ in range(n)]
for j in range(c+1):
	dp[0][j] = sigma(j, a[0], b[0])

for i in range(1, n):
	for j in range(c+1):
		for k in range(j+1):
			dp[i][j] += dp[i-1][k] * sigma(j-k, a[i], b[i])
			dp[i][j] %= MOD

print(dp[n-1][c])

Measured memory_bytes: 44892
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
  cin>>n;
  int a[100000];
  int ct=0;
  int s=0;
  for(int i=0; i<n; i++){
    cin>>a[i];
    if(a[i]&1) ct++;
    s^=a[i];
  }
  if(s==1){
    cout<<"Bob"<<endl;
  }else if(s>1){
    cout<<"Alice"<<endl;
  }else if(ct>0){
    cout<<"Alice"<<endl;
  }else{
    cout<<"Bob"<<endl;
  }
	return 0;
}


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

using namespace std;
using int64 = long long int;

int main()
{
    int64 n, a, b;
    cin >> n >> a >> b;

    int64 ans = a * (n / (a + b)) + min(n % (a + b), a);
    cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N, K;
    scan(N, K);
    int ans = K;
    foreach (i ; 0 .. N - 1) {
        ans *= K - 1;
    }
    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))

isBalls = [0] * (N+1)
for k in reversed(range(1, N+1)):
    num = sum([isBalls[k*i] for i in range(1, N//k+1)])
    if num % 2 != As[k-1]:
        isBalls[k] = 1

M = sum(isBalls)
anss = [i for i in range(1, N+1) if isBalls[i] > 0]

print(M)
print(' '.join(map(str, anss)))


Measured memory_bytes: 19900
N = int(input())
a_list = list(map(int, input().split()))

even_list = [i for i in a_list if i % 2 == 0]
odd_list = [j for j in a_list if j % 2 == 1]

even_count = len(even_list)
odd_count = len(odd_list)

if odd_count % 2 !=0:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 14108
#include<bits/stdc++.h>
using namespace std;
bool h,e,l1,l2,o;
int p,y,r,b;
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	p=s1.size();
	y=s2.size();
	b=min(p,y);
	r=max(p,y);
    for(int i=0;i<b;i++)
    {
        cout<<s1[i]<<s2[i];
	}
    if(p>y)
    {
    	for(int i=b;i<r;i++)cout<<s1[i];
	}      
    else for(int i=b;i<r;i++) cout<<s2[i];
    return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()
{
  int n = 0, c = gc();
  if (c == '-') { c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return -n;
  }
  do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
  return n;
}

void out(int n)
{
  int i;
  char ob[20];

  if (!n) pc('0');
  else {
    i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
    while (i--) pc(ob[i]);
  }
  pc('\n');
}

#define MAX_N  500005

typedef struct { int id; int p[2], child[2], min[2], max[2]; } NODE;
NODE kdTree[MAX_N];

int root;       // root of kd tree
int ans[102], len;
int s[2], t[2];

int mkKdTree(int l, int r, int k)
{
  int i, j, c;
  int m, x;
  NODE t;

  m = (l+r)>>1;
  t = kdTree[m], x = t.p[k], kdTree[m] = kdTree[r], kdTree[r] = t;
  i = l-1;
  /*for (j = l; j < r; j++) {
    if (kdTree[j].p[k] < x) {
      if (++i != j) {
        t = kdTree[++i];
        kdTree[i] = kdTree[j];
        kdTree[j] = t;
        printf("aaa\n");
      }
    }
  }*/
  t = kdTree[r], kdTree[r] = kdTree[m], kdTree[m] = t;

  kdTree[m].child[0] = (l == m) ? 0: mkKdTree(l, m-1, k);
  kdTree[m].child[1] = (m == r) ? 0: mkKdTree(m+1, r, k);

  for (i = 0; i < 2; i++) {
    kdTree[m].min[i] = kdTree[m].max[i] = kdTree[m].p[i];
    for (j = 0; j < 2; j++) if (c = kdTree[m].child[j]) {
        if (kdTree[m].min[i] > kdTree[c].min[i]) kdTree[m].min[i] = kdTree[c].min[i];
        if (kdTree[m].max[i] < kdTree[c].max[i]) kdTree[m].max[i] = kdTree[c].max[i];
      }
  }
  return m;
}

void printRange(int node)
{
  int c;

  if (kdTree[node].p[0] >= s[0] && kdTree[node].p[0] <= t[0] &&
      kdTree[node].p[1] >= s[1] && kdTree[node].p[1] <= t[1]) {
    ans[len++] = kdTree[node].id;
  }

  if ((c = kdTree[node].child[0]) &&
              kdTree[c].min[0] <= t[0] && s[0] <= kdTree[c].max[0] &&
      kdTree[c].min[1] <= t[1] && s[1] <= kdTree[c].max[1])
    printRange(c);

  if ((c = kdTree[node].child[1]) &&
              kdTree[c].min[0] <= t[0] && s[0] <= kdTree[c].max[0] &&
      kdTree[c].min[1] <= t[1] && s[1] <= kdTree[c].max[1])
    printRange(c);
}

int kdcmp(NODE *a, NODE *b) { if (a->p[0]-b->p[0]) return a->p[0]-b->p[0]; return a->p[1]-b->p[1]; }

void insertion_sort(int n, int *a)
{
  int i, j, key;

  for (i = 1; i < n; i++) {
    key = a[i];
    j = i-1;
    while (j >= 0 && a[j] > key) a[j+1] = a[j], j--;
    a[j+1] = key;
  }
}

int main()
{
  int n, q, i;

  n = in();
  for (i = 1; i <= n; i++) {
    kdTree[i].id = i-1, kdTree[i].p[0] = in(), kdTree[i].p[1] = in();
  }
  qsort(kdTree+1, n, sizeof(NODE), kdcmp);
  root = mkKdTree(1, n, 0);

  q = in();
  while (q--) {
    s[0] = in(), t[0] = in();
    s[1] = in(), t[1] = in();
    len = 0;
    printRange(root);
    insertion_sort(len, ans);
    for (i = 0; i < len; i++) out(ans[i]);
    pc('\n');
  }
}


Measured memory_bytes: 26148
function Main(input) {
	input = input.trim().split(" ");
	var A = input[0];
	var B = input[1];
	var a1 = parseInt(A.slice(0, -7),10);
	var a2 = parseInt(A.substr(-7, 7),10);
	var b1 = parseInt(B.trim().split(".")[0]);
	var b2 = parseInt(B.trim().split(".")[1]);
	if (isNaN(a1)) a1 = 0;
	if (isNaN(a2)) a2 = 0;
	if (isNaN(b1)) b1 = 0;
	if (isNaN(b2)) b2 = 0;
	var ANS, ans1, ans2, ansMiddle, tmp;
	
	ans1 = a1 * (b1 * 100 + b2);
	tmp = String(a2 * (b1 * 100 + b2)).slice(0,-2); 
	ansMiddle = parseInt(tmp.slice(0, -5),10);
  	if (isNaN(ansMiddle)) ansMiddle = 0;
	ans2 = parseInt(tmp.substr(-5, 5),10);
	if (isNaN(ans2)) ans2 = 0;
	ans1 = String(ans1 + ansMiddle);
	if (ans1 === '0'){
		ANS = String(ans2);
	} else {

		ANS = ans1 + String(ans2 + 100000).substr(-5,5);
	}	
 	console.log(ANS);	
}   

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll L;
	cin >> L;

	ll hoge = L * L * L;

	long double ans = (long double) hoge / ((long double) 27.00);

	// printf("%8.10lf\n", ans);
	cout << fixed << setprecision(10) << ans << "\n";
	// cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll max(ll a,ll b)
{
  return (a>=b?a:b);
}
int main(void)
{
  ll n,w;
  cin>>n>>w;
  ll remw=w;
  ll we[n],val[n];
  for(ll i=0;i<n;++i)
  {
    cin>>we[i]>>val[i];
  }
  ll dp[n+1][w+1]={0};
  for(ll i=1;i<=w;++i)
  {
    dp[0][i]=0;
    //cout<<dp[0][i]<<" ";
  }
  cout<<endl;
  for(ll i=1;i<=n;++i)
  {
    for(ll j=1;j<=w;++j)
    {
      if(j<we[i-1])
      {
        dp[i][j]=dp[i-1][j];
      }
      else
      {
        dp[i][j]=max(val[i-1]+dp[i-1][j-we[i-1]],dp[i-1][j]);
        
      }
    }
  }
  /*for(ll i=0;i<=n;++i)
  {
    for(ll j=0;j<=w;++j)
      cout<<dp[i][j]<<" ";
    cout<<endl;
  }*/
  cout<<dp[n][w];
}


Measured memory_bytes: 79104