akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillDouble(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%lf", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

char grid[100][100];

pair<int, int> next(int x, int y) {
  if (y == 98) {
    return {x+2, 0};
  } else {
    return {x, y+2};
  }
}

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

  int a,b;
  cin >> a >> b;

  rep(i, 50) rep(j, 100) {
    grid[i][j] = '.';
    grid[i+50][j] = '#';
  }
  a--;
  b--;
  pair<int,int> p = {0, 0};
  while(b) {
    int x = p.first;
    int y = p.second;
    grid[x][y] = '#';
    b--;
    p = next(x, y);
  }
  p = {51, 0};
  while(a) {
    int x = p.first;
    int y = p.second;
    grid[x][y] = '.';
    a--;
    p = next(x, y);
  }

  cout << 100 << " " << 100 << endl;
  rep(i, 100) {
     rep(j, 100) {
       cout << grid[i][j];
     }
     cout << endl;
  }
}

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

using namespace std;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)


int main(){
int n,m,c,r,cnt=0;
  cin>>n>>m>>c;
  vector<int> b(m);
  REP(i,m)cin>>b[i];
  vector<vector<int>> a(n,vector<int> (m));
  REP(i,n)REP(j,m){
  cin>>a[i][j];
  }
  int sum=0;
  REP(i,n)REP(j,m){
  sum+=a[i][j]*b[j];
    if(j==m-1){
    sum+=c;
      if(sum>0){cnt++;}
      sum=0;
    }
  }
  cout<<cnt<<endl;
return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

def main():
	r = II()
	print(2*r*3.14)

if __name__ == '__main__':
	main()

Measured memory_bytes: 9232
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
using namespace std;

#define rep(i,a,b) for(long long int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)





int main()
{
  string str; cin >> str;
  int N = str.size();
  int flag = 0;
  REP(i, N){
    if(str[i] == 'h'){
      i++;
      if(str[i] != 'i'){flag=1; break;}
    } else{ flag=1; break; }
  }
  if(flag == 0){ cout << "Yes" << endl; }
  else{cout << "No" << endl; }

  return 0;
}

Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()



int main() {

	ll K, S;
	cin >> K >> S;

	ll ans = 0;
	rep(i, K + 1) {
		rep(j, K + 1) {
			if (0 <= S - i - j && S - i - j <= K) ++ans;
		}
	}
	cout << ans << endl;
}

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

int n;
int x;
vector<int> ve;
long long z[201010];
int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x;
		ve.push_back(x);
		z[x]++;
	}
	long long su = 0;
	for(int i = 0; i <= n; i++){
		su += (z[i]*(z[i]-1))/2;
	}
	for(int i = 0; i < n; i++){
		cout << su - z[ve[i]]+1 << " ";
	}
}


Measured memory_bytes: 4084
#include <bits/extc++.h>

struct dsu {
  dsu(int n = 0) : _cc(n), dat(n, -1) {}

  int size() const { return std::size(dat); }
  int root(int v) {
    assert(0 <= v), assert(v < size());
    return dat[v] < 0 ? v : dat[v] = root(dat[v]);
  }
  std::pair<int, int> unite(int u, int v) {
    assert(0 <= u), assert(u < size());
    assert(0 <= v), assert(v < size());
    u = root(u), v = root(v);
    if (u == v) return {u, -1};
    --_cc;
    if (-dat[u] < -dat[v]) std::swap(u, v);
    dat[u] += dat[v];
    dat[v] = u;
    return {u, v};
  }
  bool same(int u, int v) {
    assert(0 <= u), assert(u < size());
    assert(0 <= v), assert(v < size());
    return root(u) == root(v);
  }
  int size(int v) {
    assert(0 <= v), assert(v < size());
    return -dat[root(v)];
  }
  int cc() const { return _cc; }

 private:
  int _cc;
  std::vector<int> dat;
};

int main() {
  using namespace std;
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> x(n), y(n), x2i(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
    --x[i], --y[i];
    x2i[x[i]] = i;
  }
  dsu d(n);
  map<int, int> mp;
  vector<int> y_min(n, n);
  for (int nx = 0; nx < n; ++nx) {
    int i = x2i[nx];
    y_min[i] = y[i];
    for (auto it = begin(mp); it != end(mp) and it->first < y[i];) {
      assert(not d.same(it->second, i));
      auto [u, v] = d.unite(it->second, i);
      y_min[u] = min(y_min[u], y_min[v]);
      it = mp.erase(it);
    }
    int v = d.root(i);
    mp.emplace(y_min[v], v);
  }
  for (int i = 0; i < n; ++i) cout << d.size(i) << '\n';
}


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

N, M = map(int, raw_input().split())
_L = 1
_R = N

for i in range(M):
    L, R = map(int, raw_input().split())
    if _L < L:
        _L = L
    if R < _R:
        _R = R 

print str(max(_R-_L+1,0))

Measured memory_bytes: 5764
while 1:
    n=int(input())
    if n==0:break
    box=[list(map(int,input().split())) for i in range(n)]
    a,b=0,0
    for x,y in box:
        if x>y:a +=x+y
        elif y>x:b +=x+y
        elif x==y:
            a +=x
            b +=y
    print(a,b)


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

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

	cout << ans;

	return 0;
}

