akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

long long isPrime(long long n){
  long long i;
  if(n < 2LL){
    return 0LL;
  }
  else if(n == 2LL){
    return 1LL;
  }
  if(n % 2LL == 0LL){
    return 0LL;
  }
  for(i = 3LL; i * i <= n; i += 2LL){
    if(n % i == 0LL){
      return 0LL;
    }
  }
  return 1LL;
}

int main() {
  ll n;
  cin>>n;
  vector<ll> vp;
  rep(i,3,55556){
    if(isPrime(i)==1){
      if(i%10==1){
        vp.pb(i);
      }
    }
  }
  rep(i,0,n){
    cout << vp[i];
    if(i!=n-1)cout << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fi first
#define se second
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);



bool isPrime(ll n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    if (n%2 == 0 || n%3 == 0) return false;

    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}


int main()
{
    ll a,b;
    cin>>a>>b;

    ll i;

    unordered_map<ll,ll>mp1,mp2;

    for(i=1;i<=sqrt(a);i++)
    {
        if(a%i==0)
        {
            ll x = a/i;
            mp1[x]++;
            mp1[i]++;
        }
    }

    for(i=1;i<=sqrt(b);i++)
    {
        if(b%i==0)
        {
            ll y = b/i;
            mp2[y]++;
            mp2[i]++;
        }
    }

    ll ans=0;
    for(auto it:mp1)
    {
        if(mp2.find(it.first) != mp2.end()  &&  isPrime(it.first))
        {

            ans++;
        }
    }
    ans++;

    cout<<ans;
}


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

const int N = 1e5;

string s;
int par[N+5];
vector<int> adj[N+5];
bool vis[N+5];
int le,ri;
int cnt = 0;

void dfs(int node, int id1, int id2)
{
//   cout << "node = " << node << " >> " << id1 << " " << id2 << endl;
   for(int i=0;i<adj[node].size();i++)
   {
      int now = adj[node][i];
      if(vis[now]) continue;
      vis[now] = 1;
      cnt++;
      par[le+cnt] = id1;
      par[ri+cnt] = id2;
      dfs(now,le+cnt,ri+cnt);
   }
   return;
}

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   cin >> s;
//   while(s.size()%2==0);
   int pan = s.size()-1;
   bool bisa=1;
   if(s[pan]=='1' || s[0] =='0') bisa=0;
   pan--;
   for(int i=0;i<=pan/2;i++)
   {
      if(s[i]!=s[pan-i]) bisa=0;
   }
   if(!bisa) printf("-1\n");
   else
   {
      //11011
      int cur=1;
      for(int i=0;i<(pan+1)/2;i++)
      {
         if(s[i] == '1')
         {
            adj[cur].push_back(i+2);
            adj[i+2].push_back(cur);
            cur=i+2;
         }
         else
         {
            adj[i+2].push_back(cur);
            adj[cur].push_back(i+2);
         }
//         cout << "current root = " << cur << endl;
      }
      le = 1;
      pan+=2;
      if(pan%2==0)
      {
         ri = ((pan)/2)+1;
         par[ri] = le;
      }
      else
      {
         ri = (pan+1)/2;
      }
      vis[cur] = 1;
//      cout << ">> " << le << " " << ri << endl;
      dfs(cur,le,(pan%2==0 && s[pan/2-1]=='1')?ri:1);
      for(int i=2;i<=pan;i++)
      {
         printf("%d %d\n",i,par[i]);
      }
   }
 	return 0;
}


Measured memory_bytes: 8172
h, n = map(int, input().split())

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

# dp = [[None] * n for _ in range(h + 1)]
#
# def dfs(at, i):
#     at = max(at, 0)
#
#     if dp[at][i] is not None:
#         return dp[at][i]
#
#     if i == n - 1:
#         r = ((at + ab[i][0] - 1) // ab[i][0]) * ab[i][1]
#     elif at <= 0:
#         r = 0
#     else:
#         r = min(dfs(at - ab[i][0], i) + ab[i][1], dfs(at, i + 1))
#
#     dp[at][i] = r
#     return r
#
# print(dfs(h, 0))

