akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

const int INF = 1000000000;

int main()
{
    int n;
    cin >> n;
    int x[102];
    for(int i = 0; i < n; i++) cin >> x[i];
    int ans = INF;
    for(int i = 0; i <= 100; i++){
        int s = 0;
        for(int j = 0; j < n; j++) s += (i - x[j]) * (i - x[j]);
        ans = min(ans, s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	ll A,B;
	cin >> A >> B;
	
	if(A == B){
		if(A == 0) cout << "Zero" << endl;
		if(A > 0) cout << "Positive" << endl;
		if(A < 0) cout << "Negative" << endl;
		return 0;
	}
	
	if(InRange(0LL, A, B + 1L)){
		cout << "Zero" << endl;
		return 0;
	}
	
	if(A > 0){
		cout << "Positive" << endl;
		return 0;
	}
	
	cout << ((B - A) % 2 == 1 ? "Positive" : "Negative") << endl;
	
	
	
    return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) {cin>>a.at(i);}

  int l = 0;
  int ans = 0;

  while (l < n)
  {
    int x, y;
    for (int i = l; i < n; i++)
    {
      x = i+1;
      if (i+1 == n || a.at(i+1) < a.at(i) )
      {
        break;
      }
    }
    
    for (int i = l; i < n; i++)
    {
      y = i+1;
      if(i+1 == n || a.at(i+1) > a.at(i)){
        break;
      }
    }

    ans++;
    l = max(x, y);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
using namespace std;


int main(void) {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int cnt = 0;
    for(int i = 0; i <= N / R; i++) {
        for(int j = 0; j <= (N-i*R)/G; j++) {
            int b = N - R * i - G * j;
            if(b >= 0 && b % B == 0) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 100100100100100;


int main() {
	string S;
	cin >> S;
	ll size = S.size();
	for (int i = 0; i < size; i++) cout << "x";
	cout << endl;
}

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define out(v) cout<<v<<"\n"

const int MAX_N = 1e5+1;

int parent[MAX_N];
int root(int x) {
  if (parent[x] == x)
    return x;
  return parent[x] = root(parent[x]);
}
void unite(int x, int y) {
  if (root(x) == root(y))
    return;
  x = root(x);
  y = root(y);
  parent[x] = y;
  return;
}
bool same(int x, int y) {
  return root(x) == root(y);
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  rep(i, MAX_N)
    parent[i] = i;

  rep(i, M) {
    int x, y, z;
    cin >> x >> y >> z;
    --x; --y;
    unite(x, y);
  }
  int ans = 0;
  rep(i, N) {
    if (root(i) == i)
      ++ans;
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll MOD=1000000007;
int main(){
    int N;cin>>N;
    vector<ll>A(N);
    rep(i,N){
        cin>>A[i];
    }
    ll ans=1;
    if(N>1){
        rep(i,N/2){
            ans=(ans*2)%MOD;
        }
    }
    sort(A.begin(),A.end());
    vector<ll>B(N);
    if(N%2==0){
        rep(i,N){
            if((i+1)%2==0){
                B[i]=B[i-1];
            }
            else{
                B[i]=i+1;
            }
        }
    }
    else{
        B[0]=0;
        if(N>1){
            B[1]=2;
            for(int i=2;i<N;i++){
                if(i%2==1){
                    B[i]=2+B[i-1];
                }
                else{
                    B[i]=B[i-1];
                }
            }
        }
    }
    if(A==B){
        cout<<ans<<endl;
    }
    else{
        cout<<0<<endl;
    }
}

Measured memory_bytes: 1792
import math
def minkowskiDistance(p, x, y):
    distance, sum = 0, 0
    for i, j in zip(x, y):
        sum += math.fabs(i- j) ** p
    distance = math.pow(sum, 1 / p)
    return distance
def chebyshevDistance(x, y):
    distance = []
    for i, j in zip(x, y):
        distance.append(math.fabs(i - j))
    return max(distance)

n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

print(minkowskiDistance(1, x, y))
print(minkowskiDistance(2, x, y))
print(minkowskiDistance(3, x, y))
print((chebyshevDistance(x, y)))



Measured memory_bytes: 5716
#include<bits/stdc++.h>
using namespace std;
set<int> s1,s2;
//set<int>:: iterator it;
int main(){
  int n,a,b;
  s1.insert(2);
  s1.insert(4);
    s1.insert(5);
    s1.insert(7);
    s1.insert(9);
    s2.insert(0);
  s2.insert(1);
    s2.insert(6);
    s2.insert(8);
  cin>>n;
  a=n%10;
  if(s1.find(a)!=s1.end())
    cout<<"hon"<<endl;
  else if(s2.find(a)!=s2.end())
    cout<<"pon"<<endl;
  else
    cout<<"bon"<<endl;
  
    //s3.insert(3);
  
}

Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;

if(0<=a&&a<=100&&0<=b&&b<=100&&0<=c&&c<=100){
  if(a<b&&b<c)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
}

return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 300005
#define MOD 1000003
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int main()
{
    long long X,K,D;
    scanf("%lld %lld %lld",&X,&K,&D);
    if(X<0) X=-X;
    long long Y=X/D,Z=X%D;
    if(Y>K)
    {
        printf("%lld",X-D*K);
    }
    else if(Y%2==K%2)
    {
        printf("%lld",Z);
    }
    else
    {
        printf("%lld",D-Z);
    }
    return 0;
}


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

int find(int K){
  	int L;
  	int temp = 10;
  	int count = 0;
    if(K % 2  == 0 || K % 5 == 0)
      return -1;
  	if(K % 7)
      L = 9 * K;
  	else
      L = 9 * K / 7;
	while(1){
      	temp = temp % L;
      	if(temp == 1){
          count++;
          return count;
        }
      	temp *= 10;
      	count++;
    }
}
int main(){
	int K;
  	int L;
  	long temp;
  	int count;
  	cin >> K;
  	count = find(K);

  	cout << count << endl;
	return 0;
}

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

using namespace std;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vl a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	ll num = 0;
	ll res1 = 0;
	for (int i = 0; i < n; i++) {
		num += a[i];
		if ((i+1) % 2 == 1) {
			if (num <= 0) {
				res1 += 1 - num;
				num = 1;
			}
		} else {
			if (num >= 0) {
				res1 += num + 1;
				num = -1;
			}
		}
	}
	num = 0;

	ll res2 = 0;
	for (int i = 0; i < n; i++) {
		num += a[i];

		if ((i+1) % 2 == 0) {
			if (num <= 0) {
				res2 += 1 - num;
				num = 1;
			}
		} else {
			if (num >= 0) {
				res2 += num + 1;
				num = -1;
			}
		}
	}

	cout << min(res1, res2) << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  int temp;
  cin >> temp;
  if(temp >= 30){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3608
#include <cstdio>

int fibo(int n, int *dp) {
    if (n == 0 || n == 1) return 1;
    if (0 < dp[n]) return dp[n];
    return dp[n] = fibo(n-1, dp) + fibo(n-2, dp);
}

int
main ()
{
    int n;
    int dp[50];
    for (int i=0; i<50; i++) dp[i] = -1;
    scanf("%d", &n);
    printf("%d\n", fibo(n, dp));
    return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll x, y, c, a, b, m;std::cin >> a >> b >> m;
  vll A(a), B(b);
  re(i, a) std::cin >> A[i];
  re(i, b) std::cin >> B[i];
  ll ans = 1000000000000000000;
  re(i, m){
    std::cin >> x >> y >> c;
    x--, y--;
    ans = min(ans, A[x]+B[y]-c);
  }
  sort(all(A));
  sort(all(B));

  std::cout << min(ans, A[0]+B[0]) << '\n';
  return 0;
}


Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

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




int main(){
  ll a,b; cin >> a >> b; string s; cin >> s;
  bool flag = true;
  
  for(ll i=0; i < s.size(); i++){
    if(i == a and s[i] != '-') flag = false;
    else if(i != a and s[i] == '-') flag = false;
  }
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
}

Measured memory_bytes: 3592
//
// Created by raghavendras1 on 5/27/2018.
//
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main() {
    vector<int> v;
    int n; cin >> n; string s; cin >> s;
    set<char> left, right;
    int ans = 0;
    for(int pos = 1; pos <= n; pos++) {
        for(char c: s.substr(0, pos)) {
            left.insert(c);
        }
        for(char c : s.substr(pos)) {
            right.insert(c);
        }
        int res = 0;
        for(char c: left) {
            if(right.count(c)) {
                res++;
            }
        }
        left.clear(); right.clear();
        ans = max(ans, res);
    }
    cout << ans;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	long rep(long n){
		if(n == 0){
			return 1;
		}else{
			return rep(n-1)*n;
		}
	}
	void run(){
		int n = sc.nextInt();
		System.out.println(rep(n));
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
		
	}
}

Measured memory_bytes: 12000
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)

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


n = ns()
n = list(map(int,n[::-1])) + [0]

ans = 0

for i in range(len(n)):
    a = n[i]
    if a <= 4:
        ans += a
    elif a >= 6:
        ans += 10-a
        n[i+1] += 1
    else:
        if n[i+1] <= 4:
            ans += a
        else:
            ans += a
            n[i+1] += 1

print(ans)

Measured memory_bytes: 19744
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

#define f first 
#define s second 
#define mp make_pair
#define pb push_back

typedef long long ll;

const int mod=1e9+7;
const int INF=INT_MAX;



int main(){
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    string s;
    cin >> s;
    int cnt_ooo=0,cnt_xx=0;
    for(int i=a;i<=c-1;i++){
        if(i<n-1&&s[i]=='#'&&s[i+1]=='#'){
            cnt_xx++;
        }
    }
    for(int i=b;i<=d-1;i++){
        if(i<n-1&&s[i]=='#'&&s[i+1]=='#'){
            cnt_xx++;
        }
    }
    for(int i=b-1;i<=d-1;i++){
        if(i<n-2&&s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
            cnt_ooo++;
        }
    }
    if(c<d&&cnt_xx==0){
        cout << "Yes" << endl;
    }else if(c>d&&cnt_xx==0&&cnt_ooo>0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

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


    if(a>=13)
        cout<<b<<endl;
    else if(a>=6)
        cout<<b/2<<endl;
    else
        cout<<0<<endl;

    return 0; 
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const lli mod=1e9+7;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define printli(n) printf("%lld\n",n)
#define all(vi) (vi.begin(),vi.end())
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}

int main(){
    int n;
    si(n);
    int ct=0;
    
    while(n){
        ct++;
        n/=2;
    }
    
    cout<<pow(2,ct-1)<<endl;
	return 0;
}

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

int main() {
  int count = 0;
  
  string s;
  cin >> s;
  
  for(int i = 0; i < s.size(); i++) {
    if(s.at(i) == '1') {
      count++;
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
    long i, j, N;
    cin >> N;
    long dp[N];
    for(i=0; i<=N; i++){
        dp[i] = i; 
    }
    for(i=1; i<=N; i++){
        for(j=1; j<=i; j*=6){
            dp[i] = min(dp[i], dp[i-j]+1);
        }
        for(j=1; j<=i; j*=9){
            dp[i] = min(dp[i], dp[i-j]+1);
        }
    }
    cout << dp[N] <<'\n';
    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll Tn;
char T[202020];
deque<ll> dqe;

ll i, j, k;
ll ans;

int main(){
    scanf("%s", T);
    Tn = strlen(T);
    ll a = 0, b = 0, c = 0;

    fornum(i,0,Tn){
        if(T[i]=='1'){
            if(i%2==0)
                ++a;
            else
                ++b;
        }
    }
    j = 1;
    string s;
    fornum(i,0,Tn){
        if(T[i]=='1'){
            if(j==1){
                --a;
                ++c;
            }else{
                --b;
            }
            j ^= 1;
            s += '1';
        }else{
            if(j==0){
                s += '0';
                j = 1;
            }else{
                ans += c + a;
                swap(a, b);
            }
        }
    }
    //printf("%lld,%lld,%lld\n", a, b, c);
    if(c==0){
        printf("0\n");
        return 0;
    }
    i = s.size();
    while(i>0){
        --i;
        if(s[i]=='1'){
            if(i%2==0){
                ++a;
                --c;
            }else{
                ++b;
            }
        }else{
            ans += a + c;
            swap(a, b);
        }
    }
    c = a + b;
    while(c>0){
        ans += (c + 1) / 2;
        --c;
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 4080
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

int a[123456];
int main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int i,j;
    rep(i,n+10){
    	a[i]=0;
    }
    int val,gg;
    rep(i,k){
    	cin>>val;
    	rep(j,val){
    		cin>>gg;
    		a[gg]=1;
    	}
    }
    int sumi=0;
    rep(i,n+2){
    	sumi+=a[i];
    }
    cout<<n-sumi<<endl;
    return 0;   
}


Measured memory_bytes: 3664
def check(H, W, S):
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if S[y][x] == '#':
                if len([1 for i in range(y-1, y+2) if S[i][x] == '#'] + [1 for j in range(x-1, x+2) if S[y][j] == '#']) < 3:
                    return False
    return True

if __name__ == '__main__':
    H, W = list(map(int, input().strip().split(' ')))
    S = [['.' for _ in range(W+2)]] + [list('.' + input() + '.') for _ in range(H)] + [['.' for _ in range(W+2)]]

    if check(H, W, S):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int main()
{
	int n, k, m;
	while (scanf("%d%d%d", &n, &k, &m), n)
	{
		vector<int> v(n);
		for (int i = 0; i < n; ++i)
			v[i] = i + 1;
		int i = --m;
		while (v.size() > 1)
		{
			v.erase(v.begin() + i);
			i = (i + k - 1) % v.size();
		}
		printf("%d\n", v[0]);
	}
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  vector<int> a(5);
  int mini=200,ans=0;
  r(i,5){
    cin>>a.at(i);
    if(a.at(i)%10<mini&&a.at(i)%10!=0){mini=a.at(i)%10;ans=i;}
  }

  int sum=0;
  r(i,5){
    if(i==ans)continue;
    else{
      if(a.at(i)%10==0)sum+=a.at(i);
      else sum+=(a.at(i)/10+1)*10;
  }
  }
  sum+=a.at(ans);
  cout<<sum<<endl;
return 0;}


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

using namespace std;

#define MAX 120
#define INF 1e9

int H, W;
char field[MAX][MAX];
const int dx[] = {-1,0,0,1};
const int dy[] = {0,-1,1,0};

bool inField(int y, int x){
  return 0 <= y && y < H && 0 <= x && x < W;
}

bool check(int y, int x){
  if(y == 0 || y == H-1) return true;
  if(x == 0 || x == W-1) return true;
  return false;
}

void bfs(int y, int x){
  int ans = INF;
  int cost[MAX][MAX];
  fill(cost[0], cost[MAX], INF);
  queue<int> nowx, nowy;
  nowx.push(x); nowy.push(y); 
  cost[y][x] = 0;

  while(!nowx.empty()){
    int xx = nowx.front(); nowx.pop();
    int yy = nowy.front(); nowy.pop();
    int cnt = cost[yy][xx];

    for(int i = 0 ; i < 4 ; i++){
      int nx = xx + dx[i];
      int ny = yy + dy[i];

      if(!inField(ny, nx)) continue;
      if(check(ny, nx)){
        if(field[yy][xx] != '#' && field[ny][nx] == '#'){
          cost[ny][nx] = min(cost[ny][nx], cnt+1);
        }else{
          cost[ny][nx] = min(cost[ny][nx], cnt);
        }
        continue;
      }
      int ncnt = cnt;
      if(field[yy][xx] != '#' && field[ny][nx] == '#') ncnt++;
      if(ncnt < cost[ny][nx]){
        cost[ny][nx] = ncnt;
        nowx.push(nx); nowy.push(ny);
      }
    }
  }
  for(int i = 0 ; i < H ; i++){
    ans = min(ans, cost[i][0]);
    ans = min(ans, cost[i][W-1]);
  }
  for(int i = 0 ; i < W ; i++){
    ans = min(ans, cost[0][i]);
    ans = min(ans, cost[H-1][i]);
  }

  cout << ans << endl;
}

int main(){
  int sx, sy;
  while(cin >> W >> H, (W | H)){
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
        cin >> field[i][j];
        if(field[i][j] == '&'){
          sx = j; sy = i;
        }
      }
    }  
    bfs(sy, sx);
  }

  return 0;
}

Measured memory_bytes: 1288
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long n,a,b;
int main()
{
	scanf("%lld %lld %lld",&n,&a,&b);
	if((a-b)&1)printf("%lld",min((n-a+n-b+1)/2,(a+b-1)/2));
	else printf("%lld",abs(a-b)/2);
	return 0;
}


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

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const double PI = acos(-1.0);
const int MOD = pow(10, 9) + 7;

#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()

ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

inline void finish() {
	cout << -1 << endl;
	exit(0);
}

template <typename T>
inline void debug(vector<T> v) {
	cout << "[";
	for (size_t i = 0; i < v.size() - 1; ++i) {
		cout << v[i] << ", ";
	}
	cout << v[v.size() - 1] << "]" << endl;
}

class Point {
public:
	double x, y;
	Point(double x, double y) {
		this->x = x;
		this->y = y;
	}
	Point() {
		x = 0.0;
		y = 0.0;
	}
};

class Mod {
	static inline ll Add(ll a, ll b) {
		return (a + b) % MOD;
	}

	static inline ll Sub(ll a, ll b) {
		ll ans = (a - b) % MOD;
		return (ans < 0) ? (ans + MOD) : ans;
	}

	static inline ll Mul(ll a, ll b) {
		return (a * b) % MOD;
	}
	
	static inline ll Div(ll a, ll b) {
		return (a % MOD) * modinv(b, MOD) % MOD;
	}
};

inline double distance(Point p1, Point p2) {
	return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}

inline int Kaijo(int n) {
	int ans = 1;
	for (int i = 2; i <= n; ++i) {
		ans *= i;
	}
	return ans;
}

void Main();
inline void DebugMain() {
	while (true) {
		Main();
	}
}

int main() {
	bool debug = false;
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	if (debug) {
		cout << "\x1b[41m" << "Debug Mode このまま提出すると死" << endl;
	}
	(debug) ? DebugMain() : Main();
	return 0;
}

inline void Main(){
	string S;
	cin >> S;

	if (S == "SUN") {
		cout << 7;
		return;
	}
	if (S == "MON") {
		cout << 6;
		return;
	}
	if (S == "TUE") {
		cout << 5;
		return;
	}
	if (S == "WED") {
		cout << 4;
		return;
	}
	if (S == "THU") {
		cout << 3;
		return;
	}
	if (S == "FRI") {
		cout << 2;
		return;
	}
	if (S == "SAT") {
		cout << 1;
		return;
	}
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
        string str; cin >> str;
        int q; cin >> q;
        for (int i = 0; i < q; i++){
                int a,b;
                string oreder; cin >> oreder;
                if (oreder == "print"){
                        cin >> a >> b;
                        cout << str.substr(a,b-a+1) << endl;
                }else if(oreder == "reverse"){
                        cin >> a >> b;
                        char tmp;     
                        for ( int j = 0; j <= (b-a)/2; j++){
                                tmp = str[a+j];
                                str[a+j] = str[b-j];
                                str[b-j] = tmp;
                        }       
                }else if(oreder == "replace"){
                        string rp_str;
                        cin >> a >> b >> rp_str;
                        for ( int j = a; j <= b ; j++){
                                str[j] = rp_str[j-a];  
                        }       
                }       
        }       
return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

const ll mod = 998244353;

const ll INF = 1e15;

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};

int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> ms(n + 1, 1);
	rep(i, n) {
		ms[i + 1] = ms[i] * (m-1);
		ms[i + 1] %= mod;
	}
	Factorial f(n);
	ll sum = 0;
	for (int i = 0; i <= k; i++) {
		auto c = f.cmb(n - 1, i);
		c *= m;
		ll u = n - i - 1;
		c %= mod;
		c *= ms[u];
		c %= mod;
		sum += c;
		sum %= mod;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 7916
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<bitset>
#include<cmath>
#include<sstream>
#include<map>
using namespace std;
typedef pair<int,int> pr;
int unit[30]={};
int find(int x){
  if(unit[x]==x)
    return x;
  else
    return unit[x]=find(unit[x]);
  
}
void unions(int f,int s){
  int leaderF=find(f),leaderS=find(s);
  if(leaderF<leaderS)
    unit[leaderS]=leaderF;
  else
    unit[leaderF]=leaderS;
  return;
}


int main(){
  int n;
  
  while(cin >> n && n!=0){
  int arrive[30]={};
  int left[30]={};
  for(int i=0;i<30;i++)
    unit[i]=i;
  string ss;
  vector<pr > nodes; 
  for(int i=0;i<n;i++){
    cin >> ss ;
    int f=ss[0]-'a',s=ss[ss.size()-1]-'a';
    left[f]++;
    arrive[s]++;
    unions(f,s);
  }
  bool ans=true;
  int leader=-1;
    for(int i=0;i<30;i++){
      if(left[i]!=arrive[i])
	ans=false;
      else if(left[i]==0) continue;
      else if(leader==-1) leader=i;
      else if(leader!=find(i))
	ans=false;
    }
    if(ans)
      cout << "OK" << endl;
    else
      cout << "NG" << endl;
  }
  return 0; 
}

Measured memory_bytes: 1200
S = input()

l = (len(S)-1)//2
r = len(S)//2
m = S[l]
while l >= 0:
    if S[l] != m or S[r] != m:
        break
    l -= 1
    r += 1
if l < 0:
    print(len(S))
else:
    print(r)



Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <numeric>
#include <cmath>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <cstdint>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

vector<string> solve(const vector<int>& p, const vector<int>& y) {
    vector<int> indices(p.size());
    iota(indices.begin(), indices.end(), 0);
    sort(indices.begin(), indices.end(), [&y](int lhs, int rhs) {
        return y[lhs] < y[rhs];
    });


    vector<int> count(100001, 0);
    vector<string> ids(p.size());
    for (auto index : indices) {
        auto pp = p[index];
        auto yy = y[index];
        ++count[pp];

        ostringstream oss;
        oss << setw(6) << setfill('0') << pp;
        oss << setw(6) << setfill('0') << count[pp];
        ids[index] = oss.str();
    }

    return ids;
}

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

    vector<int> p(m);
    vector<int> y(m);

    for (int i = 0; i < m; ++i) {
        cin >> p[i] >> y[i];
    }

    const auto& ans = solve(p, y);
    for (const auto& id : ans) {
        cout << id << endl;
    }

    return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a < b){
    for(int i = 0; i < b; i++){
      cout << a;
    }
  }else{
    for(int i = 0; i < a; i++){
      cout << b;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
const string YES = "Yes";
const string NO = "No";
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> A(Q);
    std::vector<int> ans(N,K);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&A[i]);
        ans[A[i]-1]++;
    }
    for (size_t i = 0; i < N; i++) {
      cout << (ans[i] - Q > 0 ? "Yes":"No") << endl;
    }
}


Measured memory_bytes: 1792
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

import numpy as np

V_e = np.array(V)
C_e = np.array(C)

F_e = V_e - C_e

F = F_e.tolist()
G = []
for i in range(N):
    if F[i] >= 0:
        G.append(F[i])
print(sum(G))

Measured memory_bytes: 18892
#include <stdio.h>

int main() {

  long long i,j,k,n,m,l,a,b,c;
  long long A[101][101] = {0};
  long long B[101][101] = {0};
  long long C[101][101] = {0};

  scanf("%lld %lld %lld",&n,&m,&l);

  for(j=0; j<n; j++) {
    for(i=0; i<m; i++) {

      scanf("%lld", &a);
      A[j][i] = a;
    
    }
  }

  for(j=0; j<m; j++){
    for(i=0;i<l;i++){
      scanf("%lld",&b);
      B[j][i] = b;
    }
  }

    for(i=0 ;i<n; i++) {
      for(j=0; j<l; j++){
	C[i][j] = 0;
	for(k=0;k<m; k++) {
	   C[i][j] += A[i][k]*B[k][j];  
	   /*    printf("%d ",C[i][j]); */
	}
	/* printf("\n"); */
      }
    }


     for(i=0; i<n; i++) {
      for(j=0; j<l; j++) {
	printf("%lld",C[i][j]);
	if(j !=l-1) {
	  printf(" ");
	}
      }
      printf("\n");
      } 

    return 0;

  }



Measured memory_bytes: 2056
from functools import reduce

mod = 10 ** 9 + 7

N, K, *A = map(int, open(0).read().split())

A.sort(reverse=True)

ans = 1
l, r = 0, N - 1
if K % 2 == 1:
    ans = A[0]
    l = 1

if ans < 0:
    print(reduce(lambda a, b: a * b % mod, A[:K], 1))
    quit()


for i in range(K // 2):
    L = A[l] * A[l + 1]
    R = A[r] * A[r - 1]
    if L >= R:
        ans *= L
        l += 2
    else:
        ans *= R
        r -= 2
    ans %= mod

print(ans)

Measured memory_bytes: 32084
#include<stdio.h>

int main(void){
	
	int price;
	int i;
	int sum;
	while (1){
		scanf("%d", &sum);
		if (sum == 0)break;
		for (i = 0; i < 9; i++){

			scanf("%d", &price);

			sum -= price;

		}
		printf("%d\n", sum);
	}

	return 0;
}

Measured memory_bytes: 600
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAX_N 12

ll N, M, X;
ll value=INF;
int C[MAX_N], A[MAX_N][MAX_N];
int skill[MAX_N];

void solve(){
    cin >> N >> M >> X;
    REP(i, N){
        cin >> C[i];
        REP(j, M){
            cin >> A[i][j];
        }
    }


    //ビット生成
    for(ll bit=0; bit<(1<<N); bit++){
        REP(i, M) skill[i] = 0;
        //ビットに基づいて理解度を計算
        ll money = 0;
        for(ll i=0; i<N; i++){
            //ビットオン
            if(bit & (1<<i)){
                for(ll j=0; j<M; j++){
                    skill[j] += A[i][j];
                }
                money += C[i];
            }
        }

        //このビット列の習熟度を確認
        bool can=true;
        REP(i, M){
            if(skill[i] < X) can=false;
        }
        if(can){
            value = min(value, money);
        }
    }
}

int main() {
    solve();
    if(value == INF) cout << -1 << endl;
    else cout << value << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, N=16;

int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN];
int cnt[MAXN];
int dp[1<<N], xo[1<<N];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	for (int i=1; i<n; i++){
		cin>>u>>v>>x;
		A[u]^=x;
		A[v]^=x;
	}
	for (int i=1; i<=n; i++) cnt[A[i]]++;
	ans=cnt[0];
	cnt[0]=0;
	for (int i=1; i<N; i++) ans+=cnt[i]/2, cnt[i]%=2;
	for (int mask=1; mask<(1<<N); mask++){
		int bit=__builtin_ctz(mask);
		xo[mask]=xo[mask^(1<<bit)]^bit;
	}
	for (int mask=1; mask<(1<<N); mask++)
		for (int submask=mask; submask; submask=(submask-1)&mask)
			if (!xo[submask]) dp[mask]=max(dp[mask], dp[mask^submask] + 1);
	
	int mask=0;
	for (int i=0; i<N; i++) if (cnt[i]) mask|=(1<<i);
	ans+=dp[mask];
	cout<<n-ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 1280
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(S: str):
    u = int(S[:2])
    d = int(S[2:])
    
    if 0 < u <= 12 and 0 < d <= 12:
        print('AMBIGUOUS')
    
    elif 0 < d <= 12:
        print('YYMM')

    elif 0 < u <= 12:
        print('MMYY')
        
    else:
        print('NA')
        
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    solve(S)

if __name__ == '__main__':
    main()


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(a > 0 && c > 0) {
        c -= b;
        a -= d;
    }
    if(c <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a.at(i);
    for(int i = 0; i < n; i++) {
        if (a.at(i) % 2 != 0) continue;
        if (a.at(i) % 3 != 0 && a.at(i) % 5 != 0) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 25000 + 5 ; 
const int M = 400 + 5 ; 
const int P = 1e9 + 7 ; 
int n, m, K, A[N], w[N], Ans, f[N][M], g[N][M], sum[N][M], nxt[N][M] ; 
int fpow( int x, int k ) {
	int ans = 1, base = x % P ; 
	while( k ) {
		if( k & 1 ) ans = 1ll * ans * base % P ; 
		base = 1ll * base * base % P, k >>= 1 ; 
	} return ans % P ; 
}
void inc( int &x, int y ) {
	( ( x += y ) >= P ) && ( x -= P ) ; 
}
void solve1() {
	sum[1][1] = f[1][1] = K ; if( m == 1 ) nxt[1][1] = g[1][1] = K ; 
	for( re int i = 2; i <= n; ++ i )
		for( re int j = K - 1; j >= 1; -- j ) { 
			f[i][j] = f[i - 1][j - 1] * ( K - j + 1 ) % P, inc( f[i][j], sum[i - 1][j] ),
			g[i][j] = g[i - 1][j - 1] * ( K - j + 1 ) % P, inc( g[i][j], nxt[i - 1][j] ) ;
			if( j >= m ) inc( g[i][j], f[i][j] ) ; 
			sum[i][j] = ( sum[i][j + 1] + f[i][j] ) % P, nxt[i][j] = ( nxt[i][j + 1] + g[i][j] ) % P ; 
		}  
	int A = 1, S = nxt[n][1] ;  
	for( re int i = 0; i < m; ++ i ) A = A * ( K - i ) % P ; 
	S = S * fpow( A, P - 2 ) % P ;
	printf("%I64d\n", ( Ans - S + P ) % P ) ;
}
void solve2() {
	int R = m + 1 ; memset( w, 0, sizeof(w) ) ;
	for( re int i = m; i >= 1; -- i ) {
		++ w[A[i]] ; 
		while( w[A[i]] > 1 ) -- R, -- w[A[R]] ; 
	}
	int l = R - 1 ; f[0][l] = 1 ; 
	for( re int j = K - 1; j >= 1; -- j ) sum[0][j] = sum[0][j + 1] + f[0][j] ;
	rep( i, 1, n )
		for( re int j = K - 1; j >= 1; -- j )
			f[i][j] = f[i - 1][j - 1] * ( K - j + 1 ) % P, inc( f[i][j], sum[i - 1][j] ),
			sum[i][j] = ( sum[i][j + 1] + f[i][j] ) % P ;
	int L = 0 ; memset( w, 0, sizeof(w) ) ;
	
	for( re int i = 1; i <= m; ++ i ) {
		++ w[A[i]] ; 
		while( w[A[i]] > 1 ) ++ L, -- w[A[L]] ; 
	}
	l = m - L, g[0][l] = 1 ; 
	for( re int j = K - 1; j >= 1; -- j ) nxt[0][j] = nxt[0][j + 1] + g[0][j] ;
	rep( i, 1, n )
		for( re int j = K - 1; j >= 1; -- j )
			g[i][j] = g[i - 1][j - 1] * ( K - j + 1 ) % P, inc( g[i][j], nxt[i - 1][j] ),
			nxt[i][j] = ( nxt[i][j + 1] + g[i][j] ) % P ;
	int S = 0 ;
	for( re int i = 0; i <= n - m; ++ i ) {
		S = ( S + sum[i][1] * nxt[n - m - i][1] ) % P ; 
	}
	printf("%I64d\n", ( Ans - S + P ) % P ) ;
}
bool check() {
	memset( w, 0, sizeof(w) ) ;
	int l = 0 ;
	for( re int i = 1; i <= m; ++ i ) {
		++ w[A[i]] ;
		while( w[A[i]] > 1 ) ++ l, -- w[A[l]] ; 
		if( i - l >= K ) return 1 ;  
	} return 0 ; 
}
signed main()
{
	n = gi(), K = gi(), m = gi() ;
	int flag = 1 ; 
	rep( i, 1, m ) {
		A[i] = gi(), ++ w[A[i]] ; 
		if( w[A[i]] > 1 ) flag = 0 ; 
	}
	Ans = fpow( K, n - m ) * ( n - m + 1 ) % P ;
	if( check() ) printf("%I64d\n", Ans ) ;
	else if( flag ) solve1() ; 
	else solve2() ; 
	return 0 ;
}

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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll n{0};
	ll d{0};
	cin>>n>>d;

	ll count{0};
	while(n--){
		ll x{0};
		ll y{0};
		cin>>x>>y;
		ll temp=(x*x)+(y*y);
		double dis=sqrt(temp);
		if(dis<=d)
			count++;
	}

	cout<<count<<endl;
	
	return 0;
}



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

const int N = 100005;

int n, a[N], b[N];
long long sum;

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

	cin >> n;
	bool ok = true;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i] >> b[i];
		ok &= (a[i] == b[i]);
		sum += a[i];
	}
	if (ok) return printf("0\n"), 0;

	int mn = 1e9;
	for (int i = 1; i <= n; ++i) {
		if (a[i] > b[i]) mn = min(mn, b[i]);
	}

	cout << sum - mn << endl;
}

Measured memory_bytes: 384
X = int(input())
if X == 2:
    print(X)
else:
    flag = True
    while flag == True :
        flag = False
        if X%2 == 0:
            X += 1
            flag = True
        else:
            for i in range(3,X,2):
                if X%i == 0:
                    flag = True
                    X += 1
                    break
                else:
                    flag = False

    
    print(X)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <ios>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
  int N,X;
  cin >> N >> X;

  vector<int>num(N,0);
  for(int i=0;i<N;i++){
    cin >> num[i];
  }

  vector<int>point(N + 1 , 0);
  point[0] = 0;
  for(int i=1;i<=N;i++){
    point[i] = point[i - 1] + num[i - 1];
  }

  /*for(int i=0;i<N + 1;i++){
    cout << point[i] << endl;

  }
  */

  int ans = 0;
  for(int i=0;i<N + 1;i++){
    if(point[i] <= X)
      ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef set<ii> sii;
typedef set<int> si;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;

const int INF = 1000000010;
const ll MOD = 1000000007;

int main() {FIN
    
    int i, r = 0, p = 0, w = 0;
    string s;
    cin >> s;
    
    for (i = 0; i < (int)s.size(); i++) {
		if (s[i] == 'g') {
			if (r > p) {
				p++;
				w++;
			} else
				r++;
		} else {
			if (r > p)
				p++;
			else {
				r++;
				w--;
			}
		}
	}
	
	cout << w << "\n";
	
    return 0;
}


Measured memory_bytes: 3692
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	A, B := nextInt(), nextInt()

	switch {
	case A >= 13: fmt.Println(B)
	case A <= 5: fmt.Println(0)
	default: fmt.Println(B/2)
	}
}


Measured memory_bytes: 640
import java.util.*;

class Main {

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

        int n = sc.nextInt();

        if(n == 3|| n == 5|| n == 7){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }

    }

}

Measured memory_bytes: 21716