akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >>n;
    vector<vector<pair<int,int>>> a(n);
    rep(i,0,n){
        int b;
        cin >> b;
        rep(j,0,b){
            int t,t1;
            cin >> t >> t1;
            a[i].push_back(make_pair(t-1,t1));
        }
    }
    int ans=0;
    bool ok = true;
    rep(bit,0,(1<<n)){
        ok = true;
        rep(shift,0,n){
            if(!(bit & (1<<shift))) continue;
            rep(i,0,a[shift].size()){
                //cout <<a[shift][i].second<< (bool)(bit & (1<<a[shift][i].first)) << endl;
                if(a[shift][i].second != (bool)(bit & (1<<a[shift][i].first))) ok = false;
            }
            if(!ok) break;
        }
        if(!ok) continue;
        int cnt=0;
        rep(shift,0,n) if(bit & (1<<shift)) cnt++;
        ans = max(cnt,ans);
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

struct info{
    
    map<int, pair<int, int> > m;
    vector<int> h;
    vector<int> w;
    int a, b;
    info(int n, vector<vector<int> > mat){
        h.resize(n + 1, 0);
        w.resize(n + 1, 0);
        a = 0;
        b = 0;

        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                m[mat[i][j]] = {i + 1, j + 1};
            }
        }
    }
};

signed main(){
    
    int n, u, v, m; cin >> n >> u >> v >> m;
    if(n == 1){
        u += 3;
        v += 3;
    }
    vector<vector<int> > a(n, vector<int> (n));
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> a[i][j];
    info usa = info(n, a);
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> a[i][j];
    info neko = info(n, a);
    
    int ans = 0;
    
    set<int> hoge;
    for(int i = 0; i < m; i++){
        int val; cin >> val;
        if(hoge.find(val) != hoge.end()) continue;
        hoge.insert(val);
        if(ans != 0) continue;

        int usa_i = usa.m[val].first;
        int usa_j = usa.m[val].second;
        
        int neko_i = neko.m[val].first;
        int neko_j = neko.m[val].second;

        usa.h[usa_i]++; 
        if(usa_i != 0 && usa.h[usa_i] == n) u--;
        usa.w[usa_j]++;
        if(usa_i != 0 && usa.w[usa_j] == n) u--;
        
        if(usa_i != 0 && usa_i - usa_j == 0) usa.a++;
        if(usa_i != 0 && usa.a == n){ u--; usa.a++; }
        if(usa_i != 0 && usa_i + usa_j == n + 1) usa.b++;
        if(usa_i != 0 && usa.b == n){ u--; usa.b++; }

        neko.h[neko_i]++;
        if(neko_i != 0 && neko.h[neko_i] == n) v--;
        neko.w[neko_j]++;
        if(neko_i != 0 && neko.w[neko_j] == n) v--;
        
        if(neko_i != 0 && neko_i - neko_j == 0) neko.a++;
        if(neko_i != 0 && neko.a == n){ v--; neko.a++; }
        if(neko_i != 0 && neko_i + neko_j == n + 1) neko.b++;
        if(neko_i != 0 && neko.b == n){ v--; neko.b++; }
        
        
        
        if(u <= 0 && v > 0){
            ans = 1;
            continue;
        }else if(u > 0 && v <= 0){
            ans = 2;
            continue;
        }else if(u <= 0 && v <= 0){
            ans = 3;
            continue;
        }
    }

    if(ans == 0 || ans == 3) cout << "DRAW" << endl;
    else if(ans == 2) cout << "NEKO" << endl;
    else cout << "USAGI" << endl;
    
    return 0;
}




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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  if (s.at(0) == 'A') ans++;  //  条件１

  for (int i = 2; i < s.size() - 1; i++) {   // 条件２
    if (s.at(i) == 'C') {
      ans++;
      break;
    }
  }
  int num = 0;
  for (int i = 1; i < s.size(); i++) {  //  条件３
    if (s.at(i) >= 'A' && s.at(i) <= 'Z') num++;
  }
  if (num == 1) ans++;

  if (ans == 3) cout << "AC" << endl;  // トータル
  else  cout << "WA" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll H, W;
    cin >> H >> W;
    V<string> vs(H);
    for(auto &s : vs) cin >> s;

    ll ans = 0;
    queue<PLL> que;
    for(ll i = 0; i < H; i++) for(ll j = 0; j < W; j++) if(vs[i][j] == '#') que.emplace(i, j);
    ll cnt = que.size();

    ll dh[] = { 1, 0, -1, 0 };
    ll dw[] = { 0, 1, 0, -1 };
    while(cnt < H * W) {
        ans++;
        queue<PLL> nque;
        while(que.size()) {
            ll h, w;
            tie(h, w) = que.front();
            que.pop();
            for(ll i = 0; i < 4; i++) {
                ll nh = h + dh[i];
                ll nw = w + dw[i];
                if(!(0 <= nh && nh < H &&
                     0 <= nw && nw < W)) continue;
                if(vs[nh][nw] == '#') continue;
                vs[nh][nw] = '#';
                nque.emplace(nh, nw);
            }
        }
        que = move(nque);
        cnt += que.size();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 17716
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vector <int> H(N);
    loop(i,0,N) cin >> H[i];
    vector <int> dp(N);
    dp[0]=0;
    dp[1]=abs(H[1]-H[0]);
    loop(i,2,N) dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]));
    cout << dp[N-1] << "\n";
    return 0;
}

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