dp = [[0] * n for _ in range(h + 1)]
i = n - 1
for at in range(h + 1):
    dp[at][i] = ((at + ab[i][0] - 1) // ab[i][0]) * ab[i][1]

for at in range(h + 1):
    for i in reversed(range(n - 1)):
        r = min(
            dp[max(0, at - ab[i][0])][i] + ab[i][1],
            dp[at][i + 1])
        dp[at][i] = r
print(dp[h][0])



Measured memory_bytes: 120668
main :: IO ()
main = do ls <- getContents
          putStrLn (compose ls)

compose :: String -> String
compose = unwords . fmap show . mathOp . (\xs -> take (head xs) (tail xs)) . (=<<) (fmap (\x -> read x::Int) . words) . lines

mathOp  :: [Int] -> [Int]
mathOp  xs = fmap ($ xs) [mini, maxi, sumi]

mini :: [Int] -> Int
mini [] = error "Empty list was given"
mini [x] = x
mini (x:xs) = min x (mini xs)

maxi :: [Int] -> Int
maxi [] = error "Empty list was given"
maxi [x] = x
maxi (x:xs) = max x (maxi xs)

sumi :: [Int] -> Int
sumi = foldr (+) 0

Measured memory_bytes: 6616
N = int(input())
A = list(map(int, input().split()))

def sunuke(b):
    ret = 0
    sub = 1
    for a in A:
        ret += abs(a - (b+ sub))
        sub += 1
    return ret


B = []

sub = 1
for a in A:
    b = a - sub
    B.append(b)
    sub += 1

B.sort()
b1 = N // 2
if N < 3:
    print(sunuke(B[b1]))
    exit()

b2 = b1 + 1
b1_s = sunuke(B[b1])
b2_s = sunuke(B[b2])
if b1_s < b2_s:
    print(b1_s)
else:
    print(b2_s)


Measured memory_bytes: 25708
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <limits>
#include <math.h>
using namespace std;
int main(){ 
  int s;
  cin >> s;
  bool flag = false;
  int m = 1;
  if(s <= 2) {
    cout << 4 << endl;
    return 0;
  }
  while(!(flag && s == 4)){
    if(s == 4) {
      flag = true;
    }
    if(s % 2 == 0 ){
      s = s /2;
    } else {
      s = 3 * s + 1;
    }
    m++;
  }
  cout << m << endl;
  return 0;
}

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

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (auto& i : h)
        cin >> i;

    sort(h.begin(), h.end(), greater<int>());
    int minimum = pow(10, 9);
    for (int i = 0; i < N-K+1; i++) {
        minimum = min(minimum, h[i] - h[i + K - 1]);
    }

    cout << minimum << endl;

    return 0;
}

Measured memory_bytes: 640
import math

N = int(input())

pos_list = []

for i in range(N):
	pos_list.append(tuple(map(int, input().strip().split())))

dist_table = [[None] * N for i in range(N)]

for i in range(N):
	x1, y1 = pos_list[i]
	for j in range(i + 1, N):
		x2, y2 = pos_list[j]
		dist = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
		dist_table[i][j] = dist
		dist_table[j][i] = dist

total = 0
number = 0

def calc(perm, count, towns):
	global total, number
	if count == N:
		for i in range(N - 1):
			total += dist_table[perm[i]][perm[i + 1]]
		number += 1
	else:
		for i in range(N):
			if towns[i]:
				towns[i] = False
				perm[count] = i
				calc(perm, count + 1, towns)
				towns[i] = True

calc([None for _ in range(N)], 0, [True for _ in range(N)])

print(total / number)


Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(){
int N,A[200001],x=0,y,z=0,w=0;
cin >> N;
for(int i=0;i<N;i++){
  cin >> A[i];
}
for(int i=0;i<N;i++){
  x=max(A[i],x);
}
for(int i=0;i<N;i++){
  if(x==A[i]){
    z=z+1;
    y=i;
  }
}
if(z==1){
  for(int i=0;i<y;i++){
    w=max(w,A[i]);
  }
  for(int i=y+1;i<N;i++){
    w=max(w,A[i]);
  }
}
if(z==1){
  for(int i;i<y;i++){
    cout << x <<endl;
  }
  cout << w << endl;
  for(int i=y+1;i<N;i++){
    cout << x << endl;
  }
}else{
  for(int i=0;i<N;i++){
    cout << x <<endl;
  }
}
  return 0;
}


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

int main() {
  int sx,sy,tx,ty;
  cin >>sx>>sy>>tx>>ty;
  int A=tx-sx;
  int B=ty-sy;
  cin>>A>>B;
  for (int i = 0; i < A; i++) {
    cout<<"R";
 
}
  for (int i=0; i<B;i++){
    cout<<"U";
  }
  
  for (int i = 0; i < A; i++) {
    cout<<"L";
  }
  for (int i=0; i<B;i++){
    cout<<"D";
  }
  cout<<"L";
  for (int i=0; i<B+1;i++){
    cout<<"U";
  }
  for (int i = 0; i < A+1; i++) {
    cout<<"R";
 
}
  cout<<"D";
  cout<<"R";
  
  for (int i=0; i<B+1;i++){
    cout<<"D";
  }
  for (int i = 0; i < A+1; i++) {
    cout<<"L";
 
}
  cout<<"U"<<endl;
  
 
}
  
  



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

int main() {
    int N, M;
    cin >> N >> M;
    map<int, int> mp;
    rep(i, N) {
        int tmp;
        cin >> tmp;
        rep(j, tmp) {
            int a;
            cin >> a;
            mp[a]++;
        }
    }
    int ans = 0;
    for (auto t : mp) {
        if (t.second == N) ans++;
    }
    cout << ans << endl;
}


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

