akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main (){
  int i;
  int n,mx=0,j,c=0,mn=101,mnr=1000000000;
  cin>>n;
  vector<int>x(n);
  for(i=0;i<n;i++){
    cin>>x[i];
    mx = max(mx,x[i]);
    mn = min(mn,x[i]);
  }
  for(i=mn;i<=mx;i++){
    c=0;
    for(j=0;j<n;j++){
      c+=(x[j]-i)*(x[j]-i);
    }
    mnr=min(mnr,c);
  }
  cout<<mnr<<endl;
  return 0;
}


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

int main(void) {
	int64_t A, B, K;
	int64_t takahasi, aoki;
	int64_t asumikana;
	if (scanf("%" SCNd64 "%" SCNd64 "%" SCNd64, &A, &B, &K) != 3) return 1;
	takahasi = A <= K ? 0 : A - K;
	asumikana = A < K ? K - A : 0;
	aoki = asumikana <= B ? B - asumikana : 0;
	printf("%" PRId64 " %" PRId64 "\n", takahasi, aoki);
	return 0;
}


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

int main(){
    string s;
    cin >> s;
    string h="abcdefghijklmnopqrstuvwxyz";
    for(int i=0;i<26;i++){
        if(0<=s.find(h[i])&&s.find(h[i])<s.length()) continue;
        cout << h[i] << endl;
        return 0;
    }
    cout << "None" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int mp[26];
int nx[10];

int main(){
  int n;
  string s;
  cin>>n>>s;
  {
    int x = (n+1)/2;
    REP(i,x) mp[s[2*i]-'a']++;
  }
  REP(i,26) nx[mp[i]]++;
  int res = 0;
  int plop = 0;
  REPR(i,10){
    if(i==1 && nx[i]>0){
      res += nx[i]*2-1;
    }else if(nx[i]==1){
      if(res)++plop;
      res += 3;
    }else if(nx[i]>1){
      if(res)++plop;
      res += 2*nx[i]+3;
    }
  }
  res += plop;
  cout<<res<<endl;
  return 0;
}

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

int h[100000];
int L[100000],R[100000];

int main(){
	int n;scanf("%d",&n);
	rep(i,n)scanf("%d",&h[i]);
	stack<int>st;
	rep(i,n){
		while(!st.empty()&&h[st.top()]>=h[i])st.pop();
		if(st.empty())L[i]=0;
		else L[i]=st.top()+1;
		st.push(i);
	}
	while(!st.empty())st.pop();
	for(int i=n-1;i>=0;i--){
		while(!st.empty()&&h[st.top()]>=h[i])st.pop();
		if(st.empty())R[i]=n-1;
		else R[i]=st.top()-1;
		st.push(i);
	}
	ll Max=0;
	rep(i,n){
		Max=max(Max,(R[i]-L[i]+1)*(ll)h[i]);
	}
	cout<<Max<<endl;
}


Measured memory_bytes: 4572
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll i, ll z) {
	ll sum = 1;
	for (ll j = max(z, 2LL); j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%Mod;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n;
int a[2][100];
int dp[2][100];
signed main() {
	cin >> n;
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
	dp[0][0] = a[0][0];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			if (i == 0) {
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i + 1][j]);
			}
			if (j < n - 1) {
				dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + a[i][j + 1]);
			}
		}
	}
	cout << dp[1][n - 1] << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
//In The Name Of God
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int, int>
#define pb push_back
using namespace std;
const int N = 1e5 + 5, Mod = 1e9 + 7, P = 727, Lg = 17, TOF = 1900;

int main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      int n, h, w; cin >> n >> h >> w;
      long long ans = 0;
      for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                  if(i + w - 1 <= n && j + h - 1 <= n)
                        ans++;
            }
      }
      cout << ans;
      return 0;
}



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

using namespace std;

//string findDayYear (string s){

//}

int32_t main()
{
    time_t start, end;
    time(&start);
    ios_base::sync_with_stdio(false);

    ///////////////////////////////////////////////////////
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i < n;i++)cin>>a[i];
    int b[n], c[n], mini=1000;
	b[0]=a[0];
	c[n-1]=a[n-1];
	for(int i=1;i<n;i++)b[i]=b[i-1]+a[i];
	for(int i=n-2;i>=0;i--)c[i]=c[i+1]+a[i];
	for(int i=1;i<n;i++)mini=min(mini,abs(c[i]-b[i-1]));
	cout<<mini;
    ///////////////////////////////////////////////////////

    time(&end);
    double time_taken = double(end - start); 
    //cout << "Time taken by program is : " << fixed << time_taken << setns << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List

main = do
  forM_ [1..9] $ \i -> do
    forM_ [1..9] $ \j -> do
      putStrLn $ qq i j

qq :: Int -> Int -> String
qq x y = show x ++ "x" ++ show y ++ "=" ++ show (x * y)

Measured memory_bytes: 3580
/*
ID: zhaowei10
TASK:
LANG: C++14
*/
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;