Measured memory_bytes: 3576
#include<cstdio>
#include<cstring>
using namespace std;

const int maxn=41;
int n,m;
typedef long long ll;
ll f[maxn][maxn][maxn],ans;
char s[maxn][maxn];

ll dp(int l,int r,int mid)
{
	if (~f[l][r][mid])
		return f[l][r][mid];
	if (l==r)
		return f[l][r][mid]=1;
	if (l==mid||mid==r)
		return f[l][r][mid]=0;
	int j,k,p,q;
	ll res=0;
	for (j=l;j<=mid-1;j++)
		for (k=mid+1;k<=r;k++)
			if (s[j][k]=='1')
				for (p=j;p<=mid-1;p++)
					for (q=mid+1;q<=k;q++)
						res+=1ll*dp(l,p,j)*dp(p+1,q-1,mid)*dp(q,r,k);
	return f[l][r][mid]=res;
}

int main()
{
	int i;
	scanf("%d",&n);
	m=(n<<1);
	for (i=1;i<=m;i++)
		scanf("%s",s[i]+1);
	memset(f,-1,sizeof(f));
	for (i=2;i<=m;i++)
		if (s[1][i]=='1')
			ans+=dp(2,m,i);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	cout<<(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]?"Bad":"Good")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm> // sort,reverse,min,lower_bound
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=a;i<(n);i++)
typedef long int li;

// print_item
template<typename T>
void print_item(T x) {cout << x;}
// 汎用
void print(auto& vec,string str="");


int main(){
  if(df) printf("*debug mode*\n");
  string s; cin >>s;
  int n=s.size();
  int temp=s.at((n-1)/2),ans=n/2;
  if(df)printf("mid:%c\n",temp);
  repa(i,n/2,n){
    if(s.at(i)==temp) ans++;
    else break;
  }
  temp=s.at(n/2);
  int ans2=n/2;
  if(df)printf("mid:%c\n",temp);
  for(int i=(n-1)/2;i>=0;i--){
    if(df) printf("compare %c\n",s.at(i));
    if(s.at(i)==temp) ans2++;
    else break;
  }
  printf("%d",min(ans,ans2));
}

void print(auto& vec,string str){
  if(str!="") cout << str << ":";
  for(auto x: vec) {print_item(x); cout << " ";}
  cout << endl;
}

/// confirm df==0 ///


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>

using namespace std;

int main(void){
  char in[1201];
  int len, j;

  j = 0;
  while(true){  
    scanf("%c", &in[j]);
    if(in[j] == '\n'){
      in[j + 1] = '\0';
      break;
    }
    j++;
  }
  
  len = strlen(in);
  for(int i = 0; i < len; i++){
    if(islower(in[i])){
      in[i] = toupper(in[i]);
    } else if(isupper(in[i])){
      in[i] = tolower(in[i]);
    }
  }
  
  printf("%s", in);
  
  return 0;
}

Measured memory_bytes: 1136
#include <stdio.h>
#include <stdlib.h>
int main(void) {
    int sp=0,stack[101];
    char temp[8];
    while (scanf(" %s",temp)!=EOF) {
        if (temp[0]=='+') {
            sp--;
            stack[sp-1]+=stack[sp];
        } else if (temp[0]=='-') {
            sp--;
            stack[sp-1]-=stack[sp];
        } else if (temp[0]=='*') {
            sp--;
            stack[sp-1]*=stack[sp];
        } else {
            stack[sp]=atoi(temp);
            sp++;
        }
    }
    printf("%d\n",stack[0]);
    return 0;
}



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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int count = 1;
  for (int i = 1; i < N; i++) {
    if (N == 1) {
      cout << '1' << endl;
      return 0;
    }
    if (S.at(i) == S.at(i-1)) {
      continue;
    } else {
      count++;
    }
  }
  
  cout << count << endl;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
int h,w; cin>>h>>w;
string s[h];
rep(i,h)cin >>s[i];
//入力
int A[] = {1,1,1,0,0,-1,-1,-1};
int B[] = {1,0,-1,1,-1,1,0,-1};//回りまわす配列

rep(i,h){
    rep(j,w){
        if(s[i][j] == '#') continue;//爆弾は無視
        int count = 0; 
        rep(a,8){
            if(i+A[a] == -1||i+A[a] == h|| j+B[a] == -1||j+B[a]==w) continue;//グラフより外は無視
           if(s[i+A[a]][j+B[a]] == '#') count++;//爆弾の数数える
            
        }//8マス周りをまわる
        s[i][j] = '0' + count;//爆弾の数を入れる

    }
}//全部のマスを調べる