#define zton(i,n) for(int i=0;i<=n;i++)
#define oneton(i,n) for(int i=1;i<=n;i++)
#define fo(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define loop(i,b,a) for(int i=a;i>=b;i--)
#define dsort(arr,n) sort(arr, arr + n, greater<int>())
#define vsortd(a) sort(a.begin(), a.end(), greater<double>())
#define vsort(a) sort(a.begin(), a.end())
#define ll long long int
#define test int tc;cin>>tc;while(tc--)
#define dbg(x) cout<<#x<<'='<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl;
#define dbg3(x,y,z) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl;
#define dbg4(x,y,z,w) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl<<#w<<"="<<(w);
#define minheap priority_queue <int, vector<int>, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define ff first
#define ss second
#define mpr make_pair
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mkv vector<int>
#define allzero(dp) memset(dp,0,sizeof(dp))
#define endl "\n"
#define print(x) cout<<x<<endl;

const int mod=1e9+7;
using namespace std;
bool sortcol( const vector<int>& v1,const vector<int>& v2 ) {return v1[1] < v2[1];}

void fastio()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

bool sortbysecdesc(const pair<ll,ll> &a,const pair<ll,ll> &b){
    if(a.first>b.first)return true;
    if(a.first==b.first)return a.second<b.second;
    return false;
}

ll power(ll x, ll y){
    ll res = 1;x=x%mod;
    while(y>0){
        if(y&1)res=(res*x)%mod;
        y=y>>1;x=(x*x)%mod;}
    return res;
}



void solve()
{
    ll n;cin>>n;
    ll a[n];fo(i,n)cin>>a[i];
    ll x=1000;
    ll y=0;
    for(ll i=0;i<n-1;i++){
        if(a[i]==a[i+1])continue;
        if(a[i]>a[i+1]){
            x+=a[i]*y;
            y=0;
        }
        else{
            ll t=x/a[i];
            x-=t*a[i];
            y+=t;
        }
  //  dbg3(i,x,y)
    //cout<<endl;
    }
    x+=a[n-1]*y;
    print(x)

}

int main()
{
  //  fastio();
   // test
    solve();
}


Measured memory_bytes: 3632
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

for k in range(N):
    for i in range(N):
        for j in range(N):
            # 
            if A[i][j] > A[i][k] + A[k][j]:
                print(-1)
                exit()


ans = 0
for i in range(N):
    for j in range(i+1,N):

        f = True
        for k in range(N):
            if k == i or k == j:
                continue
            if A[i][j] == A[i][k] + A[k][j]:
                f = False
                break
        
        if f:
            #辺i->jを足す
            ans += A[i][j]


print(ans)

Measured memory_bytes: 44252
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<iostream>
#include<stack>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include <iomanip>
#include<unordered_map>
#include<set>
using namespace std;
typedef long long ll;
const int maxn = 1005;