#ifdef LOCAL
#include <debug.h>
#else
#define debug(...) 0
#endif

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

#ifdef LOCAL
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
#else
#endif

  string s;
  cin >> s;
  cout << s.substr(0, 3);
}

Measured memory_bytes: 3640
import math

n,m = map(int,input().split())

if (n < 2) and (m < 2):
    tn = tm = 0
elif (n >= 2) and (m < 2):
    tn = math.factorial(n) // (math.factorial(n - 2)*2)
    tm = 0
elif (m >= 2) and (n < 2):
    tn = 0 
    tm = math.factorial(m) // (math.factorial(m - 2)*2)
else:
    tn = math.factorial(n) // (math.factorial(n - 2)*2)
    tm = math.factorial(m) // (math.factorial(m - 2)*2)

print(tn+tm)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

using namespace std;
int w[110];
int main(){
	int i,j,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> w[i];
	}
	int mn = 1000000;
	for(i=0;i<=100;i++){
		int s = 0,t = 0;
		for(j=0;j<n;j++){
			if(j<i) s+= w[j];
			else t += w[j];
		}
		mn = min(mn,(int)abs(s - t));
	}
	cout << mn << endl;
}
				

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, cnt = 0, cur = 0, m;
	cin >> n;
	while (n--) {
		cin >> m;
		if (m >= cur)
			++cnt;
		cur = max(cur, m);
	}
	cout << cnt << '\n';
}

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

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

int P[100000];
int Y[100000];

vector<int> Year[100001];

int main()
{
	int N, M;
	int order;

	cin >> N >> M;

	rep(i, M) {
		cin >> P[i] >> Y[i];
		Year[P[i]].push_back(Y[i]);
	}

	rep(i, N + 1) {
		sort(Year[i].begin(), Year[i].end());
	}

	rep(i, M) {
		printf("%06d", P[i]);
		order = lower_bound(Year[P[i]].begin(), Year[P[i]].end(), Y[i]) - Year[P[i]].begin() + 1;
		printf("%06d\n", order);
	}

	return 0;
}


Measured memory_bytes: 7808
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
# define MOD 1000000000+7
# define INF 1000000000
typedef long long ll;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }


int main() {
	int cnt;
	int ansa = 0, ansb = 0;
	string s;
	cin >> s;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '1' && i % 2 == 0) {
			ansa++;
		}
		else if (s[i] == '0' && i % 2 == 1) {
			ansa++;
		}
	
	}
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '0' && i % 2 == 0) {
			ansb++;
		}
		else if (s[i] == '1' && i % 2 == 1) {
			ansb++;
		}

	}

	cout << min(ansa, ansb) << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	private static final int MAX = 100000;
	private static int[][] map;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String string = sc.next();
		sc.close();
		String mew = string;
		while (mew.indexOf("mew") != -1 && !mew.equals("mew")) {
			mew = mew.replaceAll("mew", "");
		}
		if (!mew.equals("mew")) {
			System.out.println("Rabbit");
			return;
		}
		System.out.println("Cat");
		return;
	}

	static void WarshallFloyd() {
		// 任意の2点間の最小時間を入れる
		int n = map.length;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (map[i][j] == 0) {
					map[i][j] = MAX;
				}
			}
		}

		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (i != j) {
						map[i][j] = Math.min(map[i][j], map[i][k] + map[k][j]);
					}
				}
			}
		}
	}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = 3.141592653589;
double ans;

int main(){
  double a, b, c;
  string s, t;
  cin >> a;
  printf("%lf\n", a * 2 * PI);
}



Measured memory_bytes: 3812
"use strict";
    
const main = arg => {
    const X = parseInt(arg.split("\n")[0].split(" ")[0]);
    const Y = parseInt(arg.split("\n")[0].split(" ")[1]);
    const Z = parseInt(arg.split("\n")[0].split(" ")[2]);
    
    console.log(Math.floor((X-Z)/(Y+Z)));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
#include <time.h> 
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 100010
#define inf 1001000100
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pc pair<char ,int>
#define pi pair<int ,int>
#define pii pair <pi,pi>
using namespace std;
int arr[nax];
int brr[nax];
vector< ll > v;
int main(int argc, char const *argv[])
{
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  int n;
  sd(n);
  for(int i = 1; i <= n; i++)
    sd(arr[i]);
  ll sum = 0;
  int lo,hi;
  lo = hi = 0;
  ll def = 0;
  int c_def = 0;
  for(int i = 1; i <= n; i++)
  {
    sd(brr[i]);
    sum += arr[i] - brr[i];
    if(brr[i] > arr[i])
    {
      def += brr[i] - arr[i];
      c_def++;
    }
    else
       v.pb(arr[i] - brr[i]);
  }

  if(sum < 0)
  {
    puts("-1");
    return 0;
  }

  int siz = sz(v);
  sort(v.begin(), v.end());
  ll psum = 0;
  int change = 0;
  for(int i = siz - 1; siz >= 0; i--)
  {
      if(psum >= def)
        break;
      psum += v[i];
      change++;
  }
  printf("%d\n", change + c_def);
  return 0;
} 

Measured memory_bytes: 2040
#include <iostream>
#include <vector>
#include <boost/range/numeric.hpp>
#include <boost/range/algorithm/max_element.hpp>
#include <boost/range/irange.hpp>
#include <boost/foreach.hpp>
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i : boost::irange(0, n, 1)) {
        cin >> vec.at(i);
    }

    long sum = boost::accumulate(vec, 0);
    int max_num = *(boost::max_element(vec));
    if (max_num < sum - max_num) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define dl double long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