rep(i,h){
    cout<<s[i]<<endl;
}

    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    int n,a,b;
    cin >> n >> a >> b;

    if(a+b <= n){
        cout << min(a,b) << " " << "0" << endl;
    }else{
        cout << min(a,b) << " " << abs(n-a-b) << endl;
    }





    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int P;
    string S;
    cin >> S;
    int N = S.size();
    P = 2019;
    int sum = 0;
    map<int,ll> mp;
    mp[0] = 1;
    vec<int> pow10(N+1,1);
    for(int i=1;i<=N;i++) pow10[i] = pow10[i-1]*10%P;
    ll ans = 0;
    if(P!=2 && P!=5){
        for(int i=N-1;i>=0;i--){
            int a = S[i]-'0';
            sum += pow10[N-1-i]*a%P;
            sum %= P;
            ans += mp[sum];
            mp[sum]++;
        }
    }else if(P==2){
        for(int i=N-1;i>=0;i--){
            int a = S[i]-'0';
            if(a%2==0) ans += i+1;
        }
    }else{
        for(int i=N-1;i>=0;i--){
            int a = S[i]-'0';
            if(a%5==0) ans += i+1;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 4288
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;

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

   cout<<(N-(H-1))*(N-(W-1))<<endl;
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main(){
	int n,b,f,r,v,a[4][3][10]={0};
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>b>>f>>r>>v;
		a[b-1][f-1][r-1]=v+a[b-1][f-1][r-1];
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++){
				cout<<" "<<a[i][j][k];
			}
			cout<<endl;
		}
		if(i!=3)cout<<"####################"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	int N = s.size();
	int L = (N - 1) / 2, R = N / 2;
	char c = s[L];
	for (; 0 <= L && R < N; L--, R++) {
		if (s[L] != c || s[R] != c) {
			break;
		}
	}

	cout << R << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
    int N,M; cin>>N>>M;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin>>A[i];
    }
    vector<pair<int,int>> change(M);
    int b,c;
    for (int i = 0; i < M; ++i) {
        cin>>b>>c;
        change[i]={c,b};
    }

    sort(A.begin(),A.end());

    sort(change.rbegin(),change.rend());
    int iter=0;
    for (int i = 0; i < M; ++i) {
        bool cont=true;
        for (int j = 0; j < change[i].second; ++j) {
            if(A[iter]<change[i].first){
                A[iter]=change[i].first;
                iter++;
            }else{
                cont=false;
                break;
            }
        }
        if(!cont) break;
    }

    ll ans=0ll;
    for (int i = 0; i < N; ++i) {
        ans+=(ll)A[i];
    }

    cout<<ans<<endl;

    return 0;
}



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

int main()
{
    string S, pat = "KIHBR";
    int acap[] = { 1, 0, 0, 1, 1, 1 };
    int cnt = 0, acnt = 0;
    bool flag = true;
    cin >> S;
    for ( int i = 0; i < S.size(); i++ ) {
        if ( S[i] == 'A' ) {
            acnt++;
        } else if ( cnt < 5 && S[i] == pat[cnt] ) {
            if ( acnt > acap[cnt] ) flag = false;
            else acnt = 0;
            cnt++;
        } else {
            flag = false;
        }
    }
    if ( flag && cnt >= 5 && acnt <= acap[cnt] ) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return ( 0 );
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) cin >> a.at(i) >> b.at(i) >> c.at(i);
  
  vector<vector<int>> dp(n, vector<int>(3));
  dp.at(0).at(0) = a.at(0);
  dp.at(0).at(1) = b.at(0);
  dp.at(0).at(2) = c.at(0);
  for (int i = 1; i < n; i++) {
    dp.at(i).at(0) = max(dp.at(i - 1).at(1), dp.at(i - 1).at(2)) + a.at(i);
    dp.at(i).at(1) = max(dp.at(i - 1).at(2), dp.at(i - 1).at(0)) + b.at(i);
    dp.at(i).at(2) = max(dp.at(i - 1).at(0), dp.at(i - 1).at(1)) + c.at(i);
  }
  
  cout << max({dp.at(n - 1).at(0), dp.at(n - 1).at(1), dp.at(n - 1).at(2)}) << '\n';
}

Measured memory_bytes: 6912
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    ll prev;
    bool same = true;
    rep(i,N) {
        cin >> A.at(i);
        if (i == 0) prev = A[0];
        else if (prev != A[i]) {
            same = false;
        }
        prev = A[i];
    }
    if (same) {
        cout << A[0] << endl;
        return 0;
    }
    ll a = A[0];
    ll b = A[1];
    set<ll> div;
    for (int i = 1; i < (int)sqrt(max(a,b)) + 1; i++) {
        if (a % i == 0) {div.insert(i); if (a / i != i) div.insert(a/i);}
        if (b % i == 0) {div.insert(i); if (b / i != i) div.insert(b/i);}
    }
    set<ll> res; 
    for (auto x : div) {
        int cnt = 0;
        rep(i, N) if (A[i] % x == 0)  cnt++;
        if (cnt > N - 2) res.insert(x);
    }
    cout << *rbegin(res) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n,m,h[100010],ma[100010];
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>h[i];
ma[i]=0;
}
for(int i=0;i<m;i++){
int a,b;
cin>>a>>b;
ma[a]=max(ma[a],h[b]);
ma[b]=max(ma[b],h[a]);
}
int ans=0;
for(int i=1;i<=n;i++){
ans+=h[i]>ma[i];
}
cout<<ans<<endl;
}