int main(){
  string S ;
  cin >> S;
  
  if ( S[0] == S[1] && S[1] == S[2] && S[2] == S[3] ){
    cout << "No" << endl;
  }
  
  else if ( S[0] == S[1] && S[2] == S[3] ){
    cout << "Yes" << endl;
  }
  
  else if ( S[0] == S[2] && S[1] ==S[3] ){
    cout << "Yes" << endl;
  }
  
  else if ( S[0] == S[3] && S[1] == S[2] ){
    cout << "Yes" << endl;
  }
  
  else if ( S[0] == S[1] && S[1] == S[2] && S[2] == S[3] ){
    cout << "No" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}

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

int main(){
	
	
	int n;
	cin >> n;
	
	vector<int> d(n);
	rep(i,n){
		cin >> d[i];
	}
	
	sort(d.begin(),d.end());
	
	int cnt = 0;
	for(int k = d[n/2 -1]+1; k <= d[n/2]; k++) cnt++;

	
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#define LL long long
#define inl inline
#define re register
#define MAXN 10100
using namespace std;
struct ji
{
	string s;
	int p,fl;
}h[1010];
int n;
bool cmp(const ji& a,const ji& b)
{
	if(a.s==b.s)return a.p>b.p;
	return a.s<b.s;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>h[i].s>>h[i].p,h[i].fl=i;
	sort(h+1,h+n+1,cmp);
	for(int i=1;i<=n;i++)cout<<h[i].fl<<endl;
	return 0;
}



Measured memory_bytes: 256
import Data.List ( sort )
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

getParm
  :: IO [Int]
getParm = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,x] <- getParm
  as    <- getParm
  print $ f n x as

f :: Int -> Int -> [Int] -> Int
f n x as
  | t < x     = n-1
  | otherwise = k
  where
    t = sum as
    lengthUpto x = length . takeWhile (<= x) 
    k = lengthUpto x sums
    sums = scanl1 (+) as'
    as' = sort as

Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  cout << a.at(N-1) - a.at(0) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int n,m,a,b,c,t;
V M(const V &x,const V &y){
	V z(n*n);
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(x[slice(i*n,n,1)]*y[slice(j,n,n)]).sum()%m;
	return z;
}
V E(const V &x,const int n){
	if(n==1)return x;
	if(n&1)return M(E(x,n-1),x);
	V y=E(x,n>>1);
	return M(y,y);
}
V s,x;
void O(const V &r){
	int i=0;
	for(;i<n;i++)printf(i<n-1?"%d ":"%d\n",(r[slice(i*n,n,1)]*s).sum()%m);
}
main(){
	int i;
	for(;scanf("%d%d%d%d%d%d",&n,&m,&a,&b,&c,&t),n;){
		s.resize(n);
		for(i=0;i<n;i++)scanf("%d",&s[i]);
		x.resize(0);
		x.resize(n*n);
		if(t){
			x[0]=b;
			x[1]=c;
			for(i=1;i<n-1;i++){
				x[i*n+i-1]=a;
				x[i*n+i]=b;
				x[i*n+i+1]=c;
			}
			x[i*n+i-1]=a;
			x[i*n+i]=b;
			O(E(x,t));
		}else{
			for(i=0;i<n;i++)x[i*n+i]=1;
			O(x);
		}
	}
}

Measured memory_bytes: 1084
module Main where

import Data.Functor
import Numeric

main :: IO ()
main =  do
  { [x,y,z,w] <- getDoubles
  ; putStrLn $ showFFloat Nothing (sqrt ((x-z)^2+(y-w)^2)) ""
  }

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

Measured memory_bytes: 4036
ans = []
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    tmp = 0
    for i in range(1, n - 1):
        for j in range(i + 1, n):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    tmp += 1
    ans.append(tmp)
[print(x) for x in ans]



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<double>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

ll A, B, K;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> A >> B >> K;
    if(A >= K){
        cout << A - K << " " << B << endl;
    }else{
        cout << 0 << " " << max(A + B - K, 0LL) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[1000001],c[1000001];

int main(){
    int b,num=0,l=0;
    cin>>a;
    b=strlen(a);
    
    for(int i=b-1;i>=0;i--) {
        c[num]=a[i];
        if(c[num]=='b') c[num]='d';
        else if(c[num]=='d') c[num]='b';
        else if(c[num]=='p') c[num]='q';
        else if(c[num]=='q') c[num]='p';
        num++;
    }
    
    for(int i=0;i<=b-1;i++) {
        if(a[i]!=c[i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

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

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


int main() {
	LL k, a, b;
	cin >> k >> a >> b;
	if (b <= a + 2 || k + 1 < a) {
		cout << k + 1 << endl;
		return 0;
	}
	k -= a - 1;
	cout << a + (k / 2)*(b - a) + k % 2 << endl;
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
a_list = sorted(map(int, input().split()))
cb_list = []
for _ in range(M):
    b, c = tuple(map(int, input().split()))
    cb_list.append((c, b))
cb_list = sorted(cb_list)[::-1]
sum_val = 0

def gen_next_value():
    for c, b in cb_list:
        for _ in range(b):
            yield c

i = 0
for a, val in zip(a_list, gen_next_value()):
    if val < a:
        break
    sum_val += val
    i += 1
if i == len(a_list):
    print(sum_val)
else:
    print(sum_val + sum(a_list[i:]))

Measured memory_bytes: 22444
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n, a, b;
  cin >> n >> a >> b;
  vector<int> p(n);
  REP(i,n){
    cin >> p[i];
  }

  int pro[3] = {};
  REP(i,n){
    if(p[i] <= a){
      pro[0]++;
    }else if(p[i] >= b+1){
      pro[2]++;
    }else{
      pro[1]++;
    }
  }

  cout << min(pro[0], min(pro[1], pro[2])) << endl;
  return 0;
}



Measured memory_bytes: 256
from collections import deque
S=input()
N=int(input())
Q=[input() for i in range(N)]
T=deque(S)
cnt=0
for i in range(N):
    if Q[i][0]=="1":
        cnt+=1
    if cnt%2==0:
        if Q[i][0]=="2":
            if Q[i][2]=="1":
                T.appendleft(Q[i][4])
            if Q[i][2]=="2":
                T.append(Q[i][4])
    if cnt%2==1:
        if Q[i][0]=="2":
            if Q[i][2]=="1":
                T.append(Q[i][4])
            if Q[i][2]=="2":
                T.appendleft(Q[i][4])
if cnt%2==1:
    T.reverse()
print(''.join(T))

Measured memory_bytes: 21212
N,K=map(int,input().split())
A=list(map(int,input().split()))
MOD=10**9+7
A.sort()

fac=[None for i in range(N)]
finv=[None for i in range(N)]
inv=[None for i in range(N)]

def COMinit(num):
    global fac
    global finv
    global inv
    fac[0]=1
    fac[1]=1
    finv[0]=1
    finv[1]=1
    inv[1]=1

    for i in range(2,num):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

def COM(n,k):
    if n<k:
        return 0
    elif n<0 or k<0:
        return 0
    else:
        return int(fac[n] * (finv[k] * finv[n - k] % MOD) % MOD)
        
ans=0
COMinit(N)

for i in range(N-K+1):
    ans+=A[-(i+1)]*COM(N-(1+i),K-1)
    ans=ans%MOD
    ans-=A[i]*COM(N-(1+i),K-1)
    ans=ans%MOD

print(ans)


Measured memory_bytes: 19280
#include <iostream>

using namespace std;

int main()
{
    int m,n;

    cin >> m >> n;

    while((m!=0)||(n!=0)){
        if(m>n){
            int temp;
            temp = m;
            m = n ;
            n = temp;
        }
        cout << m <<" " << n <<endl;
        cin >> m >> n;
    }

    return 0;
}



Measured memory_bytes: 3076
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
 
int d, n;
 
int main()
{
	scanf("%d%d", &d, &n);
	if(d==0)
	{
		if(n==100) printf("101");
		else printf("%d\n", n);
	}
	if(d==1)
	{
		if(n==100) printf("10100");
		else printf("%d\n", n*100);
	}
	if(d==2)
	{
		if(n==100) printf("1010000");
		else printf("%d\n", n*10000);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 1000000

using namespace std;

ll n, m, k;
ll g[3001][3001];
ll dp[3001][3001][4];

ll go(ll x, ll y, ll tot)
{
	if (x >= n || y >= m)return 0;
	ll &ans = dp[x][y][tot];
	if (ans != -1)return ans;
	ans = 0;
	if (tot >= 3)
	{
		ans = max(go(x + 1, y, 0), go(x, y + 1, tot));
	}
	else
	{
		ans = max(go(x + 1, y, 0), go(x, y + 1, tot));
		ans = max({ans, (g[x][y] + go(x + 1, y, 0)), (g[x][y] + go(x, y + 1, tot + 1))});
	}
	return ans;
}

void solve()
{
	cin >> n >> m >> k;
	for (int i = 0; i < 3001; ++i)
	{
		for (int j = 0; j < 3001; ++j)
		{
			g[i][j] = 0;
		}
	}
	for (int i = 0; i < k; ++i)
	{
		ll x, y, v;
		cin >> x >> y >> v;
		x--, y--;
		g[x][y] = v;
	}
	memset(dp, -1, sizeof dp);
	cout << go(0, 0, 0) << endl;
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin >> T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 355972
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int L, R, d, count, i, result;
	count = 0;
	result = 0;

	scanf("%d %d %d", &L, &R, &d);
	
	for (i = 1; result < L; i++) {
		result = d * i;
	}
	for (int j=i; result <= R; j++) {
		result = d * j;
		count++;
	}
	printf("%d", count);
}

Measured memory_bytes: 1736
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cingroup(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfgroup(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
typedef unsigned long long ull;
using namespace std;
map <int,int> m;

int main()
{
//	freopen("input.txt","r",stdin);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		m[a[i]]++;
	}
	int ans=0;
	for(map<int,int>::iterator it=m.begin();it!=m.end();it++)
	{
		int a=it->first;
		int b=it->second;
		if(b==a) continue;
		if(b<a) ans+=b;
		if(b>a) ans+=b-a;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define PB push_back
#define MAX3(i,j,k) max(i,max(j,k))
#define MIN3(i,j,k) min(i,min(j,k))
#define FOR(i,k) for(int i=0; i<k; i++)
#define OUT(x) cout<<(x)<<endl
#define F first
#define S second

using namespace std;

typedef pair<int, int> PII;
template <typename T,typename U>
pair<T,U> operator+(const pair<T,U> & l,const pair<T,U> & r) {   
  return {l.F+r.F,l.S+r.S};
}         
bool IsValid(PII &p, int H, int W) {
  return p.F >= 0 && p.S >= 0 && p.F < H && p.S <= W;
}
vector<PII> neighbors = {{0,1}, {1,0}, {-1,0}, {0,-1}};

bool IsPrime(int n)
{
  if (n <= 1)  return false;
  if (n <= 3)  return true;
  if (n%2 == 0 || n%3 == 0) return false;
  for (int i=5; i*i<=n; i=i+6)
    if (n%i == 0 || n%(i+2) == 0)
      return false;
  return true;
}

int main() {
  int n;
  cin>>n;
  int base=10;
  FOR(i,55555) {
    if(IsPrime(base+1)) {
      cout<<(base+1)<<" ";
      n--;
      if(n==0)
	break;
    }
    base+=5;
  }
  cout<<endl;
}

Measured memory_bytes: 256
//panasonic2020_d.cpp
//Sat Mar 14 20:55:56 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

int n;

void dfs(string x, char c){
	if (x.length()==n){
		cout << x << endl;
	}else {
		string temp = "a";
		while (temp[0]<=c){
			string y = x+temp;
			if (temp[0]==c){
				dfs(y,c+1);
			}else {
				dfs(y,c);
			}
			temp[0]++;
		}
	}

}


int main(){
	cin >> n;

	string a = "a";

	dfs(a,'b');

//	printf("%.4f\n",ans);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  if (S == "keyence") {
    cout << "YES"<< endl;
    return 0;
  }
  if (N == 7) {
    cout << "NO" << endl;
  }
  //iは除く文字列の最初の位置
  for (int i = 0; i <= 6; i++) {
    string s = S;
    string Sn = s.erase(i, N-7);
    if (Sn == "keyence") {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

double median(vi v)
{
	sort(all(v));
	ll int n=v.size();
	if(n%2==1)
	{
		return v[n/2];
	}
	else
	{
		ll int l=n/2;
		ll int r=l-1;
		double avg=(v[l]+v[r])/2.0;
		return avg;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n;
		cin>>n;
		vi a(n),b(n);
		for(ll int i=0;i<n;i++)
		{
			cin>>a[i]>>b[i];
		}
		if(n%2==1)
		{
			ll int l=median(a);
			ll int r=median(b);
			cout<<r-l+1<<endl;
		}
		else
		{
			double l=median(a);
			double r=median(b);
			l*=2;
			r*=2;
			ll int ans=r-l+1;
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 7936
#include <stdio.h>

int main(void){
    int n;
    long long ans=0, a[200000];
    scanf("%d", &n);
    for(int i =0; i<n; i++){
        scanf("%lld", &a[i]);
        if(i != 0){
            if(a[i-1]>a[i]){
                ans += a[i-1] - a[i];
                a[i] = a[i-1];
            }
        }
    }

    printf("%lld\n", ans);


    return 0;
}


Measured memory_bytes: 3296
# -*- coding:utf-8 -*-

def main():
    N = int(input())
    a_list = list(map(int, input().split()))

    # 初期設定
    ans = 0
    a_set = set(a_list)

    for a in a_set:
        c = a_list.count(a) # 要素の出現回数をカウントする
        if c < a:
            ans += c
        elif c > a:
            ans += c-a
    print(ans)

def main2():
    N = int(input())
    a_list = list(map(int, input().split()))
    ans = 0

    import collections
    count_dict = collections.Counter(a_list) # キーに要素、値に出現回数の辞書

    for key in count_dict:
        diff = key - count_dict[key]
        if diff == 0:
            continue
        elif diff > 0:
            ans += count_dict[key]
        elif diff < 0:
            ans += abs(diff)
    print(ans)



if __name__ == "__main__":
    main2()


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

int main( void ){
  int N, n, flag;
  double buf, ans;
  double* v;

  scanf("%d", &N);

  v = (double*)malloc(sizeof(double) * N);

  for(int i = 0; i < N; i++){
    scanf("%lf", &v[i]);
  }

  n = N;
  do{
    flag = 0;
    n--;
    for(int i = 0; i < n; i++){
      if(v[i] > v[i+1]){
        buf = v[i];
        v[i] = v[i+1];
        v[i+1] = buf;
        flag = 1;
      }
    }
  }while(flag == 1);

  ans = v[0];
  for(int i = 1; i < N; i++){
    ans += v[i];
    ans /= 2.0;
  }

  printf("%lf\n", ans);

  free(v);

  return 0;
}



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

using IV = std::vector<int>;
IV ToFixedIntArray(std::istream& is, int n) {
	IV ret(n);
	auto* dst = ret.data();
	while(n > 0) {
		--n;
		is >> *dst++;
	}
	return ret;
}

void DisableIOSync() {
	std::cin.tie(0);
	std::cout.tie(0);
	std::ios::sync_with_stdio(false);
}
int main() {
	DisableIOSync();
	const auto pos = ToFixedIntArray(std::cin, 3);
	const int distA = std::abs(pos[0] - pos[1]),
				distB = std::abs(pos[0] - pos[2]);
	char res;
	if(distA < distB) {
		res = 'A';
	} else {
		res = 'B';
	}
	std::cout << res << std::endl;

	return 0;
}

Measured memory_bytes: 256
import math
Q=int(input())

def primelist(x):
  limit=math.sqrt(x)
  
  prime=[]
  search=list(range(2,x+1))
  
  while 1:
    if search[0]>limit:
      prime+=search
      break
    else:
      head_num = search.pop(0)
      prime.append(head_num)
      #head_numの倍数を取り除く
      search = [num for num in search if num % head_num != 0]
      
  return prime 

prime=primelist(10**5+1)
judge=[0]
for i in range(1,10**5+2):
  if i % 2==0:
    judge.append(judge[i-1])
  else:
    if i in prime and (i+1)//2 in prime:
      judge.append(judge[i-1]+1)
    else:
      judge.append(judge[i-1])
      
for i in range(Q):
  l,r=map(int,input().split())
  print(judge[r]-judge[l-1])
  
  
  

Measured memory_bytes: 53564
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)  # aを優先度付きキューに

for _ in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-tmp_min//2))  # 計算誤差の関係で-1を2回かけてます
print(-sum(a))

Measured memory_bytes: 14184
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

// aのp乗を求める関数
ll mpow(ll a, ll b){
	if(b==0){
		return 1;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1)*a%MOD;
	}
}

// aCbを求める関数
ll mod_combination(int a, int b){
  if(b>a-b) return mod_combination(a,a-b);
  ll ansMul = 1, ansDiv = 1;
  rep(i, b) {
    ansMul *= (a-i); ansDiv *= (i+1);
    ansMul %= MOD; ansDiv %= MOD;
  }
  ll ans = ansMul*mpow(ansDiv, MOD-2)%MOD;
  return ans;
}

signed main(){
	ll h,w; cin>>h>>w;
	ll ans = INF;
	reps(i,h){
		ll sa = i*w;
		ll yoko = w/2;
		ll sb = (h-i)*yoko, sc = (h-i)*(w-yoko);
		// cerr << sa SP sb SP sc << endl;
		chmin(ans,max(abs(sa-sb),max(abs(sb-sc),abs(sc-sa))));
		ll tate = (h-i)/2;
		sb = tate*w, sc = (h-i-tate)*w;
		chmin(ans,max(abs(sa-sb),max(abs(sb-sc),abs(sc-sa))));
	}
	reps(i,w){
		ll sa = i*h;
		ll yoko = h/2;
		ll sb = (w-i)*yoko, sc = (w-i)*(h-yoko);
		// cerr << sa SP sb SP sc << endl;
		chmin(ans,max(abs(sa-sb),max(abs(sb-sc),abs(sc-sa))));
		ll tate = (w-i)/2;
		sb = tate*h, sc = (w-i-tate)*h;
		chmin(ans,max(abs(sa-sb),max(abs(sb-sc),abs(sc-sa))));
	}
	cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

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

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b,n;
    cin>>a>>b>>n;
    ll mini=min(n,b-1);
    cout<<floor(a*mini/b)-a*floor(mini/b)<<endl;
    return 0;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
#define int long long
int arr[666];
signed main(){
	int n,m;cin>>n>>m;int s=0;
	for(int i=0;i<m;i++){
		int t;cin>>t;s+=t;
	}
	if(s>=n) cout<<"Yes";
	else cout<<"No";
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define chmax(x, y) { x = max(x, y); }
#define chmin(x, y) { x = min(x, y); }
#define INF 1e7

int main() {
    int n;
    cin >> n;
    st c;
    cin >> c;
    int rsum = 0;
    rep(i, n){
        if(c.at(i) == 'R'){
            rsum++;
        }
    }
    int ans = 0;
    rep(i, rsum){
        if(c.at(i) == 'W'){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3764
n = int(input())
a = list(map(int, input().split()))
a_max = max(a)
l = len(bin(a_max)) - 2
bits = [[0, 0] for _ in range(l)]
for num in a:
    for i, bit in enumerate(format(num, 'b').zfill(l)):
        if bit == '0':
            bits[i][0] += 1
        else:
            bits[i][1] += 1

sumation = 0
div = (10**9+7)
for i in range(l):
    sumation += (bits[i][0]) * (bits[i][1]) * (2**(l-i-1) % div)
print(int(sumation % (10**9+7)))
    

Measured memory_bytes: 125624
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 2e5 + 10;

int a[N],ed[N],num[N];
int n;

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline int Pw(int cnt,int val) {
	ll res = 1;
	For(i,1,cnt) {
		res *= val;
		if(res > N) return INF;
	}
	return res;
}

inline bool check(int val) {
	int top = 0;
	memset(num,0,sizeof(num));
	memset(ed,0,sizeof(ed));
	For(i,1,n) {
		if(a[i] > ed[top]) {
			ed[++top] = a[i],num[top] = 0;
		} else {
			while(top && ed[top - 1] + 1 > a[i]) top--;
			num[top] /= Pw(ed[top] - a[i],val),ed[top] = a[i];
			num[top]++;
			int pos = top;
			while(pos && num[pos] >= Pw(ed[pos] - ed[pos - 1],val))
				num[pos - 1]++,num[pos] = 0,pos--;
			if(num[0]) return false;
		}
	}
	return true;
}

int main() {

	n = read();
	int flag = true;
	For(i,1,n) {
		a[i] = read();
		if(i > 1 && a[i - 1] >= a[i]) flag = false;
	}
	if(flag) return puts("1"),0;

	int l = 2,r = n;
	while(l < r) {
		int mid = (l + r) >> 1;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}

	printf("%d\n",l);
	return 0;
}

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

int main() {
	char x,y;
  	cin >> x >> y;
  
  	if(x < y) {
    	cout << '<' << endl;
    }else if(x > y) {
    	cout << '>' << endl;
    }else {
    	cout << '=' << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	int n;
	long min=1000000,max=-1000000,s=0;
	Scanner scan = new Scanner(System.in);
	n= scan.nextInt();
	int[] a=new int[n];
	for(int i=0;i<n;i++) {
		a[i]=scan.nextInt();
		s=s+a[i];
		if(max<a[i])
			max=a[i];
		if(min>a[i])
			min=a[i];
		
	}
	System.out.println(min+" "+max+" "+s);
	
}
}

Measured memory_bytes: 41880
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,n,k,sum=0;
    cin>>n>>k;
    for(int i=1; i<=n; i++)
    {
        cin>>a;
        if(a>=k)
        {
            sum++;
        }
    }
    cout<<sum<<endl;

    return 0;
}

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

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0];
    auto M = s[1];
    auto S = readln.chomp;
    auto T = readln.chomp;

    auto L = N * M / gcd(N, M);
    char[long] X;

    long p = 0;
    long a = L / N;
    foreach (i; 0..N) {
        if (p in X) {
            if (X[p] != S[i]) {
                writeln(-1);
                return;
            }
        }
        X[p] = S[i];
        p += a;
    }

    p = 0;
    a = L / M;
    foreach (i; 0..M) {
        if (p in X) {
            if (X[p] != T[i]) {
                writeln(-1);
                return;
            }
        }
        X[p] = T[i];
        p += a;
    }

    writeln(L);
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll cash = 1000;
    ll gap = 0;
    int i = 1;
    for (; i<n; i++) {
        if (a[i] > a[i-1]) gap += a[i] - a[i-1];
        else {
            if (gap != 0) {
                ll stocks = cash / (a[i-1] - gap);
                cash += stocks * gap;
                gap = 0;
            }
        }
    }
    if (gap != 0) {
        ll stocks = cash / (a[i-1] - gap);
        cash += stocks * gap;
    }
            
    cout << cash << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

#define MAXN 200001
#define MOD 1000000007

long long f[MAXN], invf[MAXN];
int H, W, A, B;
long long ans;

long long modpow(long long x, long long y)
{
	long long ret = 1LL;

	while (y)
	{
		if (y & 1LL)
		{
			ret *= x;
			ret %= MOD;
		}
		x *= x;
		x %= MOD;
		y >>= 1LL;
	}

	return ret;
}

long long nCr(int n, int r)
{
	if (r == 0 || r == n) return 1;
	return ((f[n] * invf[n-r] % MOD) * invf[r] % MOD);
}

int main(void)
{
	int i;

	scanf("%d %d %d %d", &H, &W, &A, &B);

	f[0] = 1;
	for (i = 1; i <= H + W; ++i)
	{
		f[i] = f[i-1] * i % MOD;
		invf[i] = modpow(f[i], MOD-2);
	}

	for (i = B; i < W; ++i)
	{
		ans += nCr(H - A + i - 1, i) * nCr(A + W - i - 2, W - i - 1) % MOD;
	}
	printf("%lld\n", ans % MOD);

	return 0;
}

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

int main(void)
{
	int n;
	cin >> n;
	vector<int>res(n);
	for (int i = 0; i < n; i++)cin >> res[i];
	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		int b, e;
		cin >> b >> e;
		reverse(res.begin() + b, res.begin() + e);
	}
	for (int i = 0; i < n; i++)
		if (i == 0)cout << res[i];
		else cout << " " << res[i];
	cout << endl;
	return 0;
}


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

cnt = 0

for i in range(N):
    ans = C
    for j in range(M):
        ans += A[i][j] * B[j]
    if ans > 0:
        cnt += 1

print(cnt)


Measured memory_bytes: 3060
#include<stdio.h>
#define MAX 26
#define NIL -1


struct Node { int parent, leftChild, rightChild; };
Node T[MAX];

// root , left, right
void preOrder(int node) {
	if (node == NIL)
		return;
	printf(" %d", node);
	preOrder(T[node].leftChild);
	preOrder(T[node].rightChild);
}

// left, root, right
void inOrder(int node) {
	if (node == NIL){
		return;
	}
	inOrder(T[node].leftChild);
	printf(" %d", node);
	inOrder(T[node].rightChild);
}

//left, right, root
void postOrder(int node) {
	if (node == NIL){
		return;
	}
	postOrder(T[node].leftChild);
	postOrder(T[node].rightChild);
	printf(" %d", node);
}

void output(int root) {
	printf("Preorder\n");
	preOrder(root);
	printf("\nInorder\n");
	inOrder(root);
	printf("\nPostorder\n");
	postOrder(root);
	printf("\n");
}

int main() {
	int i, n, id, child_1, child_2, root;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		T[i].parent = NIL;

	for (i = 0; i < n; i++){
		scanf("%d %d %d", &id, &child_1, &child_2);
		T[id].leftChild = child_1;
		T[id].rightChild = child_2;

		if (child_1 != NIL)
			T[child_1].parent = id;
		if (child_2 != NIL)
			T[child_2].parent = id;
	}

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

	output(root);

	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	string s;
	cin >> s;
	int i=0;
	int j=s.length()-1;
	while(s[i]!='A') i++;
	while(s[j]!='Z') j--;
	cout << j-i+1;

	return 0;
}

Measured memory_bytes: 640
import heapq
N, M = map(int, input().split())

W = []  # 取り組める仕事のリスト
for _ in range(N):
    W.append(tuple(map(int, input().split())))
W = sorted(W, key=lambda x: (x[0], -x[1]))


a = []
heapq.heapify(a)  # リストaのheap化

ans = 0
c = 0
for day in range(1, M+1):
    day_c = 0
    while c != N and W[c][0] == day:
        if day_c <= M-day:
            x = W[c][1]
            heapq.heappush(a, -x)  # heap化されたリストaに要素xを追加
            day_c += 1
        c += 1
    if len(a) >= 1:
        ans += -heapq.heappop(a)  # heap化されたリストaから最小値を削除＆その最小値を出力

print(ans)


Measured memory_bytes: 28492
N, A, B = map(int, input().split())

ans = 0


def somesum(x):
    total = 0
    while x > 0:
        total += x % 10
        x = x // 10
    return total


for i in range(N + 1):
    total = somesum(i)
    if total >= A and total <= B:
        ans += i

print(ans)


Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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 vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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 main(){
  ll N;
  cin>>N;
  
  ll ans=N*(N+1)*(N+2)/6;
  REP(i,N-1){
    ll a,b;
    cin>>a>>b;
    if(a>b) swap(a,b);
    ans-=a*(N-b+1);
  }
  co(ans);
  return 0;
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;
#define r(i,a,n) for(int i=a;i<(int)(n);i++)
typedef long long ll;
int main(){
    int a,b,c,ans,n,K;
    cin>>a>>b>>c>>K;
    n=max(a,max(b,c));
    ans=a+b+c;
    ans-=n;
    r(i,0,K)n*=2;
    cout<<ans+n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

ll dp[61][3];

void add(ll &a,ll b){
    a=(a+b)%MOD;
}

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

  dp[60][0]=1;
  for(int i=59;i>=0;i--){
      for(int j=0;j<=2;j++){
          int n=0;
          if(N&(1ll<<i)) n=1;
          for(int k=0;k<=2;k++){
              int ns=2*j+n-k;
              if(ns<0) continue;
              if(ns>2) ns=2;
              add(dp[i][ns],dp[i+1][j]);
          }
      }
  }


  ll ans=0;
  for(int j=0;j<=2;j++) ans=(ans+dp[0][j])%MOD;
  cout<<ans<<endl;


  return 0;
}


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

int main() {
	long long c;
	long long s;
	long long breakdown;
	long long scc;
	cin>>s>>c;
	if(c/2<s){
		scc=scc+c/2;
	}
	else {
		scc=scc+s;
		c=c-s*2;	
		s=s-s;
		scc=scc+c/4;
	}
	cout<<scc<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stdio.h>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

using namespace std;


int main() {
	int n;	cin >> n;
	vector<char>s(n, 0);	rep(i, n) cin >> s[i];
	int ans = n;
	

	rep(i, n - 1) {
		if (s[i] == s[i + 1]) {
			ans--;
		}

	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int x,y;
  int num[13]={0,0,2,0,1,0,1,0,0,1,0,1,0};

  cin>>x>>y;
  if(num[x]==num[y]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include "iostream"
#include<cstring>
using namespace std;
int main()
{
    int grid[4][4];
    bool marked[4][4];
    memset(marked, false, sizeof(marked));
    for(int i=1;i<4;i++)
    { for(int j=1;j<4;j++)
        {
            cin>>grid[i][j];
        }
    }
    
    int n;
    cin>>n;
    int arr[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    
    for(int i=1;i<4;i++)
    { for(int j=1;j<4;j++)
        {

            for(int k=1;k<=n;k++)
            {
                if(grid[i][j]==arr[k])
                {
                    marked[i][j]=true;
                }
            }
            
            
    
        }}
    
    string ans="No";
    
    for(int i=1;i<=3;i++)
    {
        if(marked[i][1] && marked[i][2] && marked[i][3])
            ans="Yes";
        
    }
    
    for(int i=1;i<=3;i++)
    {
        if(marked[1][i] && marked[2][i] && marked[3][i])
            ans="Yes";
        
    }
    
    if(marked[1][1] && marked[2][2] && marked[3][3]) ans = "Yes";
     if(marked[3][1] && marked[2][2] && marked[1][3]) ans = "Yes";
    
    cout<<ans<<endl;
    
    
    
}


Measured memory_bytes: 256