ll gcd(ll a, ll b) { return (b > 0) ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a*b/gcd(a, b); }
using ipair = pair<ll, ll>;

int main()
{
  ll ans=0;
  dl W, H, x, y;
  cin >> W >> H >> x >> y;
  if(W/2 == x && H/2 == y) ans=1;
  cout << W*H/2.0 << " " << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long int ll;
string S;
int main()
{
    cin >> S;
    ll len = S.size(), M = 1e9 + 7, ans = 1;
    for (long i = len - 1, d = 1; i >= 0; i--, d = d * 3 % M) {
        if (S.at(i) == '1') ans = (ans * 2 + d) % M;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3736
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static final FS sc = new FS();  // 封装输入类
    static final PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = sc.nextInt(), k = sc.nextInt();
        int[] a = new int[n];
        int max = 0;
        for (int i = 0;i < n;i++) {
            a[i] = sc.nextInt();
            max = Math.max(max, a[i]);
        }
        if(k == 0){
            pw.println(max);
            pw.flush();
            return;
        }

        int l = 1, r = max, ans = max;
        while(l <= r){
            int mid = l + (r - l) / 2;
            if(isOk(a, mid, k)){
                ans = mid;
                r = mid - 1;
            }else{
                l = mid + 1;
            }
        }
        pw.println(ans);
        pw.flush();
    }

    public static boolean isOk(int[] a, int target, int k) {
        int count = 0;
        for (int num : a) {
            if (num > target) {
                int needs = num / target;
                if (num % target == 0) {
                    needs--;
                }
                count = count + needs;
                if (count > k) {
                    return false;
                }
            }
        }
        return true;
    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while(!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch(Exception ignored) {}
            }
            return st.nextToken();
        }
        int[] nextArray(int n) {
            int[] a = new int[n];
            for(int i = 0;i < n;i++) {
                a[i] = nextInt();
            }
            return a;
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 55856
N = int(input())
A = list(map(int, input().split()))
mod = 1000000007
ans = 1
colors = [-1, -1, -1]  # red, blue, green
for i in range(N):
    flag = [False] * 3
    cnt = 0
    # print(A[i]-1)
    for j in range(len(colors)):
        if A[i]-1 == colors[j]:
            flag[j] = True
            cnt += 1
    # if cnt == 0:
    #     print(0)
    #     exit()
    for k in range(3):
        if flag[k]:
            colors[k] += 1
            break
    # print(cnt)
    ans *= cnt % mod
print(ans % mod)


Measured memory_bytes: 13964
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

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

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

  double dp[n + 1][n + 1];
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = dp[i - 1][0] * (1 - ps[i - 1]);
    for (int j = 1; j <= i; j++) {
      dp[i][j] = dp[i - 1][j - 1] * ps[i - 1] + dp[i - 1][j] * (1 - ps[i - 1]);
    }
  }

  double res = 0;
  for (int i = n / 2 + 1; i <= n; i++) { res += dp[n][i]; }
  printf("%.10f\n", res);
}



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

string bit(int n,int d){
  string ans="";
  for(int i=0;i<d;i++){
    char c='0'+n%2;
    n/=2;
    ans=c+ans;
  }
  return ans;
}

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  if(n==1){
    cout << a[0] << endl;
    return 0;
  }
  for(int i=0;i<n-2;i++){
    if(a[i]==a[i+2]){
      cout << 0 << endl;
      return 0;
    }
  }
  if(n>12&&a[0]==0){
    cout << 0 << endl;
    return 0;
  }
  else if(n>12){
    cout << 1 << endl;
    return 0;
  }
  int ans=0;
  for(int i=0;i<1<<n;i++){
    string s=bit(i,n);
    int time[n+2];
    for(int j=0;j<n;j++){
      if(s[j]=='1') time[j]=24-a[j];
      else time[j]=a[j];
    }
    time[n]=0,time[n+1]=24;
    sort(time,time+n+2);
    int count=24;
    for(int j=0;j<n+1;j++){
      count=min(count,time[j+1]-time[j]);
    }
    ans=max(ans,count);
  }
  cout << ans << endl;
}


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