Measured memory_bytes: 4404
n, k = map(int, input().split())
people = [0] * n
for i in range(k):
    m = int(input())
    lst = list(map(int, input().split()))
    for m in range(m):
        people[lst[m] - 1] += 1

ans = [1 for i in range(n) if people[i] == 0]
print(sum(ans))


Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 240000;
constexpr LL mod = 1000000007;
int c[maxn], p[maxn], f[maxn];
int main(){
	int n, m = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i += 1) scanf("%d", c + i);
	for(int i = 1; i <= n; i += 1) if(c[i] != c[i - 1]) c[m += 1] = c[i];
	f[0] = 1;
	for(int i = 1; i <= m; i += 1) f[i] = p[c[i]] = (p[c[i]] + f[i - 1]) % mod;
	printf("%d", f[m]);
}

Measured memory_bytes: 2560
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    X=int(input())
    ans=0
    for i in range(2,1000):
        for j in range(1,1000):
            if j**i<=X:
                ans=max(ans,j**i)
            else:
                break

    print(ans)


resolve()

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

int main(){
   int N, M;
   int sum = 0;

   cin >> N >> M;
   vector<int> score(N);

   for (int i=0; i<N; i++){
      cin >> score.at(i);
   }

   sort(score.begin(), score.end());
   reverse(score.begin(), score.end());
  
   //for (int i=0; i<N; i++)
   //  cout << score.at(i) << " ";
   sum = accumulate(score.begin(), score.end(), 0);

   if (score.at(M-1) >= sum/(4.0*M))
      cout << "Yes" << endl;
   else
      cout << "No" << endl;
}



Measured memory_bytes: 256
inlist = input().split()
a = int(inlist[0])
b = int(inlist[1])

ans = []
for i in range(0,a):
	if (i==0):
		ans.append(b)
	else:
		if not (a-i < -1000000):
			ans.append(b-i)
		if not (a+i > 1000000):
			ans.append(b+i)
ans.sort()
string= ''
for i,a in enumerate(ans):
	string += str(a)
	if not (i==len(ans)-1):
		string += ' '

print(string)


Measured memory_bytes: 3064
s = input().split()[0]

pat_1_list = []
pat_2_list = []

for i in range(len(s)):
    if i % 2 == 0:
        pat_1_list.append('0')
        pat_2_list.append('1')
    else:
        pat_1_list.append('1')
        pat_2_list.append('0')

change_count_list = []

for pat_list in [pat_1_list, pat_2_list]:
    # print('pat_list: {}'.format(pat_list))
    change_count = 0
    for pat_char, s_char in zip(pat_list, s):
        if pat_char != s_char:
            change_count += 1
    change_count_list.append(change_count)

# print(change_count_list)
ans = min(change_count_list)

print(ans)

Measured memory_bytes: 4820
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define*/
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( i = a; i < b ; i++)
#define REP(i, n) for ( i = 0; i < n ; i++)
#define DER(i, n) for ( i = n; n ; i--)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1e9 + 7;

/* alias */
typedef long long ll;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

/* main */
int i, j, k;

int main() {
	int n, r = 0;
	char a[101], b[101], c[101];
	scanf("%d %s %s %s", &n, a, b, c);
	REP(i, n) {
		if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i])r += 2;
		else if (!(a[i] == b[i] && b[i] == c[i]))r++;
	}
	printf("%d", r);
	return 0;
}

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

#define int long long