int main() {
   // freopen("in.cpp","r",stdin);
    string cc;
    cin>>cc;
    int cnt=0;
    for(int i=0;i<cc.size();i++){
        if(cc[i]=='C'&&cnt==0)cnt++;
        else if(cc[i]=='F'&&cnt==1)cnt++;
    }
    if(cnt==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int k, n, ans=0;
    cin >> k >> n;
  int h[n];
    for(int i=0; i<n; i++) cin >> h[i];
    pair<int, int> route = make_pair(n-1, 0);
    int dist = h[0]-h[n-1]+k;
    for(int i=1; i<n; i++){
      int r = h[i]-h[i-1];
      if(dist<r){
        dist = r;
        route.first = i-1; route.second = i;
      }
      //cout << route.first << route.second << endl;
    }
    for(int i=0; i<n-1; i++){
      int j=i+route.second;
      if(j==n-1) ans += h[0]-(h[j]-k);
      else {
        if(n<=j)
          j = i+route.second-n;
        ans += h[j+1] - h[j];
        }
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

ll n;
string ans;

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	
	cin >> n;
	
	while (n)
	{
		n -= 1;
		ans += 'a' + (n % 26);
		n /= 26;
	}
	
	reverse(ans.begin(), ans.end());
	
	cout << ans << '\n';
	
	return 0;
}

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

int main(){
  int n,i;
  cin >> n;
  vector<pair<string,int>> s(n);
  for(i=0; i<n; i++){
    cin >> s[i].first >> s[i].second;
    s[i].second=(100-s[i].second)*1000+(i+1);
  }
  sort(s.begin(), s.end());
  for(i=0; i<n; i++){
    cout << s[i].second%1000 << endl;
  }
}

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

int main() {
	int x,a,b;

	cin >> x >> a >> b;
	
	if (b - a <= 0) {
		cout << "delicious" << endl;
	}
	else if(b - a <= x) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}
	
	
	return 0;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

int main()
{
    int N;
    cin >> N;
    multiset <int> st;

    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        auto k = st.lower_bound(x);
        if (k != st.begin()) st.erase(--k);
        st.insert(x);
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 4992
n = int(input())
S = []
t = 100
for i in range(n):
    s = int(input())
    S.append(s)
    if s < t and s % 10 != 0:
        t = s
ss = sum(S)
if t == 100: print(0)
elif ss % 10 == 0: print(ss - t)
else: print(ss)



Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int town[50][50];
int main(void){
	int n,m; cin >> n >> m;
	int *a = new int[m-1];
	int *b = new int[m-1];
	for(int i=0; i<m; i++){
		cin >> a[i] >> b[i];
		town[a[i]-1][b[i]-1]++;
		town[b[i]-1][a[i]-1]++;
	}
	for(int i=0; i<n; i++){
		int cnt=0;
		for(int j=0; j<n; j++){
			cnt+=town[i][j];
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int w,h;
int per[110][110];
int s,t;

int main(){
	while(1){
		cin>>n;
		for(int i=0;i<110;i++){
			for(int j=0;j<110;j++){
				per[i][j]=0;
			}
		}
		if(n==0)break;
		cin>>w>>h;
		for(int i=0;i<n;i++){
			int x,y;
			cin>>x>>y;
			per[x][y]=1;
		}
		cin>>s>>t;
		int ans=0;
		for(int i=1;i<=w-s+1;i++){
			for(int j=1;j<=h-t+1;j++){
				int count=0;
				for(int k=0;k<s;k++){
					for(int l=0;l<t;l++){
						if(per[i+k][j+l])count++;
					}
				}
				ans=max(ans,count);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()

int solve()
{
    int n;
    cin>>n;
    vector<int> dp(3,0);
    rep(i,n)
    {
        vector<int> val(3);
        vector<int> new_dp(3,0);
        rep(j,3)
        {
            cin>>val[j];
        }
        rep(j,3)
        {
            rep(k,3)
            {
                if(j!=k)
                {
                    new_dp[k] = max(new_dp[k],dp[j] + val[k]);
                }
            }
        }
        dp = new_dp;
    }
    cout<<max({dp[0],dp[1],dp[2]})<<endl;
    return 0;
}
int main()
{
    /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else
    #endif */
    solve();
    /* #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC<<" Sec\n";
    #endif */

    return 0;
} 

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

using namespace std;
#define ll long long
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;

unsigned GetDigit(unsigned num){
    return std::to_string(num).length();
}

int main (){
    ll n;
    cin >> n;
    int N = sqrt(n) / 1;
    ll maxi = 0;
    for(ll i = 1; i <= N; i++){
        if(n % i == 0){
            ll k = n / i;
            maxi = max(k,i);
        }
        
    }

    cout << GetDigit(maxi) << endl;
    


    return 0;
}

/* 10進数の桁数　数え方いろいろ　https://qiita.com/EqualL2/items/168e083caa5f07a1105b */

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int dp[MAX_N];

int main()
{
	int n,W;
	int v,w,m;
	scanf("%d%d",&n,&W);
	fill(dp,dp+MAX_N,-INF);
	dp[0] = 0;
	rep(i,n){
		scanf("%d%d%d",&v,&w,&m);
		for(int j=0;m>0;j++){
			int hoge = min(m,(1<<j));
			m-=hoge;
			for(int k=W;k>=hoge*w;k--){
				dp[k] = max(dp[k],dp[k-hoge*w]+hoge*v);
			}
		}
	}
	cout << *max_element(dp,dp+W+1) << "\n";
	return 0;
}

Measured memory_bytes: 3624
a,b,c,d=map(int,list(input()))

if a+b+c+d==7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a-b+c+d==7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b-c+d==7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a+b+c-d==7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a-b-c+d==7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a+b-c-d==7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
elif a-b+c-d==7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a-b-c-d==7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int h,w,k;
  cin >> h >> w >> k;
  char c[h][w];
  REP(i,h) {
    REP(j,w) {
      cin >> c[i][j];
    }
  }
  int ans=0;
  REP(i,pow(2,h)) {
    vi row_check;
    REP(x,h) {
      if((i>>x)&1) row_check.push_back(x);
    }
    REP(j,pow(2,w)) {
      vi column_check;
      REP(y,w) {
        if((j>>y)&1) column_check.push_back(y);
      }
      int cnt=0;
      REP(a,h) {
        REP(b,w) {
          if(find(ALL(row_check),a)==row_check.end()) continue;
          if(find(ALL(column_check),b)==column_check.end()) continue;
          if(c[a][b]=='#') cnt++;
        }
      }
      if(cnt==k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;

int main() {

    ll x, y;
    cin >> x >> y;

    int ans = 1;
    while ( true ) {
        if ( x  * (1LL << (ans - 1)) > y ) break;
        ans++;
        // cout << x * (1 << (ans - 1)) << endl;
    }

    cout << ans - 1 << endl;
    

    return 0;
}

Measured memory_bytes: 384
def argmaxs(lst):
    mx=max(lst)
    output=[]
    for i,a in enumerate(lst):
        if a==mx:
            output.append(i)
    
    return output
    
def main():
    import sys
    H,W,M=list(map(int,sys.stdin.readline().split()))
    y_lst=[0]*H
    x_lst=[0]*W
    bumbs=[set() for _ in range(H)]

    for i in range(M):
        h,w=list(map(int,sys.stdin.readline().split()))
        y_lst[h-1]+=1
        x_lst[w-1]+=1
        bumbs[h-1].add(w-1)

    output=max(x_lst)+max(y_lst)
    
    
    argys=argmaxs(y_lst)
    argxs=argmaxs(x_lst)
    argx_set=set(argxs)

    k=1
    for y in argys:
        if not(argx_set <= bumbs[y]):
            k=0
            break

    
    print(output-k)
main()

Measured memory_bytes: 218088
N = int(input())
num = str(N)
for i in range(1,len(num)):
    if num[-i] != "9" and 0 < N - (int(num[-i]) + 1) * 10**(i-1):
        N -= (int(num[-i]) + 1) * 10**(i-1)
        num = str(N)

D = 0
for digit in str(N):
    D += int(digit)

print(D)

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

int main()
{
  int H, W;
  cin >> H >> W;

  vector<vector<char>> grid(H, vector<char>(W));
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> grid.at(i).at(j);
    }
  }

  for (int i = 0; i < H; i++)
  {
    bool H_erase;
    bool W_erase;
    for (int j = 0; j < W; j++)
    {
      H_erase = true;
      W_erase = true;
      for (int ii = 0; ii < H; ii++)
      {
        if (grid.at(ii).at(j) == '#')
        {
          H_erase = false;
          break;
        }
      }
      for (int jj = 0; jj < W; jj++)
      {
        if (grid.at(i).at(jj) == '#')
        {
          W_erase = false;
          break;
        }
      }
      if (!H_erase && !W_erase)
        cout << grid.at(i).at(j);
    }
    if (!W_erase)
      cout << endl;
  }
}


Measured memory_bytes: 256
S = input()
S = S[::-1]
#print(S)

mod = 10**9+7

tblpow = [1]
for i in range(1,len(S)+1):
	tblpow.append(10*tblpow[i-1]%13)

dp = [0]*13
dp[0] = 1
for i in range(len(S)-1,-1,-1):
	ch = int(S[i]) if S[i]!='?' else -1
	temp = [0]*13
	for d in range(10):
		if ch!=-1 and ch!=d:
			continue
		for m in range(13):
			temp[(d*tblpow[i]+m)%13] += dp[m]
	for m in range(13):
		temp[m] %= mod
	dp = temp
print(dp[5])


Measured memory_bytes: 45680
//package abc124.B;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int sum = 0, diff = 0;
		
		for (int i = 0; i < 5; i++) {
			int n = sc.nextInt();
			sum += (n + 10 - 1) / 10 * 10;
			if (n % 10 != 0) diff = Math.max(diff, 10 - n % 10);
		}
		
		System.out.println(sum - diff);
		
	}

}


Measured memory_bytes: 22996
#define _USE_MATH_DEFINES 1
#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 MOD 1000000007ll
#define INF 1000000000000000000ll
#define EPS 1e-9
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock

typedef long long         ll;
typedef long double       ld;
typedef pair <ll,ll>      pl;
typedef tuple <ll,ll,ll>  tl;

ll A, B;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> A >> B;
	
	cout << A * B;
	
    return 0;
}

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


int main(){

  int Y,M,D;
  int n;
  cin >> n;
  while(cin >> Y >> M >> D){
  
    int date = 0;
    while( Y < 1000 ){
 
	
      if( Y % 3 == 0 ){
	while( D <= 20 ){
	  date++;
	  D++;
	}
      }else{
	if( M % 2 == 0 ){
	  while( D <= 19 ){
	    date++;
	    D++;
	  }
	}
	else{
	  while( D <= 20 ){
	    date++;
	    D++;
	  } 
	}
      }
      M++;
      D = 1;
      if( M == 11 ){
	M = 1;
	Y++;
      }
    }	
    
    cout << date <<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <string>
#include <iostream>
#include <set>       // 要素数は size() で取得
#include <algorithm> // count_ifに必要
#include <array>     // size固定の配列
#include <queue>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains(InputIterator iterator, const T &value)
{
  if (find(iterator.begin(), iterator.end(), value) == iterator.end())
    return false;
  else
    return true;
}

// =========ここまでテンプレ============

int main()
{
  ll n;
  vector<ll> a;
  cin >> n;
  a.push_back(0);
  for (int i = 1; i < n; i++)
  {
    ll j;
    cin >> j;
    a.push_back(0);
    a[j - 1] = a[j - 1] + 1;
  }
  for (auto itr = a.begin(); itr != a.end(); ++itr)
  {
    cout << *itr << endl;
  }
}

Measured memory_bytes: 4852
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleTest
{
    static partial class Program
    {
  

        static void Main(string[] args)
        {
            _ = Int();
            var a = Ints();
            var b = new int[a.Length+2];
            for(int i = 0; i < a.Length; ++i)
            {
                b[a[i]]++;
            }
            for(int i=1; i <= a.Length+1; ++i)
            {
                Console.WriteLine(b[i]);
            }


        }

    }
    static partial class Program
    {
        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }
        public static int[] Ints()
        {
            return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        }
        public static long[] Longs()
        {
            return Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        }
        public static int[][] MultiInts(int num)
        {
            var result = new int[num][];
            for(int i = 0; i < num; ++i)
            {
                result[i] = Ints();
            }
            return result;
        }
        public static T[] MultiItems<T>(int num, Func<string,T> parser)
        {
            var result = new T[num];
            for(int i =0; i < num; ++i)
            {
                result[i] = parser(Console.ReadLine());
            }
            return result;
        }
    }
}


Measured memory_bytes: 43648
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll x,y,i,j,a,b,c;
            cin>>x>>y>>a>>b>>c;
            ll ar[a+1],ar2[b+1],ar3[c+1];
            for(i=1;i<=a;++i)
            {
                cin>>ar[i];
            }
            for(i=1;i<=b;++i)
            {
                cin>>ar2[i];
            }
            for(i=1;i<=c;++i)
            {
                cin>>ar3[i];
            }
            sort(ar+1,ar+a+1);
            sort(ar2+1,ar2+b+1);
            sort(ar3+1,ar3+c+1);
            vector<ll> v;
            ll ans=0;
            for(i=1;i<=x;++i)
            {
                v.pb(ar[a-i+1]);
            }
            for(i=1;i<=y;++i)
            {
                v.pb(ar2[b-i+1]);
            }
            for(auto it:v)
            {
                ans=ans+it;
            }
            sort(v.begin(),v.end());
            i=0;
            j=c;
            while(i<v.size() && j>0)
            {
                if(v[i]>=ar3[j])
                    break;
                ans=ans-v[i]+ar3[j];
                ++i,--j;
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n, c0, c1, c2, c3, sVal;
    c0 = c1 = c2 = c3 = 0;
    cin >> n;
    char c [4];
    for (int i=0; i < n; i++) {
        cin >> c;
        sVal = strcmp(c, "RE");
        if ( sVal ==0) c3++;
        else if(sVal < 0) c0++;
        else {
            if (strcmp(c, "WA")==0) c1++;
            else c2++;
        }
    }
    cout << "AC x " << c0 << endl;
    cout << "WA x " << c1 << endl;
    cout << "TLE x " << c2 << endl;
    cout << "RE x " << c3 << endl;

    return 0;
}


Measured memory_bytes: 3620
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <random>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
#include <time.h>

using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    V A(n), B(n);
    rep(i, n) cin >> A[i] >> B[i];
    ll mask = 0;
    ll res = 0;
    for (int i = 0; i <= 30; i++)
    {
        ll tempmask = 0;
        if((k<(1<<i))&&i!=0)continue;
        if(!(k&(1<<i))&&i!=0)continue;
        tempmask = k&~(1<<i);
        for(int j=0;j<i;j++){
            tempmask|=(1<<j);
        }
        if(i==0){
            tempmask = k;
        }
        ll tempsum = 0;
        for (int j = 0; j < n;j++){
            if(tempmask==(tempmask|A[j])){
                tempsum += B[j];
            }
        }
        chmax(res, tempsum);
        mask |= (1 << i);
      //  cout<<bitset<30>(tempmask)<<endl;
    }
    cout << res << endl;
}


Measured memory_bytes: 1920
n = int(input())
a = list(map(int, input().split()))
cnt = 0
mi = 10**9 + 7
for i in range(n):
    if a[i] < 0:
        cnt += 1
        a[i] *= -1
    mi = min(mi, a[i])
print(sum(a)) if cnt % 2 == 0 else print(sum(a) - mi * 2)

Measured memory_bytes: 14412
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
const ll mod=1e9+7;

const int N=1<<21;
ll dp[22][N],n;
vector<vector<int>> a(22,vector<int>(22));

ll go(int pos, int mask){
    if(pos==n) return 1;
    if(dp[pos][mask]!=-1)
        return dp[pos][mask];
    ll ans=0;
    for(int i=0;i<n;i++){
        if(a[pos][i] && (mask&(1<<i))==0)
            ans=(ans+go(pos+1,mask|(1<<i)))%mod;
    }
    return dp[pos][mask]=ans;
}


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();
    
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(ll i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>a[i][j];
    cout<<go(0,0);

    

    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}

Measured memory_bytes: 364272
from numpy import cumsum
n,m=map(int,input().split())
a=list(map(int,input().split()))
result=cumsum(a)[-1]
mi=result/(4*m)
ans=0
for i in range(n):
    if a[i]>=mi:
        ans+=1
if ans>=m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 27140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int P = sc.nextInt();
		int Q = sc.nextInt();
		int R = sc.nextInt();
		int result_1 = P + Q;
		int result_2 = Q + R;
		int result_3 = R + P;
		int output = Math.min(result_1,(Math.min(result_2,result_3)));
      System.out.println(output);
	}
}

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

const int N = 1010;
const int inf = 1e9 + 7;

int n, x[N], ch[N];
int f[N][5010], g[N][5010];
vector<int> G[N];

void dfs(int u) {
	ch[u] = 1;
	for (int i = 1; i <= x[u]; ++i) f[u][i] = inf;
	for (int v: G[u]) {
		dfs(v);
		ch[u] += ch[v];
		for (int j = 0; j <= x[u]; ++j) g[u][j] = inf;
		for (int j = 0; j <= x[u]; ++j) {
			if (j >= f[v][x[v]]) g[u][j] = min(g[u][j], f[u][j - f[v][x[v]]] + x[v]);
			if (j >= x[v]) g[u][j] = min(g[u][j], f[u][j - x[v]] + f[v][x[v]]);
		}
		for (int j = 0; j <= x[u]; ++j) f[u][j] = g[u][j];
	}
	if (ch[u] == 1) {
		f[u][x[u]] = 0;
		for (int i = 0; i < x[u]; ++i) f[u][i] = inf;
		return;
	}
	for (int j = 0; j <= x[u] - 1; ++j) f[u][x[u]] = min(f[u][x[u]], f[u][j]);

	if (f[u][x[u]] == inf) {
		printf("IMPOSSIBLE\n");
		exit(0);
	}
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 2; i <= n; ++i) {
		int p; cin >> p;
		G[p].push_back(i);
	}
	for (int i = 1; i <= n; ++i) cin >> x[i];

	dfs(1);

	printf("POSSIBLE\n");
}

Measured memory_bytes: 38144
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static ArrayList<Integer> list = new ArrayList<>();
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		sc.close();
		int al = (int) ceil(a*12.5);
		int ah = (int) ceil((a+1)*12.5)-1;
		int bl = b*10;
		int bh = (b+1)*10-1;
//		out.printf("%d,%d,%d,%d%n", al, ah, bl, bh);
		int ans = -1;
		int ml = Math.max(al, bl);
		int mh = Math.min(ah, bh);
		if(ml <= mh) {
			ans = ml;
		}
		out.println(ans);
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
   int n;
   cin>>n;
   int d[n];
   for(int i=0;i<n;i++){
      cin>>d[i];
   }
   int ans=0;
   for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
         ans+=d[i]*d[j];
      }
   }
   cout<<ans<<endl;
   return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.length();

    int ans = n;

    for (int i = 0; i < n - 1;i++)
    {
        if(s[i] != s[i + 1])
        {
            ans = min(ans, max(i + 1, n - (i + 1)));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll powmod(ll a, ll b) {
	a %= MOD;
	ll res = 1;
	while (b > 0) {
		if (b % 2 == 1)res = res * a % MOD;
		a = a * a % MOD;
		b /= 2;
	}
	return res;
}


ll com(ll n, ll r) {
	ll res = 1;
	REP(i, r) {
		res *= n - i;
		res %= MOD;
		res *= powmod(i + 1, MOD - 2);
		res %= MOD;
	}
	return res;
}

int main() {\
	ll n, a, b;
	cin >> n >> a >> b;
	cout << (powmod(2, n) - 1 - com(n, a) - com(n, b) + (ll)MOD * 4) % MOD << endl;
}



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

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int n,m;cin>>n>>m;
    vector<int> a(n);
    int s = 0;
    rep(i, n) {
        cin>>a[i];
        s += a[i];
    }
    dump(a);

    cout << (n-s>=0 ? n-s : -1) << endl;
    return 0;
}


Measured memory_bytes: 11120
from collections import Counter

N, M= [int(x) for x in input().strip().split(' ')]
A = [int(a) for a in input().split()]
A_mod = [0]
s = 0
for elem in A:
    A_mod.append((elem+s) % M)
    s += elem

cnt = Counter(A_mod)
c = 0
for k in cnt.keys():
    if cnt[k] != 1.0:
        c += (cnt[k])*(cnt[k]-1)/2

print(int(c))


Measured memory_bytes: 17368
maxnum=0

if(__name__=="__main__"):
    N = int(input())
    a =[int(input()) for i in range(N)]
    #print(sum(a))
    
    if(sum(a) % 10 != 0):
        print(sum(a))
    else:
        a_sort = sorted(a)
        for i in range(0,N):
            if(a_sort[i] % 10 != 0):
                del a_sort[i]
                maxnum = sum(a_sort)
                break
            

        print(maxnum)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int a[6];
    for(int i=1;i<=5;i++)
        cin>>a[i];
    for(int i=1;i<=5;i++)
        if(a[i]==0)
        cout<<i;
    return 0;
    }


Measured memory_bytes: 3584
N,W = map(int,input().split())

lis = [ [0] * (W+1) ]


for i in range(N):

    w,v = map(int,input().split())

    new = [0] * (W+1)

    for j in range(W+1):

        new[j] = max(new[j],lis[-1][j])

        if j+w <= W:

            new[j+w] = max(new[j+w],lis[-1][j]+v)

    lis.append(new)

print (lis[-1][W])


Measured memory_bytes: 118620
class Combination:
    def __init__(self, n_max=10**6, mod=10**9+7):
        # self._n_max = n_max
        self._fac, self._finv, self._inv = [0]*n_max, [0]*n_max, [0]*n_max
        self._fac[0], self._fac[1] = 1, 1
        self._finv[0], self._finv[1] = 1, 1
        self._inv[1] = 1
        self._mod = mod
        for i in range(2, n_max):
            self._fac[i] = self._fac[i - 1] * i % self._mod
            self._inv[i] = self._mod - self._inv[self._mod%i] * (self._mod // i) % self._mod
            self._finv[i] = self._finv[i - 1] * self._inv[i] % self._mod
    def com(self, n, r):
        if n < r: return 0
        if n < 0 or r < 0: return 0
        return self._fac[n] * (self._finv[r] * self._finv[n - r] % self._mod) % self._mod

    def perm(self,n,r):
        if n < r: return 0
        if n < 0 or r < 0: return 0
        return self._fac[n] * (self._finv[n-r] % self._mod) % self._mod

MOD = 10**9+7
comb = Combination(10**5, MOD)
s=int(input())

ans = 0
for i in range(1,670):
    curr_s = s-i*3
    ans += comb.com(curr_s+i-1,i-1)
    ans%=MOD

print(ans)



Measured memory_bytes: 67120
#include<bits/stdc++.h>
using namespace std;
int main(){

    int N,M;
    scanf("%d %d",&N,&M);
    int P[M],Y[M],Index[M],Count[N+1]={0};
    for(int i=0;i<M;i++){
        scanf("%d %d",P+i,Y+i);
        Index[i] = i;
    }
 
    sort(Index,Index+M,[&](int a, int b){return Y[a]<Y[b];});

    for(int i=0;i<M;i++){
        Y[Index[i]] = ++Count[P[Index[i]]];
    }
    for(int i=0;i<M;i++){
        printf("%06d%06d\n",P[i],Y[i]);
    }
}


Measured memory_bytes: 3072
N, X, M = map(int, input().split())

if X == 0:
    print(0)
    exit()

if N == 1:
    print(X)
    exit()

d = [-1] * (M + 1)
out = [0]
a = X
ans = 0
for i in range(1, N + 1):
    ans += a
    d[a] = i
    out.append(a)
    a = a ** 2 % M
    if a == 0:
        print(ans)
        exit()

    if d[a] != -1:
        loop_num = i + 1 - d[a]
        remain = N - i
        ans += sum(out[d[a]:d[a] + loop_num]) * (remain // loop_num)
        ans += sum(out[d[a]:d[a] + (remain % loop_num)])
        break
print(ans)


Measured memory_bytes: 69900
n = input()
k = int(input())
l = len(n)
dp = [[[0] * (k+1) for _ in range(2)] for _ in range(l+1)]
dp[0][0][0] = 1

for i in range(1, l+1):
    m = int(n[i-1])
    for j in range(k+1):
        
        dp[i][1][j] += dp[i-1][1][j]*1  # 0
        if j - 1 >= 0:
            dp[i][1][j] += dp[i-1][1][j-1]*9  # 1〜9
            
        if m == 0:
            pass
        elif m >= 1:
            dp[i][1][j] += dp[i-1][0][j]
            if j - 1>= 0:
                dp[i][1][j] += dp[i-1][0][j-1]*(m-1)
        
        if m == 0:
            dp[i][0][j] += dp[i-1][0][j]
        else:
            if j - 1>= 0:
                dp[i][0][j] += dp[i-1][0][j-1]
        
print(dp[-1][0][k] + dp[-1][1][k])

Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<utility>
using namespace std;
int main(void){
    int n;
    cin>>n;
vector<int> min(n),max(n);
for(int i=0;i<n;i++)
cin>>min[i]>>max[i];
for(int i=n+1;i>0;i--){
    int l=0;
    for(int j=0;j<n;j++){
        if(min[j]<=i&&i<=max[j])
        l++;
    }
    if(l+1>=i){
cout<<i-1<<endl;
        break;
    }
}
return 0;
}

Measured memory_bytes: 3620