int main() {
  int64_t N;
  cin >> N;
  int64_t C = 0;
  for (int64_t i=1; i<=N; i++) {
    C += (i + (N - N%i)) * ((N - N%i) / i) / 2;
    //cout << C << endl;
  }
  cout << C << endl;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

long long ans=0;
int dx[3]={3,5,7};
long long n;
long long tens[12];
int bits[3]={1,2,4};
void make_tens(){
    tens[1]=1;
    rep2(i,10)tens[i+1]=tens[i]*10;
}
//status unsolved
void bfs(long long num,int nd,int used){
    if(num>n)return;

    if(used==7)ans++;
    rep(i,3){
        bfs(num+dx[i]*tens[nd],nd+1,used|bits[i]);
    }
}

int main(){
    cin>>n;
    make_tens();
    bfs(0,1,0);
    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 256
#include <cstdio>  
#include <cmath>  
#include <string>  
#include<vector>
#include <cstring>  
#include<algorithm>
#include <cstdlib>  
#include<queue>
#include <iostream>  
#include<set>
#define pb push_back 
#define lb lower_bound 
#define lowbit(x) (x)&(-x)   
#define forup(i,a,b) for(int i=(a);i<=(b);i++)  
#define fordown(i,a,b) for(int i=(a);i>=(b);i--)  
#define maxn 1000005
#define INF 107000000 

#define mod 997
using namespace std;  
typedef long long ll;  
typedef unsigned long long ull;  
   #define int ll 
template<class T> inline  void read(T& num){   num = 0; bool f = true;char ch = getchar();   while(ch < '0' || ch > '9') { if(ch == '-') f = false;ch = getchar();}   while(ch >= '0' && ch <= '9') {num = num * 10 + ch - '0';ch = getchar();}   num = f ? num: -num;  } 
int out[100]; 
template<class T> inline
void write(T x,char ch){  if (x==0) {putchar('0'); putchar(ch); return;}  if (x<0) {putchar('-'); x=-x;} int num=0; while (x){ out[num++]=(x%10); x=x/10;} fordown(i,num-1,0) putchar(out[i]+'0'); putchar(ch); } 
/*========================================================*/
int n;
int a[maxn];
int mid;
signed main()
{  cin>>n; 
   forup(i,1,n)
    {read(a[i]); a[i]-=i;}
  sort(a+1,a+n+1);
  mid=a[n/2];
  ll sum=0; 
  forup(i,1,n) sum+=abs(mid-a[i]);	
  ll sum2=0;
  if(n/2-1>0) forup(i,1,n) sum2+=abs(a[i]-a[n/2-1]);
  ll sum3=0;
  if(n/2+1>0) forup(i,1,n) sum3+=abs(a[i]-a[n/2+1]);
  ll ans=min(sum,sum2); ans=min(ans,sum3);
  cout<<ans<<endl; 
return 0;	
 } 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int n = 20;
vector<vector<pii>> graph(n);

void bypass(int base, int remain){
    if(remain == 0){
        return;
    }
    int b = 0;
    for(int i = 0; i < n; i++){
        if( (1<<i) <= remain ){b = i;}
        else{break;}
    }
    int val = (1<<b);
    graph[0].push_back({n-1-b,base});
    bypass(base+val, remain-val);
    return;
}

int main(){
    int l;
    cin >> l;


    for(int i = 0; i < n-1; i++){
        graph[i].push_back({i+1,0});
    }
    int b = 0;
    for(int i = 0; i < n; i++){
        if( (1<<i) <= l ){b = i;}
        else{break;}
    }

    for(int i = 0; i < b; i++){
        graph[n-2-i].push_back({n-1-i,(1<<i)});
    }

    bypass((1<<b), l-(1<<b));

    int edge = 0;
    for(int i = 0; i < n; i++){
        edge += graph[i].size();
    }
    cout << n << " " << edge << endl;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < graph[i].size(); j++){
            cout << i+1 << " " << graph[i][j].first+1 << " " << graph[i][j].second << endl;
        }
    }


    return 0;

}


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

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    if all([S.count(S[i]) == 2 for i in range(len(S))]):
        print(YES)
    else:
        print(NO)
    return



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

if __name__ == '__main__':
    main()


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

typedef long long ll;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define dump(x) cerr<<#x<<"="<<x<<endl

typedef pair<int,int> P;

int N;
int ans=0;
int A[212345];
int B[212345];
int A2[212345];
int main(){
    cin>>N;
    string s;
    cin>>s;
    int i=0;
    int ans1=0,ans2=0;

    N=s.size();
    // .....######
    while(s[i]=='.'){
        i++;
    }
    //dump(i);
    for(int j=i;j<N;j++){
        if(s[j]=='#'){
            ans1++;
        }else{
            ans2++;
        }
    }
    ans=min(ans1,ans2);



    //途中まで ... の位置をきめる

    for(i=0;i<N;i++){
        if(s[i]=='.'){
            A[i]=1;
        }else{
            B[i]=1;
        }
    }
    for(i=N-1;i>=0;i--){
        if(s[i]=='.'){
            A2[i]=1;
        }
    }
    for(i=1;i<N;i++){
        A[i]+=A[i-1];
        B[i]+=B[i-1];
    }
    for(i=N-2;i>=0;i--){
        A2[i]+=A2[i+1];
    }
    
    i=0;ans1=0;ans2=0;
    for(i=0;i<N;i++){
        ans1=0;

        ans1+=B[i];
        ans1+=(A2[i+1]);

        ans=min(ans,ans1);
    }

    // #########
    i=0;ans1=0;ans2=0;
    for(i=0;i<N;i++){
        if(s[i]=='.')ans1++;
    }
    ans=min(ans,ans1);

    // .........
    i=0;ans1=0;ans2=0;
    for(i=0;i<N;i++){
        if(s[i]=='#')ans1++;
    }
    ans=min(ans,ans1);



    cout<<ans<<endl;

}