int cnt[2019];

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

	string s;
	cin >> s;
	cnt[0] = 1;
	int p = 1, now = 0, ans = 0;
	for(int i=s.size()-1; i>=0; --i){
		now = (now + (s[i] - '0') * p) % 2019;
		ans += cnt[now];
		++cnt[now];
		p = ((p << 3) + (p << 1)) %2019;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3720
n = int(input())
for i in range(1, n + 1):
  if i % 3 == 0:
    print(" {}".format(i), end = "")
  else:
    x = i
    while x:
      if x % 10 == 3:
        print(" {}".format(i), end = "")
        break
      x //= 10
print()


Measured memory_bytes: 5872
/*input
2
100 1 1
1 100
*/
#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;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
ll arr[maxn],arr2[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
    cin>>n;
    REP(i,n+1) cin>>arr[i];
    REP(i,n){
        cin>>arr2[i];
    }
    arr2[n]=0;
    ll ans=0;
    for(int i=n;i>=1;i--){
        if(arr[i]>=arr2[i]){
            
            arr[i]-=arr2[i];
            ans+=arr2[i];
            arr2[i]=0;
            ans+=min(arr[i],arr2[i-1]);
            arr2[i-1]-=min(arr[i],arr2[i-1]);

        }
        else{
            ans+=arr[i];
        }
    }
    ans+=min(arr2[0],arr[0]);
    cout<<ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL << 60;
ll dp[100010];

int main(){

  int n;cin>>n;
  int k;cin>>k;
  int h[n+10];rep(i,0,n)cin>>h[i];

  rep(i,0,n)dp[i]=INF;
  dp[0]=0;
  rep(i,0,n){
    for(int next=i+1;next<=min((ll)n-1,i+k);next++){
      chmin(dp[next],dp[i]+abs(h[next]-h[i]));
    }
  }

  out(dp[n-1]);

  return 0;
}


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

int main(){
  int n;
  cin >>n;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  int cnt = 0;
  rep(i,n){
    if(a[i]==cnt+1) cnt++;
  }
  if(cnt==0) cout << -1 << endl;
  else cout << n-cnt << endl;
  return 0;
}

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

int main(){
  int A, B, C;
  
  cin >> A >> B >> C;
  
  int tmp;
  tmp = A;
  A = B;
  B = tmp;
  
  tmp = A;
  A = C;
  C = tmp;
  
  cout << A << " " << B << " " << C << endl;
}

Measured memory_bytes: 256
/* -> Written by <-
   -----------
  |K_A_Z_A_M_A|
  |___________|
  |    _    |
  |   (^_^)   |
  |  /( | )\  |
  |____|_|____|
    H O A N G
*/

#define Task ""
#define F first
#define S second
#define push_back pb
#define bit(x, i) (x >> i) & 1
#define inf 1e9 + 7
#define INF 1e18 + 7
#define all(x) x.begin(), x.end()

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <string>
#include <sstream>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;

const int MOD = 998244353;
const double eps = 1e-6;
const int maxn = 1e6 + 5;

string s = "ACL";

void Solve()
{
    int k;
    cin >> k;
    for (int i = 1; i <= k; i ++)
        cout << s;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    if(fopen(Task".inp", "r"))
    {
        freopen(Task".inp","r",stdin);
        freopen(Task".out","w",stdout);
    }
    int test_case = 1;
//    cin >> test_case;
    while (test_case --)
        Solve();
    return 0;
}


Measured memory_bytes: 3636
from bisect import bisect_right
n = int(input())
A = [-int(input()) for _ in range(n)]

B = []
v = 0
for a in A:
  b = bisect_right(B,a)  
  if v == b:    
    B.append(a)
    v+=1    
  else:
    B[b] = a    
    
print(len(B))    

Measured memory_bytes: 7968
#include<bits/stdc++.h>
using namespace std;
#define ff(i,n) for(i=0;i<n;i++)
#define ll long long int
#define pb push_back
#define mp make_pair
ll bg=998244353;
void updateBIT(ll BITree[], ll n, ll index, ll val) 
{ 
    index = index + 1; 
    while (index <= n) 
    { 
        BITree[index] += val; 
        index += index & (-index); 
    } 
} 
ll *constructBITree(ll arr[], ll n) 
{ 
    ll *BITree = new ll[n+1]; 
    for (ll i=1; i<=n; i++) 
        BITree[i] = 0; 
    for (ll i=0; i<n; i++) 
        updateBIT(BITree, n, i, arr[i]); 
    return BITree; 
} 
ll getSum(ll BITree[], ll index)  
{
	ll sum =0;
    index = index + 1; 
    while (index>0) 
    { 
        sum += BITree[index]; 
        index -= index & (-index); 
    } 
    return sum; 
} 
void update(ll BITree[], ll l, ll r, ll n, ll val) 
{ 
    updateBIT(BITree, n, l, val); 
    updateBIT(BITree, n, r+1, -val); 
} 
ll gcd(ll n1, ll n2) {
    if (n2 != 0)
        return gcd(n2, n1 % n2);
    else
        return n1;
}
ll pp(string str) 
{ 
    ll l = 0; 
    ll h = str.length() - 1; 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            return 0; 
        } 
    } 
	return 1; 
}
int main()
{
    ll t;
    t=1;
    while(t--)
    {
    	ll i,j,n,q;
    	string f,a,b;
    	cin>>f;
    	n=f.length();
    	ll s=(n-1)/2-1,ss=(n+3)/2-1;
    	for(i=0;i<=s;i++)
    	   a.pb(f[i]);
    	for(i=ss;i<n;i++)
		   b.pb(f[i]);
		if(pp(f)==1 && pp(a)==1 && pp(b)==1)
		    cout<<"Yes";
		else
		    cout<<"No";	      
    }
    return 0;
}

Measured memory_bytes: 256
X = int(input())
A = 0
f = 1
while f:
  a = A ** 5
  B = 0
  while f:
    b = B ** 5
    if a <= X:
      if a + b == X:
        print(str(A)+" "+str(-B))
        f = 0
      elif a + b > X:
        break
    if a > X:
      if a - b == X:
        print(str(A)+" "+str(B))
        f = 0
      elif a - b < X:
        break
    B += 1
  A += 1

Measured memory_bytes: 9188
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)

int main() {
  for(int N, M; cin >> N >> M, (N || M); ) {
    int C[M]; REP(i, M) scanf("%d", &C[i]);
    int dp[2][256] = {};

    const int inf = 987654321;
    REP(i, 256) dp[0][i] = inf;
    dp[0][128] = 0;
    for(int n = 1; n <= N; n++) {
      int x; scanf("%d", &x);
      int cur = n & 1;
      int prev = 1 - cur;
      REP(i, 256) dp[cur][i] = inf;
      REP(i, 256) {
        REP(m, M) {
          int j = i + C[m];
          if( j < 0 ) j = 0;
          if( j > 255 ) j = 255;
          dp[cur][j] = min(dp[cur][j], dp[prev][i] + (x - j) * (x - j));
        }
      }
    }
    int best = inf;
    REP(i, 256) best = min(best, dp[N & 1][i] );
    cout << best << endl;
  }
  return 0;
}

Measured memory_bytes: 908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    int N,M;
    cin >> N >> M;
    vector<pair<ll,ll>> pair(N);
    
    for(int i = 0;i < N;i++){
        cin >> pair[i].first >> pair[i].second;
    }
    sort(pair.begin(),pair.end());
    
    ll cnt = 0;
    ll cost = 0;
    
    for(int i = 0;i < N;i++){
        if(cnt + pair[i].second < M){
            cnt += pair[i].second;
            cost += pair[i].second*pair[i].first;
        }else{
            ll remain = M-cnt;
            cost += remain * pair[i].first;
            break;
        }
    }
    
    cout << cost << endl;
}



Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x, y, b, p;
		for (int i = 0; i < n; i++) {
			x = sc.nextInt();
			y = sc.nextInt();
			b = sc.nextInt();
			p = sc.nextInt();
			if (b >= 5 && p >= 2) {
				System.out.println((int) ((x * b + y * p) * 0.8));
			} else {
				System.out.println(min(((int) ((x * max(5, b) + y * max(2, p)) * 0.8)), (x * b + y * p)));
			}
		}

		sc.close();
	}

	static int max(int a, int b) {
		if (a > b) {
			return a;
		} else {
			return b;
		}
	}

	static int min(int a, int b) {
		if (a < b) {
			return a;
		} else {
			return b;
		}
	}
}

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

int main(){
  string t;
  cin >> t;
  
  int t_len = (int)t.length(), t_int[t_len];
  for(int i=0; i<t_len; i++){
    t_int[i] = (int)t[i] - (int)'0';
  }
  
  int ans[2];
  for(int i=0; i<2; i++){
    ans[i]=0;
    for(int j=0; j<t_len; j++){
      ans[i] += ((i+j) % 2)^t_int[j];
    }
  }
  cout << min(ans[0],ans[1]);
}

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

using namespace std;

int id, PQR[3];
string s;

int NOT(int a) { return 2 - a; }
int AND(int a, int b) { return min(a, b); }
int OR(int a, int b) { return max(a, b); }

int formula() {
	if (isdigit(s[id]))	return s[id++] - '0';
	if (isalpha(s[id])) return PQR[s[id++] - 'P'];
	if (s[id] == '-') {
		id++;
		return NOT(formula());
	}
	if (s[id] == '(') {
		id++;
		int res, tmp = formula();
		if (s[id++] == '*') res = AND(tmp, formula());
		else res = OR(tmp, formula());
		id++;
		return res;
	}
}