Measured memory_bytes: 2948
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

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

int main (){
	int n; cin >> n;
	int benefit = 0;
	ll maxv = -1000000005;
	vector<vector<int> > v(n),p(n);
	rep(i,n)rep(j,10){
		int a; cin>>a;
		v[i].push_back(a);
	}
	rep(i,n)rep(j,11){
		int a; cin>>a;
		p[i].push_back(a);
	}
	for (int bit = 1; bit < (1 << 10);++bit){
		
		ll sum = 0;
		rep(i,n){
			int count=0;
			rep(j,10){
				if(bit&1<<j && v[i][j])count++;
			}
			sum += p[i][count];
		}
		maxv = max(maxv,sum);
	}
	cout << maxv << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pull pair<ull, ull>
#define m_p make_pair
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll h,n;
	cin >> h >> n;
	
	ll sum=0;
	ll x;
	for(int i=0;i<n;i++){
		cin >> x;
		sum += x;
	}
	
	if(sum < h){
		cout << "No";
	}
	else{
		cout << "Yes";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long oo=1000000000000+10;

long long n;
long long kq;

int main(){
  cin>>n;kq=+oo;
  for(long long i=1;i*i<=n;i++)
    if (n%i==0)
      kq=min(kq,i+n/i-2);
  cout<<kq;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
	
	string a,b;
	cin>>a>>b;
	ll num = stoi(a+b);
	ll x = sqrtl(num);
	puts(x*x==num?"Yes":"No");


}


Measured memory_bytes: 3748
# 英小文字 c が与えられるので、 c が母音であるか判定してください。ここで、英小文字のうち母音は a、e、i、o、uの 5 つです。

c = input()
if c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u':
    print('vowel')
else:
    print('consonant')

Measured memory_bytes: 8968
#include "bits/stdc++.h"
 
#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
 
ll N, M;
vector<pair<ll, ll>> v;
map<ll, ll> mp;
ll ans;
int main() {
	cin>>N>>M;
	REP(i, 0, N){
		ll A;
		cin >> A;
		mp[A]++;
	}
	REP(i, 0, M){
		ll B, C;
		cin >> B >> C;
		mp[C] += B;
	}
	for(auto m: mp){
		v.emplace_back(m.first, m.second);
	}
	reverse(v.begin(), v.end());
	for(auto pr: v){
		if(N == 0) break;
		ll now = min(pr.second, N);
		N -= now;
		ans += now * pr.first;
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 18544
use proconio::{input, fastout};
use std::io::{self, Write};

macro_rules! chmin {
    ($base:expr, $($cmps:expr),+ $(,)*) => {{
        let cmp_min = min!($($cmps),+);
        if $base > cmp_min {
            $base = cmp_min;
            true
        } else {
            false
        }
    }};
}

macro_rules! chmax {
    ($base:expr, $($cmps:expr),+ $(,)*) => {{
        let cmp_max = max!($($cmps),+);
        if $base < cmp_max {
            $base = cmp_max;
            true
        } else {
            false
        }
    }};
}

macro_rules! min {
    ($a:expr $(,)*) => {{
        $a
    }};
    ($a:expr, $b:expr $(,)*) => {{
        std::cmp::min($a, $b)
    }};
    ($a:expr, $($rest:expr),+ $(,)*) => {{
        std::cmp::min($a, min!($($rest),+))
    }};
}

macro_rules! max {
    ($a:expr $(,)*) => {{
        $a
    }};
    ($a:expr, $b:expr $(,)*) => {{
        std::cmp::max($a, $b)
    }};
    ($a:expr, $($rest:expr),+ $(,)*) => {{
        std::cmp::max($a, max!($($rest),+))
    }};
}

#[fastout]
fn main() {
    input! {
        N: usize,
        W: usize,
        wv: [(usize, i64); N],
    }

    let mut dp = vec![vec![0i64; W+1]; N+1];

    for i in 0..N {
        for sum_w in 0..W+1 {
            let w = wv[i].0;
            let v = wv[i].1;
            if sum_w + w <= W {
                chmax!(dp[i+1][sum_w + w], dp[i][sum_w] + v);
            }
            chmax!(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    let mut ans = -1;
    for sum_w in 0..W+1 {
        chmax!(ans, dp[N][sum_w]);
    }
    println!("{}", ans);
}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    string s1, s2, s3; cin >> s1 >> s2 >> s3;

    cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int e, y;

	cin >> e >> y;

	if (e == 0){
		if (y <= 1911){
			cout << "M" << y - 1867 << endl ;
		}else if (1912 <= y && y <= 1925){
			cout << "T" << y - 1911 << endl;
		}else if (1926 <= y && y <= 1988){
			cout << "S" << y - 1925 << endl;
		}else {
			cout << "H" << y - 1988 << endl;
		}
	}
	else if (e == 1){
		cout << 1867 + y << endl;
	}
	else if (e == 2){
		cout << 1911 + y << endl;
	}
	else if (e == 3){
		cout << 1925 + y << endl;
	}
	else {
		cout << 1988 + y << endl;
	}
}

Measured memory_bytes: 3100
#include<iostream>
using namespace std;
int h,data[500000];
void fswap(int *x,int *y){
  int tmp;
  tmp=*x;
  *x=*y;
  *y=tmp;
}
void maxheap(int x){
  int left=2*x+1,right=2*x+2,largest=x;
  if(left<h&&data[left]>data[x]) largest=left;
  if(right<h&&data[right]>data[largest]) largest=right;
  if(largest!=x){
    fswap(&data[x],&data[largest]);
    maxheap(largest);
  }
}
int main(){
  cin>>h;
  for(int i=0;i<h;++i) cin>>data[i];
  for(int i=h/2;i>0;--i) maxheap(i-1);
  for(int i=0;i<h;++i) cout<<" "<<data[i];
  cout<<endl;
  return 0;
}



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

int main(){
  int a,b,hoge,foo,bar = 0,flag = 0;
  cin >> a >>b;
  foo = b;
  while (foo >= 10){
    foo /= 10;
    bar ++;
  }
  for (int i =0;i <= bar;i++){
    a = a*10;
  }
  hoge = a+b;
  for (int i = 0;i <= hoge; i++){
    if (i*i == hoge){
      flag ++;
      break;
    }
  }
  if (flag == 1){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }
}


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

int main()
{

        int N;
        cin >> N;
        map<long long, long long> m;
        for (int i = 0; i < N; ++i) {
                long long tmp;
                cin >> tmp;
                m[tmp] += 1;
        }
        long long ans = 0;
        for (auto i : m) {

                if (i.first == i.second) {

                }
                else if (i.first < i.second) {
                        ans += (i.second - i.first);
                }
                else {
                        ans += i.second;
                }

        }
        cout << ans << endl;


}


Measured memory_bytes: 6272
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<cctype>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
#define init(x) memset(x,0,sizeof(x))
int a,b;
int main()
{
	ios::sync_with_stdio(false);
	cin>>a>>b;
	if (a<=8&&b<=8) cout<<"Yay!";
	else cout<<":(";
	return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	long long k;
	cin>>n>>k;
	long long a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	int memo[50]={};
	for (int i = 0; i < 50; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (a[j]&(1LL<<i))
			{
				++memo[i];
			}
		}
	}
	long long ans=0LL;
	for (int i = 49; i >= 0; --i)
	{
		if (memo[i]>=(n+1)/2)
		{
			continue;
		}
		if ((ans+(1LL<<i))<=k)
		{
			ans+=(1LL<<i);
		}
	}
	long long s=0LL;
	for (int i = 0; i < n; ++i)
	{
		s+=(ans^a[i]);
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
ll check(vector<pair<ll, ll>> &ps, int k, ll sx, ll sy, ll ex, ll ey)
{
    ll area = abs(sx - ex) * abs(sy - ey);
    //assert(area > 0);
    if (area == 0)
        return -1;
    int cur = 0;
    for (auto p : ps)
    {
        if (sx <= p.first && p.first <= ex && sy <= p.second && p.second <= ey)
            cur++;
    }
    return (cur >= k ? area : -1);
}
int main(int argc, char const *argv[])
{
    int n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> ps(n);
    rep(i, n) cin >> ps[i].first >> ps[i].second;
    ll ans = (1ll << 62);
    rep(i1, n)
    {
        rep(i2, n)
        {
            rep(i3, n)
            {

                rep(i4, n)
                {
                    ll ret;
                    ret = check(ps, k, ps[i1].first, ps[i2].second, ps[i3].first, ps[i4].second);
                    if (ret != -1)
                    {
                        ans = min(ans, ret);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n, max=0, ans[100];
	vector<int> s;
	for(int i=0; i<100; i++)
		ans[i] = 0;
	while(cin >> n){
		if(n > 100 || n < 1) return 0;
		s.push_back(n);
	}
	sort(s.begin(), s.end());
	vector<int>::iterator it = s.begin();
	while(it != s.end()){
		ans[*it-1]++;
		it++;
	}
	for(int i=0; i<100; i++)
		if(max < ans[i]) max = ans[i];
	for(int i=0; i<100; i++)
		if(max == ans[i]) cout << i+1 << endl;
}

Measured memory_bytes: 0
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <stack>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <sstream>
#include <iomanip>
using namespace std;


#define int int64_t
#define vi vector<int>
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define all(x) (x).begin(), (x).end()
#define vii vector< vector<int> >
#define rip(dp, n, m) vector< vector<int> > dp(n, vector<int>(m,0))
#define ff first
#define ss second
#define pii pair<int64_t, int64_t>
#define miv map<int, vector<int> >
#define mp make_pair
#define pb push_back
#define prr(x) cout << (#x) <<'	' << (x) << endl
#define pr(x) cout  << (x) << endl
#define f(i,n) for(i=0;i<n;i++)
#define pqb priority_queue<int>
#define pqs priority_queue<int,vi,greater<int> >
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x) int x; cin>>x; while(x--)
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int32_t main()
{
    FIO;
    int i, j, n, m, k, l, t;
   cin >> t >> l;
   l = l*l;
   k=0;
   while(t--)
   {
       int x , y; cin >> x >> y;
       x = (x*x)+(y*y);
       if(l>=x)k++;
       
   }
//    if(n>=30) cout << "Yes";
//    else cout << "No";
cout << k;
}

Measured memory_bytes: 3664
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;
use std::iter::FromIterator;

fn main() {
    input! {
        n: u32,
        slice: [u32; n],
    }
    let s: HashSet<u32> = HashSet::from_iter(slice);
    println!("{}", s.len());
}


Measured memory_bytes: 2152
from sys import stdin
from sys import setrecursionlimit
from math import pi
setrecursionlimit(10 ** 7)

n,m = map(int,stdin.readline().rstrip().split())
a = list(map(int,stdin.readline().rstrip().split()))

if sum(a) > n:
    print(-1)
else:
    print(n-sum(a))

Measured memory_bytes: 10216
#include <iostream>
#include <algorithm>
#include "math.h"
#include "stdio.h"

using namespace std;

#define NONE -1
#define UP_SURFACE 0
#define SURFACE 1
#define RIGHT_SURFACE 2

#define IN_ROLL 7
#define IN_PITCH 8

class Dice{
public:
    int surface[6];
    
    void roleEast();
    void roleWest();
    void roleNorth();
    void roleSouth();
    void swap(int surface2[]);
    int getSurface(int num);
    bool isPitchSide(int num);
};

void Dice::swap(int* surface2){
    for(int i = 0;i < 6;++i){
        surface[i] = surface2[i];
    }
}

void Dice::roleEast(){
    int tmp[6];
    tmp[0] = surface[3];
    tmp[3] = surface[5];
    tmp[5] = surface[2];
    tmp[2] = surface[0];
    tmp[1] = surface[1];
    tmp[4] = surface[4];
    swap(tmp);
}

void Dice::roleWest(){
    int tmp[6];
    tmp[3] = surface[0];
    tmp[5] = surface[3];
    tmp[2] = surface[5];
    tmp[0] = surface[2];
    tmp[1] = surface[1];
    tmp[4] = surface[4];
    swap(tmp);
}

void Dice::roleNorth(){
    int tmp[6];
    tmp[0] = surface[1];
    tmp[1] = surface[5];
    tmp[5] = surface[4];
    tmp[4] = surface[0];
    tmp[2] = surface[2];
    tmp[3] = surface[3];
    swap(tmp);
}

void Dice::roleSouth(){
    int tmp[6];
    tmp[0] = surface[4];
    tmp[4] = surface[5];
    tmp[5] = surface[1];
    tmp[1] = surface[0];
    tmp[2] = surface[2];
    tmp[3] = surface[3];
    swap(tmp);
}

int Dice::getSurface(int num){
    for(int i = 0;i < 6;++i){
        if(surface[i] == num){
            return i + 1;
        }
    }
    return NONE;
}

bool Dice::isPitchSide(int num){
    int surface = getSurface(num);
    if(surface == 3 || surface == 4){
        return true;
    }
    return false;
}

int main(){
    Dice dice[2];
    int rollNum = 0;
    
    for(int i = 0;i < 6;++i){
        cin >> dice[0].surface[i];
    }
    for(int i = 0;i < 6;++i){
        cin >> dice[1].surface[i];
    }
    
    int upSurface = dice[0].surface[UP_SURFACE];
    int frontSurface = dice[0].surface[SURFACE];
    
    cin >> upSurface >> frontSurface;
    // frontSurfaceを合わせる
    if(dice[1].getSurface(frontSurface) == NONE || dice[1].getSurface(upSurface) == NONE){
        cout << "No" << endl;
    }
    while(frontSurface != dice[1].surface[SURFACE]){
        if(dice[1].isPitchSide(frontSurface)){
            dice[1].roleEast();
        
        }
        else {
            dice[1].roleSouth();
        }
    }
    rollNum = 0;
    // upSurfaceを合わせる
    while(upSurface != dice[1].surface[UP_SURFACE]){
        dice[1].roleEast();
    }
    
    for(int i = 0;i < 6;++i){
        if(dice[0].surface[i] != dice[1].surface[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
}




Measured memory_bytes: 3116
#include<stdio.h>
#define MAX 100000
 
typedef struct{
  int p;
  int l;
  int r;
}id;
   
id A[MAX];
int n,B[MAX];
 
   
int rec(int x,int y){
  B[x] = y;
  if(A[x].r != -1) rec(A[x].r,y);
  if(A[x].l != -1) rec(A[x].l,y + 1);
}


int main(){
  int c,d,i,j,v,l,r,n,op;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    A[i].p = A[i].l = A[i].r = -1;
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0) A[v].l=c;
      else A[l].r = c;
      l=c;
      A[c].p = v;
    }
  }
  for(i=0;i<n;i++){
    if(A[i].p == -1) r=i;
  }
 
  rec(r,0);
 
  for(i=0;i<n;i++){
    
    printf("node %d: parent = %d, depth = %d,",i,A[i].p,B[i]);
    if(A[i].p == -1) printf(" root,");
    else if(A[i].l == -1 ) printf(" leaf,");
    else printf(" internal node,");
    printf(" [");
    op=A[i].l;
    for(j=0;op!=-1;j++){
      if(j != 0) printf(", ");
      printf("%d",op);
      op = A[op].r;
    }
    printf("]\n");  
  }
 
  return 0;
}

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

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    string s;
    cin >> s;
    string ans = s[2] == s[3] && s[4] == s[5] ? "Yes" : "No";
    cout << ans;
    
}









Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;

inline ll read(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=1e5+5;
int n,m,fa[MAXN];

struct EDGE{
	int u,v;
}e[MAXN];

ll ans[MAXN],sz[MAXN];

int get_fa(int x){
	if(x==fa[x]) return x;
	return fa[x]=get_fa(fa[x]);
}

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	n=read();m=read();
	
	for(int i=1;i<=m;++i)
	{
		e[i].u=read(); e[i].v=read();
	}
	
	for(int i=1;i<=n;++i)
	{
		fa[i]=i,sz[i]=1;
	}
	ans[m]=(ll)n*(n-1)/2;
	
	for(int i=m;i>=1;--i)
	{
		int u=get_fa(e[i].u),v=get_fa(e[i].v);
		
		if(u==v)
		{
			ans[i-1]=ans[i];
		}
		else{
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u]; fa[u]=v;
		}
	}
	
	for(int i=1;i<=m;++i)
	{
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 4096
#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 forr(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 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)
int find(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}


int main(void) {
    long int N,ans=0,A,B;
    cin >> N;
    int s[N];
        rep(i,N){
       cin >> s[i];
    }

    forr(i,0,N-1){
      forr(j,i+1,N-1){
         int g = s[i]*s[j];
         ans = ans + g;
      }
    }

      
    
      cout << ans << "\n";
  

  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 A[3], ans = 0;
    rep(i, 3) cin >> A[i];
    sort(A, A + 3);
    ans += (A[2] - A[1]) + (A[1] - A[0]);
    cout << ans << endl;
    return 0;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);


int main(void)
{
    ll a,b,m,ans;
    cin>>a>>b>>m;
    vector<ll> A(a),B(b);
    rep(i,a) cin>>A[i];
    rep(i,b) cin>>B[i];

    ll minia=*min_element(all(A)),minib=*min_element(all(B));
    ans=minia+minib;
    rep(i,m){
        ll x,y,c;
        cin>>x>>y>>c;
        ans = min(ans, A[x-1]+B[y-1]-c);
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4852
#include <stdio.h>

int main(void){
	
	int i=0,j=0,a,b,c,d;
	
	while(1){
	
		scanf("%d %d",&a,&b);
		
		if(a == 0 && b == 0){break;}
		
		while(j != a){
		
			while(i != b){
				c = j % 2;
				d = i % 2;
				
				if(c == 0){
					if(d == 0){printf("#");}
					else{printf(".");}
				}
				
				else{
					if(d == 1){printf("#");}
					else{printf(".");}
				}
				
				++i;
			}
			printf("\n");
			++j;
			i = 0;
		}
		j = 0;
		printf("\n");
	}
	return 0;
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

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

int dp[55][55][110];
int v[55];

int solve(int l, int r, int k){
  if(r < l) return 0;
  if(k == 0) return 0;
  if(dp[l][r][k] != -INF) return dp[l][r][k];
  
  dp[l][r][k] = solve(l+1, r, k-1) + v[l];
  if(k >= 2) dp[l][r][k] = max(dp[l][r][k], solve(l+1, r, k-2));
  dp[l][r][k] = max(dp[l][r][k], solve(l, r-1, k-1) + v[r]);
  if(k >= 2) dp[l][r][k] = max(dp[l][r][k], solve(l, r-1, k-2));
  return dp[l][r][k];
}

int32_t main(){
  DESYNC;
  int n,k;
  cin >> n >> k;
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      for(int x=0; x <= k; x++) dp[i][j][x] = -INF;
    }
  }
  for(int i=0; i<n; i++) cin >> v[i];
  int ans = 0;
  for(int i=0; i<=k; i++) ans = max(solve(0, n-1, i), ans);
  cout << ans << endl; 
}



Measured memory_bytes: 2560