int main() {
	while (cin >> s, s != ".") {
		int ans = 0;
		for (PQR[0] = 0; PQR[0] < 3; ++PQR[0])
			for (PQR[1] = 0; PQR[1] < 3; ++PQR[1])
				for (PQR[2] = 0; PQR[2] < 3; ++PQR[2], id = 0)
					if (formula() == 2) ans++;
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3116
import sys

a, b, c, k = map(int, input().split())

sums = 0

if (k <= a):
    print(k)
    sys.exit()
else:
    sums += a
    k -= a

if (k <= b):
    print(sums)
    sys.exit()
else:
    k -= b

sums += -1 * k
print(sums)


Measured memory_bytes: 61864
#include <math.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

#define ipair pair<int,int>
#define rep(I,N) for(int I=0; I<N; I++)
#define rrep(I,N) for(int I=N; I>=0; I--)
#define repj(i,j,n) for(int i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

int main() {
  char s[11];
  cin >> s;
  int N = strlen(s);
  long res = 0;

  rep(i, 1 << (N-1)) {
    long sm = 0;
    long a = s[0] - '0';
    rep(j, N-1) {
      if (i & (1 << j)) {
        sm += a;
        a = 0;
      }
      a = a * 10 + (s[j+1] - '0');
    }
    sm += a;
    res += sm;
  }

  printf("%ld\n", res);
  return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <math.h>
#include <deque>
#include <stack>

using namespace std;

typedef long long ll;

int main(void){
    ll n;
    cin >> n;
    vector<ll> h(n);
    for(ll i = 0;i < n;i++){
        cin >> h[i];
    }
    ll r,l;
    ll last = h[0];
    l = 0;
    for(r = 1;r < n;r++){
        if(last == h[r]){
            continue;
        }else{
            if(h[r] > last){
                last = h[r];
                l = r;
            }else{
                while(l < r){
                    h[l]--;
                    l++;
                }
                last = h[r];
            }
        }
    }
    last = h[0];
    for(ll i = 1;i < n;i++){
        if(h[i] >= last){
            last = h[i];
            continue;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
using namespace std;

#define ll long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

int main() {
	ifstream fin("Text.txt");
	ll i, j, q;
	ll n, m, k,t;
	ll a, b, c, d;
	ll x, y, z;
	ll one = 1,zero=0;
	ll ans;

	map<ll, ll>mp;
	cin >> n;
	forn(i, n) {
		cin >> a;
		mp[a]++;
	}
	cin >> m;
	forn(i, m) {
		cin >> a;
		mp[a]--;
		if (mp[a] < 0) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

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



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

    int n, m;
    cin >> n >> m;
    vector< int > tab(m);
    for (int& i : tab)
        cin >> i;
    for (int i = 1; i < tab.size(); ++i)
        if (tab[i] & 1)
        {
            swap(tab[0], tab[i]);
            break;
        }

    for (int i = 1; i < tab.size() - 1; ++i)
        if (tab[i] & 1)
        {
            swap(tab[tab.size() - 1], tab[i]);
            break;
        }

    for (int i = 1; i < tab.size() - 1; ++i)
        if (tab[i] & 1)
            return cout << "Impossible" << '\n', 0;

    vector< int > ans;

    if (tab.size() == 1)
    {
        if (tab[0] > 1)
            ans.push_back(tab[0] - 1);
        ans.push_back(1);
    }
    else
    {

        ans.push_back(tab[0] + 1);

        for (int i = 1; i < tab.size() - 1; ++i)
            ans.push_back(tab[i]);

        if (tab.back() > 1)
            ans.push_back(tab.back() - 1);
    }

    for (int v : tab)
        cout << v << ' ';
    cout << '\n';
    cout << ans.size() << '\n';
    for (int v : ans)
        cout << v << ' ';
    cout << '\n';
}

Measured memory_bytes: 256
// Aizu Vol0 0059: Intersection of Rectangles
// 2017.7.30

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

char *gets(char *);

#define MAX 500
char buf[MAX + 5], *p;

int GetInt(void)
{
	int minus = 0, len = 0, n = 0;

	while (isspace(*p)) p++;
	if (*p == '-') p++, minus = 1;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	if (*p == '.') p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0'), len++;
#define MAGIC 5
	while (len < MAGIC) n = 10 * n, len++;
	if (minus) n = -n;
	//	printf("%10d\n", n);
	return n;
}

int InOn(int x1, int y1, int x2, int y2, int x, int y)
{
	if ((x1 <= x && x <= x2) && (y1 <= y && y <= y2)) return 1;
	return 0;
}

int main()
{
	int ax1, ay1, ax2, ay2;
	int bx1, by1, bx2, by2;
	int t;

	while (gets(p = buf) != NULL) {
		ax1 = GetInt(), ay1 = GetInt();
		ax2 = GetInt(), ay2 = GetInt();
		bx1 = GetInt(), by1 = GetInt();
		bx2 = GetInt(), by2 = GetInt();

		if (ax1 > ax2) t = ax1, ax1 = ax2, ax2 = t;
		if (ay1 > ay2) t = ay1, ay1 = ay2, ay2 = t;
		if (bx1 > bx2) t = bx1, bx1 = bx2, bx2 = t;
		if (by1 > by2) t = by1, by1 = by2, by2 = t;

		if (InOn(ax1, ay1, ax2, ay2, bx1, by1)) goto YES;
		if (InOn(ax1, ay1, ax2, ay2, bx2, by1)) goto YES;
		if (InOn(ax1, ay1, ax2, ay2, bx2, by2)) goto YES;
		if (InOn(ax1, ay1, ax2, ay2, bx1, by2)) goto YES;

		if (InOn(bx1, by1, bx2, by2, ax1, ay1)) goto YES;
		if (InOn(bx1, by1, bx2, by2, ax2, ay1)) goto YES;
		if (InOn(bx1, by1, bx2, by2, ax2, ay2)) goto YES;
		if (InOn(bx1, by1, bx2, by2, ax1, ay2)) goto YES;

		if (bx1 <= ax1 && ax1 <= bx2 &&
			bx1 <= ax2 && ax2 <= bx2 &&
			ay1 <= by1 && ay2 >= by2) goto YES;

		if (ax1 <= bx1 && bx1 <= ax2 &&
			ax1 <= bx2 && bx2 <= ax2 &&
			by1 <= ay1 && by2 >= ay2) goto YES;

		puts("NO");
		continue;
	YES:	puts("YES");
	}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
        using namespace std;
        #define ll long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 1000000007
        #define inf 2e18

        int main() {

        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
            
        ll h,n;
        cin>>h>>n;
        vector<ll> v(n);
        ll sum=0;
        for(ll i=0;i<n;i++){cin>>v[i]; sum+=v[i]; }
        if(h>sum)
            cout<<"No";
        else
            cout<<"Yes";


        return 0;
        }

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

int main() {
  int n, k;
  cin >> n >> k;
  int l[n];
  rep(i, n) cin >> l[i];

  sort(l, l+n, greater<int>());
  ll sum = 0;
  rep(i, k) sum += l[i];

  cout << sum << endl;

  return 0;
}


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

int j,y;
vector<string> ans;

// back
void rec(int a,int b,string str){
	if(a == 0 && b == 0){
		ans.push_back(str);
		return;
	}
	if(str != "" && ((a <= 3 && b >= 5) || ((a >= 5 && b <= 3)))){
		return;
	}
	if(b > 0){
		rec(a,b-1,"B" + str);
	}
	if (a > 0){
		rec(a-1,b,"A" + str);
	}
	return;
}

int main(){
	ans = vector<string>();
	cin >> j >> y;

	rec(j,y,"");
	sort(ans.begin(),ans.end());

	for(int i = 0; i < ans.size(); i++){
		cout << ans[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 93193111451418101
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll ketawa(ll n) {
  ll cnt = 0;
  while (n) {
    cnt += n % 10;
    n /= 10;
  }
  return cnt;
}

int main() {
  ll n;
  cin >> n;
  ll mini = INF;
  for (ll i = 1; i < n; i++) {
    mini = min(mini, ketawa(i) + ketawa(n - i));
  }
  cout << mini << endl;
}


Measured memory_bytes: 256
/*
[abc099] B - Stone Monument
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int a, b;

ll solve() {
    ll n = b - a;
    return n * (n + 1) / 2 - b;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; ++i)

const int MOD = 1e9+7;
int N, X, Y, Z;
ll dp[42][1ll<<17];

ll pow(ll n, ll k) {
    ll r = 1;
    while (k) {
        if (k&1) r = r*n%MOD;
        k >>= 1;
        n = n*n%MOD;
    }
    return r;
}

int main() {
    cin >> N >> X >> Y >> Z;
    ll checkval = 1;
    checkval <<= X;
    checkval += 1;
    checkval <<= Y;
    checkval += 1;
    checkval <<= (Z-1);
    ll M = (1ll << (X+Y+Z))-1;

    dp[0][0] = 1;
    REP (i, N) {
        REP (m, M) {
            REP (k, 10) {
                ll x = ((((m<<1)+1) << k)) & M;
                if ((x&checkval) != checkval)
                    (dp[i+1][x] += dp[i][m]) %= MOD;
            }
        }
    }

    ll ans = pow(10, N);
    REP (m, M) ans = (ans + MOD - dp[N][m]) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 42240
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  __int128_t ans = 1;
  vector<long long> a(n);
  bool zero = false;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      zero = true;
    }
  }
  if (zero) {
    cout << 0 << '\n';
    return 0;
  }
  for (auto& x : a) {
    ans *= (__int128_t) x;
    if (ans > (__int128_t) 1e18) {
      cout << -1 << '\n';
      return 0;
    }
  }
  cout << (long long) ans << '\n';
  return 0;
}

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

int main(){
		 ll a,b,c,k;
		 cin>>a>>b>>c>>k;
		 ll sum=0;
		  if(a+b+c<k)
		   cout<<"0";
		   else
		   {
		   	
		  if(k>=a && k>0)
		  {
		  	sum+=a*1;
		  	k=k-a;
		  	a=0;
		  }
		   else if(a!=0 && k<a && k>0)
		   {
		   	sum+=k*1;
		   	k=k-a;
		   }
		   if(k>=b && k>0)
		   {
		   	k=k-b;
		   	b=0;
		   }
		   else if(b!=0 && k>0 && k<b)
		   {
		   	k=k-b;
		   }
		   if(k>=c && k>0)
		   {
		   	sum+=c*(-1);
		   	k=k-c;
		   	c=0;
		   }
		   else if(k<c && k>0 && c!=0)
		   {
		   	sum+=k*(-1);
		   	k=0;
		   }
	}
	 cout<<sum;
}

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

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int pop_count(int bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    bitset<(1<<20)> dp;
    for(int i=0; i<(1<<N); i++){
        int s = 0;
        for(int k=0; k<N; k++) if(nth_bit(i, k)) s += A[k];
        if(s == K) dp[i] = 1;
    }
    for(int k=0; k<N; k++) for(int i=0; i<(1<<N); i++) if(nth_bit(i, k)) dp[i] = dp[i] | dp[i-(1<<k)];
    int ans = N;
    for(int i=0; i<(1<<N); i++) if(!dp[i]) ans = min(ans, N - pop_count(i));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

int main(){
   ll K,T;cin>>K>>T;
   VI A(T);
   rep(i,T)cin>>A[i];
   if(T==1){
      cout<<A[0]-1<<endl;
      return 0;
   }
   sort(rALL(A));
   ll sum=0;
   for(int i=1;i<T;i++){
      sum+=A[i];
   }
   cout<<c_max(A[0]-sum-1,0)<<endl;
}

Measured memory_bytes: 3600
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let _: usize = scan(tokens);
    let s: String = scan(tokens);
    let mut prev = '_';
    let mut cnt = 0;
    for ch in s.chars() {
        if ch != prev {
            cnt += 1;
            prev = ch;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
s=list(input())
n=len(s)-1
ans=0

for i in range(2**n):# iでビット列を生成
    equ=s[0]
    for j in range(n):# jでポインタを操作
        if (i>>j)&1:# 下1桁のビットが立っているか判定
            equ+='+'+s[j+1]
        else:
            equ+=s[j+1]
    ans+=eval(equ)
print(ans)

Measured memory_bytes: 3060