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

// #include "debug.h"
// #define debug(...) 42


using ll = long long;

set <int> v;

void go(ll x, int mask) {
   if(x  >= 1e9) return;
   if(mask == 7) v.insert(x);
   for(auto t: {3, 5, 7}) {
      int mask_ = mask | (1 << ((t - 3) / 2));
      go(x * 10LL + t, mask_);
   }
}
void pre() {
   go(0LL, 0);
}


void solve() {
   int n;
   cin >> n;
   int ans = 0;
   for(auto t: v) {
      ans += t <= n;
   }
   cout << ans << endl;
} 

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   pre();
   int testcase = 1;
   // cin >> testcase;

   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}


Measured memory_bytes: 4876
#include <bits/stdc++.h>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
const double eps=1e-6;
const int INF=0x3f3f3f3f;
const int N=1e5+5;
int a[N],cnt[N];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        mem(cnt,0);
        int ans=0,mx=-INF;
        for(int i=0; i<n; i++)
        {
            scanf("%d",&a[i]);
            if(a[i]<=100000) cnt[a[i]]++;
            else ans++;
            if(mx<a[i]&&a[i]<=100000) mx=a[i];
        }
      //  for(int i=0; i<100; i++) if(cnt[i]) printf("cnt[%d]=%d\n",i,cnt[i]);
        for(int i=mx; i>=0; i--)
            if(cnt[i]&&cnt[i]>=i) ans+=(cnt[i]-i);
            else if(cnt[i]&&cnt[i]<i) ans+=cnt[i];
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#define rep(i, s, n) for(int i = s; i < n; i++)
using namespace std;
 
int h, w;
int plus_x[4] = {1, 0, -1, 0};
int plus_y[4] = {0, -1, 0, 1};
queue<pair<int, int> > que;
char s[20][20];
int ans[20][20];
 
void bfs(int x, int y) {
	
    int ans_field[h][w];
    rep(i, 0, h) {
        rep(j, 0, w) {
            ans_field[i][j] = -1;
        }
    }
 
    que.push(make_pair(x, y));
    ans_field[x][y] = 0;
    while(que.size()) {
        pair<int, int> p;
        p = que.front();
        que.pop();
        rep(i, 0, 4) {
            x = p.first + plus_x[i];
            y = p.second + plus_y[i];
            if(x >= 0 && x < h && y >= 0 && y < w) {
                if(ans_field[x][y] == -1 && s[x][y] == '.') {
                    que.push(make_pair(x, y));
                    ans[x][y] = max(ans[x][y], ans_field[p.first][p.second]+1);
                    ans_field[x][y] = ans_field[p.first][p.second]+1;
                }
            }
        }
    }
    

    
}
 
int main() {
//	freopen("in.txt","r",stdin);
    cin >> h >> w;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> s[i][j];
            ans[i][j] = 0;
        }
    }
 
    rep(i, 0, h) {
        rep(j, 0, w) {
            if(s[i][j] == '.') {
                bfs(i, j);
            }
        }
    }
 
    int answer = 0;
    rep(i, 0, h) {
        rep(j, 0, w) {
//			cout<<"x: "<<i<<" y: "<<j<<" max: "<<ans[i][j]<<endl; 
            answer = max(answer, ans[i][j]);
        }
    }
 
    cout << answer << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


	public static void main(String[] args){

		Scanner sc =new Scanner(System.in);
 
	int	a=sc.nextInt();
	int b=sc.nextInt();

	//奇数の場合
	if(a*b%2==1){
System.out.println("Odd");
	
	}
	//偶数の場合
	else{
		System.out.println("Even");

	}
	}
}

Measured memory_bytes: 19924
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, A, B, C, D;
    cin >> N;
    A = N / 1000;
    B = (N % 1000) / 100;
    C = (N % 100) / 10;
    D = (N % 10);
    if ((A == B && B == C) || (B == C && C == D)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int N = Integer.parseInt(sc.next());
        final int K = Integer.parseInt(sc.next());
        final int P[] = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        int sum = 0;
        for (int i = 0; i < K; i++) {
            sum += P[i];
        }
        int max = sum;
        if (N > K) {
            for (int i = 0; i < N - K; i++) {
                sum = sum - P[i] + P[i + K];
                if (sum > max) {
                    max = sum;
                }
            }
        }
        double d = (max + K) / 2.0;

        System.out.println(d);
    }
}

Measured memory_bytes: 61188
#include <stdio.h>
#include <string.h>

typedef long long int lli;

lli max(lli a, lli b) {
	return a > b ? a : b;
}

lli max_value(int *weights, int *values, int n, 
		int i, int weight, 
		int max_weight, lli (*dp)[max_weight+1]) {
	if (i >= n) return 0L;

	if (dp[i][weight] != -1) return dp[i][weight];

	if (weight - weights[i] < 0) {
		dp[i][weight] = max_value(weights, values, n, i+1, weight, max_weight, dp);
		return dp[i][weight];
	}

	lli pick = (lli)values[i] + max_value(weights, values, n, i+1, weight-weights[i], max_weight, dp);
	lli no_pick = max_value(weights, values, n, i+1, weight, max_weight, dp);
	dp[i][weight] = max(pick, no_pick);
	return dp[i][weight];
}

int main() {
	int n, w, i;
	scanf("%d %d", &n, &w);
	int  weights[n], values[n];
	for (i = 0; i < n; i++) {
		scanf("%d %d", &weights[i], &values[i]);
	}
	lli dp[n][w+1];
	memset(dp, -1L, sizeof(lli) * n * (w+1));
	printf("%lld\n", max_value(weights, values, n, 0, w, w, dp));
	return 0;
}

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

using namespace std;

int main(void)
{
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    double S = W*H/2.0;
    double Sx = W / 2.0;
    double Sy = H / 2.0;
    int ans = 0;
    if(Sx == x && Sy == y){
        ans = 1;
    }
    cout << S << " " << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// D - Lunlun Number
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	int k = 0, K; cin>>K;
	queue<ll> q;
	for(int i=1; i<=9; ++i) q.push(i);
	while(q.size()){
		ll n = q.front(); q.pop();
		if(++k >= K){ cout<< n <<endl; return 0; }
		ll n10 = n*10, d = n%10;
		if(d > 0) q.push(n10 + d-1);
		q.push(n10 + d);
		if(d < 9) q.push(n10 + d+1);
	}
}

Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Integer[] input = readInput();
        System.out.println(watch(input[0]));
    }

    public static String watch(int sec) {
        int s = sec % 60;
        sec /= 60;
        int m = sec % 60;
        int h = sec / 60;
        
        StringBuilder t = new StringBuilder();
        t.append(h).append(":").append(m).append(":").append(s);
        return t.toString();
    }


    public static Integer[] readInput() {
        List<Integer> l = new ArrayList<Integer>();

        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            l.add(sc.nextInt());
        }
        return l.toArray(new Integer[l.size()]);
    }
}

Measured memory_bytes: 26368
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;

const int INF = 1000000007;

// 何回割り切れるか
int num_division(int x, int y)
{
    int n = 0;
    while (x / y != 0 && x % y == 0)
    {
        x /= y;
        n++;
    }
    return n;
}

// 素数判定
bool isPrime(int n)
{
    if (n < 2) return false;
    for (int i = 2; i * i <= n; i++)
    {
        if (n % i == 0) return false;
    }
    return true;
}

// aとbを掛けた値をmodする(a * b mod p)
int modmulti(int a, int b)
{
    int res = 0;
    int mod = a % INF;
    while (b > 0)
    {
        if ((b & 1) == 1)
        {
            res += mod;
            if (res > INF)
            {
                res -= INF;
            }
        }
        mod <<= 1;
        if (mod > INF)
        {
            mod -= INF;
        }
        b >>= 1;
    }
    return res;
}

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    int sum = 1;
    for (int i = 2; i <= N; i++)
    {
        if (!isPrime(i)) continue;
        int cnt = 0;
        for (int j = 2; j <= N; j++)
        {
            if (j < i) continue;
            cnt += num_division(j, i);
        }
        sum = modmulti(sum, cnt + 1);
    }

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


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

int main(){
    string s;
    cin >> s;

    int cnt = 0;
    int i = 0;
    while(s[i + 1] != '\0'){
        if(s[i] == s[i + 1]){
            cnt++;
            if(s[i + 1] == '1'){
                s[i + 1] = '0';
            }
            else{
                s[i + 1] = '1';
            }
            i--;
        }
        i++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint N;
llint d[305];
llint dp[305][305][305];

llint fact[605], fact_inv[605];

llint pow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (pow(a, n-1)%mod)) % mod;
	}
	else{
		return pow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < 605; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	for(int i = 0; i < 605; i++){
		fact_inv[i] = pow(fact[i], mod-2);
	}
}

int main(void)
{
	cin >> N;
	for(int i = 1; i <= N; i++) cin >> d[i];
	make_fact();
	
	bool flag = false;
	for(int i = 1; i <= N; i++){
		if(d[i] < 2){
			flag = true;
			break;
		}
	}
	if(!flag){
		cout << fact[N-1] * pow(2, mod-2) % mod << endl;
		return 0;
	}
	
	
	dp[0][0][0] = 1;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			for(int k = 0; k <= N; k++){
				dp[i+1][j][k] += dp[i][j][k], dp[i+1][j][k] %= mod;
				if(d[i+1] >= 2) dp[i+1][j+1][k+d[i+1]-2] += dp[i][j][k] * (d[i+1]-1) % mod, dp[i+1][j+1][k+d[i+1]-2] %= mod;
			}
		}
	}
	
	llint mul = 1;
	for(int i = 1; i <= N; i++) mul *= fact_inv[d[i]-1], mul %= mod;
	mul *= pow(2, mod-2), mul %= mod;
	
	/*for(int i = 0; i <= N; i++){
		for(int j = 0; j <= N; j++){
			for(int k = 0; k <= N; k++){
				cout << dp[i][j][k] << " ";
			}
			cout << endl;
		}
		cout << endl;
	}*/
	
	llint ans = 0;
	for(int i = 3; i < N; i++){
		for(int j = 1; j <= N; j++){
			if(dp[N][i][j] == 0) continue;
			llint tmp = fact[i-1] * fact[(N-i)-1] % mod;
			tmp *= j, tmp %= mod;
			tmp *= dp[N][i][j], tmp %= mod;
			ans += tmp, ans %= mod;
		}
	}
	ans *= mul, ans %= mod;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 218752
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string str;
ll dp[20][20];

void solve() {
	cin >> N;
	rep(i, 0, 2 * N) cin >> str;
	string S;
	rer(i, 2 * N, N) S += str[i];
	ll res = 0;
	rep(bit, 0, (1 << N)) {
		string r, b;
		rep(i, 0, N) {
			if(bit & (1 << i)) b += str[i];
			else r += str[i];
		}
		// reverse(all(b));
		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1;
		rep(i, 0, N) {
			rep(a, 0, sz(r) + 1) {
				int c = i - a;
				if(c < 0 || !dp[i][a]) continue;
				if(a < sz(r) && S[i] == r[a]) dp[i + 1][a + 1] += dp[i][a];
				if(c < sz(b) && S[i] == b[c]) dp[i + 1][a] += dp[i][a];
			}
		}
		res += dp[N][sz(r)];
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>
#include <queue>
#include <ios>
#include <iomanip>
#include <ctime>
#include <tuple>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFF
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")

#define PInt pair<int, int>
#define PLL pair<long long, long long>
#define VInt vector<int>
#define VLL vector<long long>
#define MatrixInt vector<vector<int>>
#define MatrixLL vector<vector<long long>>

typedef long long ll;
using namespace std;

int main() {
    
    string s;
    cin >> s;

    deque<char> q;
    int ans = 0;
    for (auto itr = s.begin(); itr < s.end(); itr++) {
        if (q.empty()) {
            q.push_back(*itr);
        } else {
            if (q.back() != *itr) {
                q.pop_back();
                ans++;
            } else {
                q.push_back(*itr);
            }
        }
    }

    cout << ans * 2 << endl;
    
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 505
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int a[N][N],n,ans,p[N*N],vis[N][N];
const int d[4][2]={{0,1},{1,0},{-1,0},{0,-1}};
inline bool check(int x,int y){
	return x>=1&&y>=1&&x<=n&&y<=n;
}
void dfs(int x,int y){
	for(int i=0;i<4;++i){
		int nx=x+d[i][0],ny=y+d[i][1];
		if(check(nx,ny)&&a[nx][ny]>a[x][y]+(!vis[x][y])){
			a[nx][ny]=a[x][y]+(!vis[x][y]);
			dfs(nx,ny);
		}
	}
}
int main(){
	n=read();
	for(int i=1;i<=n*n;++i){
		p[i]=read();
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			a[i][j]=min(min(n-i,i-1),min(n-j,j-1));
		}
	}
	for(int i=1;i<=n*n;++i){
		int x=(p[i]-1)/n+1,y=(p[i]-1)%n+1;
		ans+=a[x][y];
		vis[x][y]=1;
		for(int k=0;k<4;++k){
			int nx=x+d[k][0],ny=y+d[k][1];
			if(check(nx,ny)&&a[nx][ny]>a[x][y]){
				a[nx][ny]=a[x][y],dfs(nx,ny);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 22076
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  int A,B,K;
  cin>>A>>B>>K;
  int X=min(A,B);
  vector<int> Y;
  for (int i=1;i<=X;i++) {
    if (A%i==0 && B%i==0) {
      Y.push_back(i);
    }
  }
  reverse(Y.begin(),Y.end());
  cout<<Y[K-1]<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
ll dp[2010][2010];
struct node {
	int id;
	int val;
}a[2010];
int cmp(node a, node b) {
	return a.val < b.val;
}
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i].val);
		a[i].id = i;
	}
	sort(a + 1, a + 1 + n, cmp);
	for (int i = 1; i <= n; i++)
		dp[i][i] = a[1].val * llabs(a[1].id - i);
	for(int len = 2; len <= n; len++)
		for (int i = 1; i + len - 1 <= n; i++) {
			int j = i + len - 1;
			dp[i][j] = max(dp[i + 1][j] + (ll)a[len].val * llabs(a[len].id - i), dp[i][j - 1] + (ll)a[len].val * llabs(a[len].id - j));
		}
	cout << dp[1][n]<<endl;
	return 0;
}

Measured memory_bytes: 25892
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;
#define nl endl

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
bool mark[100005];vi prime;
void seive(ll N){for(int i=2;i<=N;i++){if(mark[i]==false){prime.pb(i);for(int j=i+i;j<N;j+=i)mark[j]=true;}}}
//freopen("input.txt", "r", stdin);

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b));
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

    
    public static void main(String[] args) {
        Scanner sc=new Scanner (System.in);
        int a,b,c;
        a=sc.nextInt();
        b=sc.nextInt();
        c=sc.nextInt();
    if(a==5&&b==5&&c==7)
    {
        System.out.println("YES");
    }
    else if(a==5&&b==7&&c==5){
        System.out.println("YES");
    }
    else if(a==7&&b==5&&c==5){
       System.out.println("YES");
    }
    else {
        System.out.println("NO");
    }
    }
    
}


Measured memory_bytes: 26956
just=[]
left=[]
for i in range(5):
  a=int(input())
  if a%10 == 0:
    just.append(a)
  else:
    left.append(a)
_sum = sum(just)    
_min=10
index=-1
for i in range(len(left)):
  i1=left[i]%10
  if _min > i1:
    _min = i1
    index = i
for i in range(len(left)):
  if i == index:
    _sum += left[i]
  else:
    b=left[i]%10
    _sum += left[i] + (10-b)
print(_sum)    
    

Measured memory_bytes: 3064
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        if(A - B == 0){
            System.out.println(C);
        }else if(B - C == 0){
            System.out.println(A);
        }else if(C - A == 0){
            System.out.println(B);
        }
    }
}

Measured memory_bytes: 23764
// copied by Nurstan Duisengaliev
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
int n, m; 
int a[N], b[N];
int dp[(1 << 12) + 1];
void solve () {	
	cin >> n >> m;
	for (int i = 1; i <= m; i ++) {
		cin >> a[i];
		int k;
		cin >> k;
		for (int j = 1; j <= k; j ++) {
			int f;
			cin >> f;
			b[i] ^= (1 << (f - 1));
		}
	}	
	for (int mask = 1; mask < (1 << n); mask ++) {
		dp[mask] = mod;
	}
	for (int mask = 0; mask < (1 << n); mask ++) {
		for (int j = 1; j <= m; j ++) {
			dp[mask | b[j]] = min(dp[mask | b[j]], dp[mask] + a[j]);
		}
	}
	if (dp[(1 << n) - 1] == mod) {
		cout << -1;
		return;
	}
	cout << dp[(1 << n) - 1];
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//  cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    ll ct=1;
    rep(i,N){
        if(A[i]==ct) ++ct;
    }
    if(ct==1) dame;
    cout<< N-ct+1<<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>
using namespace std;

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

int H, W, N;
int bx[110], by[110];
vector<int> altx, alty;
int nH, nW;
int xnum[1100000], ynum[1100000];
bool cb[110][110];
int dist[110][110];
typedef pair<int, int> pint;

long long subsolve() {
  long long res = 0;
  for (int x = 0; x < nH; ++x) {
	for (int y = 0; y < nW; ++y) {
	  if (cb[x][y]) continue;
	  memset(dist, -1, sizeof(dist));
	  queue<pint> que;
	  que.push(pint(x, y));
	  dist[x][y] = 0;
	  while (!que.empty()) {
		pint cur = que.front();
		que.pop();
		for (int dir = 0; dir < 4; ++dir) {
		  int nx = cur.first + dx[dir];
		  int ny = cur.second + dy[dir];
		  if (nx < 0 || nx >= nH || ny < 0 || ny >= nW) continue;
		  if (cb[nx][ny]) continue;
		  if (dist[nx][ny] == -1) {
			dist[nx][ny] = dist[cur.first][cur.second] + 1;
			que.push(pint(nx, ny));
		  }
		}
	  }
	  for (int nx = 0; nx < nH; ++nx) {
		for (int ny = 0; ny < nW; ++ny) {
		  if (nW * nx + ny <= nW * x + y) continue;
		  if (dist[nx][ny] == -1) continue;
		  if (cb[nx][ny]) continue;
		  long long ss = ((long long)(altx[x + 1] - altx[x]) * (alty[y + 1] - alty[y])) % MOD;
		  long long st = ((long long)(altx[nx + 1] - altx[nx]) * (alty[ny + 1] - alty[ny])) % MOD;
		  res += (dist[nx][ny] % MOD) * ss % MOD * st % MOD;
		  res %= MOD;
		}
	  }	
	}
  }
  return res;
}

long long solve() {
  memset(xnum, 0, sizeof(xnum));
  memset(ynum, 0, sizeof(ynum));
  altx.clear(); alty.clear();
  altx.push_back(0); altx.push_back(H);
  alty.push_back(0); alty.push_back(W);
  for (int i = 0; i < N; ++i) {
	altx.push_back(bx[i]);
	altx.push_back(bx[i] + 1);
	alty.push_back(by[i]);
	alty.push_back(by[i] + 1);
	xnum[bx[i]]++;
	ynum[by[i]]++;
  }
  sort(altx.begin(), altx.end());
  sort(alty.begin(), alty.end());
  altx.erase(unique(altx.begin(), altx.end()), altx.end());
  alty.erase(unique(alty.begin(), alty.end()), alty.end());
  nH = (int)altx.size()-1;
  nW = (int)alty.size()-1;
  memset(cb, 0, sizeof(cb));
  for (int i = 0; i < N; ++i) {
	int itx = lower_bound(altx.begin(), altx.end(), bx[i]) - altx.begin();
	int ity = lower_bound(alty.begin(), alty.end(), by[i]) - alty.begin();
	cb[itx][ity] = true;
  }

  long long all = (long long)H * W - N;
  long long add = 0;
  long long sum = W - xnum[0];
  for (int i = 1; i < H; ++i) {
	if (xnum[i] == 0 && xnum[i-1] == 0) {   // i-1 -> i
	  long long up = sum % MOD;
	  long long down = (all - sum) % MOD;
	  add += (up * down) % MOD;
	  add %= MOD;
	}
	sum += W - xnum[i];
  }
  sum = H - ynum[0];
  for (int i = 1; i < W; ++i) {
	if (ynum[i] == 0 && ynum[i-1] == 0) {   // i-1 -> i
	  long long left = sum % MOD;
	  long long right = (all - sum) % MOD;
	  add += (left * right) % MOD;
	  add %= MOD;
	}
	sum += H - ynum[i];
  }
  long long comp = subsolve();
  long long res = (comp + add) % MOD;
  return res;
}

int main() {
  while (cin >> H >> W >> N) {
	for (int i = 0; i < N; ++i) cin >> bx[i] >> by[i];
	cout << solve() << endl;
  }
}


Measured memory_bytes: 8960
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val s = sc.next()

    for (x in 1 until s.length) {
        if (s[x] === s[x-1]) {
            println("Bad")
            return
        }
    }
    println("Good")
}



Measured memory_bytes: 31264
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

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

	vector<vector<bool>> HW(H, vector<bool>(W));
	for(uint i=0; i<H; i++) {
		string l;
		cin >> l;
		for(uint j=0; j<W; j++) {
				HW[i][j] = (l[j] == '.');
		}
	}

	ull mod = pow(10, 9) + 7;
	vector<vector<ull>> comb(H, vector<ull>(W));

	// left edge
	for(uint i=0; i<H; i++) {
		if(HW[i][0]) {
				comb[i][0] = 1;
		} else {
			break;
		}
	}

	// top edge
	for(uint j=0; j<W; j++) {
		if(HW[0][j]) {
				comb[0][j] = 1;
		} else {
			break;
		}
	}

	for(uint i=1; i<H; i++) {
		for(uint j=1; j<W; j++) {
			comb[i][j] = (HW[i][j]) ? (comb[i][j-1] + comb[i-1][j]) % mod : 0;
		}
	}

	cout << comb[H-1][W-1] << endl;
	return 0;

}


Measured memory_bytes: 8320
#include<stdio.h>
int main(){
  int n,m,c,ans,p,i,j;
  scanf("%d%d%d",&n,&m,&c);
  int b[m];
    for(i=0;i<m;i++){
      scanf("%d",&b[i]);
    }
  int a[n][m];
    ans=0;
  p=0;
  for(j=0;j<n;j++){
    for(i=0;i<m;i++){
      scanf("%d",&a[j][i]);
    }
  }
  for(j=0;j<n;j++){
  	for(i=0;i<m;i++){
      p+=a[j][i]*b[i];
 	 }
    p+=c;
    if(0<p){
      ans+=1;
    }
    p=0;
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
    int k, s, result = 0, x, y, z;
    cin >> k >> s;

    for (int i = 0; i <= k; ++i) {
        int n = s;
        x = i;
        n = n - x;
        for (int j = 0; j <= k; ++j) {
            int m = n;
            y = j;
            m = m - y;
            if (m >= 0)if (m <= k) result++;
        }
    }

    cout << result << endl;
}

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


int main(){
	string s;
	cin >> s;
	string t = "2019/04/30";
	
	if(s <= t) cout << "Heisei" << endl;
	else cout << "TBD" << endl;
	return 0;
}

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

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;

	int val = max(A, max(B, C));

	for (int i = 0; i < K; i++) {
		val *= 2;
	}

	cout << val + A + B + C - max(A, max(B, C));
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,K;
  cin >> N >> K;
  ll t[100100]={0};
  ll s[100100]={0};
  ll a;
  t[0]=0;
  s[0]=0;
  for(int i=1;i<=N;i++){
    cin >> a;
    t[i]=t[i-1]+a;
    s[i]=s[i-1]+max(a,0LL);
  }
  ll ans=0;
  for(int i=0;i<=N-K;i++){
    ans=max(ans,s[N]-s[i+K]+s[i]);
    ans=max(ans,s[N]-s[i+K]+s[i]+t[i+K]-t[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();

		String[] a = new String[5];
		String[] b = new String[4];

		for (int i = 0; i < 4; i++) {
			a[i] = reader.readLine();
			b[i] = reader.readLine();
		}
		a[4] = reader.readLine();
		int x = 0;
		int y = 0;
		char direction = 'R';
		while (true) {

			if (direction == 'R') {
				if (x > 0 && b[x - 1].charAt(y) == '1') {
					direction = 'U';
					x--;
				} else if (y < 4 && a[x].charAt(y) == '1') {
					y++;
				} else if (b[x].charAt(y) == '1') {
					direction = 'D';
					x++;
				} else {
					direction = 'L';
					y--;
				}
			} else if (direction == 'D') {
				if (y < 4 && a[x].charAt(y) == '1') {
					direction = 'R';
					y++;
				} else if (x < 4 && b[x].charAt(y) == '1') {
					x++;
				} else if (y > 0 && a[x].charAt(y - 1) == '1') {
					direction = 'L';
					y--;
				} else {
					direction = 'U';
					x--;
				}
			} else if (direction == 'L') {
				if (x < 4 && b[x].charAt(y) == '1') {
					direction = 'D';
					x++;
				} else if (y > 0 && a[x].charAt(y - 1) == '1') {
					y--;
				} else if (x > 0 && b[x - 1].charAt(y) == '1') {
					direction = 'U';
					x--;
				} else {
					direction = 'R';
					y++;
				}
			} else {
				if (y > 0 && a[x].charAt(y - 1) == '1') {
					direction = 'L';
					y--;
				} else if (x > 0 && b[x - 1].charAt(y) == '1') {
					x--;
				} else if (a[x].charAt(y) == '1') {
					direction = 'R';
					y++;
				} else {
					direction = 'D';
					x++;
				}

			}
			builder.append(direction);
			if (x == 0 && y == 0) {
				break;
			}

		}
		System.out.println(builder);
	}
}

Measured memory_bytes: 16872
#include<bits/stdc++.h>
using namespace std;
 
int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り
 
void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り
 
int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗
 
int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値
 
int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!
 
main(){
    int n=in(),t=in(),t1,t2,ans=t;
    cin >> t1;
    for (int i=1;i<n;i++){
    cin >> t2;
    ans+=min(t,t2-t1);
    t1=t2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;



int main() {
	string s;
	int k;
	cin >> s >> k;
	int n = s.length();
	string max_s;
	for (int i = 0; i < n; i++) {
		max_s += 'z';
	}
	vector<string> dic(k, max_s);

	for (int i = 0; i < n ; i++) {
		for (int j = 1; j + i <= n && j <= k; j++) {

			string sb = s.substr(i, j);

			//cout << sb << endl;
			for (int l = 0; l < k; l++) {

				if (dic[l] > sb) {

					string tmp = dic[l];
					dic[l] = sb;
					sb = tmp;
				}
				else if (dic[l] == sb) {
					break;
				}

			}
		}
	}

	cout << dic[k - 1] << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    vector<vector<ll>> dp(s.length() + 1, vector<ll>(4, 0));
    dp[0][0] = 1;
    dp[0][1] = 0;
    dp[0][2] = 0;
    dp[0][3] = 0;
    for (int i = 0; i < s.length(); ++i) {
        dp[i + 1][0] = (s[i] == '?' ? 3ll : 1ll) * dp[i][0] % MOD;
        for (int j = 1; j <= 3; ++j) {
            dp[i + 1][j] = (s[i] == '?' ? 3ll : 1ll) * dp[i][j] % MOD;
            if (s[i] == '?' || s[i] == "ABC"[j - 1]) {
                dp[i + 1][j] += dp[i][j - 1];
            }
            dp[i + 1][j] %= MOD;
        }
    }
    cout << dp[s.length()][3] << endl;
    return 0;
}

Measured memory_bytes: 7424
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define PI 3.1415926535
using namespace std;
int main(void){

    int n;
    while(1){
        cin>>n;
        if(n==-1)break;
        double t=0.0;
        double x=0.0,y=0.0;
        for(int i=1;i<n;i++){
            t+=acos(sqrt(i)/sqrt(i+1));
            if(t>=2.0*PI)t-=2.0*PI;
        }
        printf("%.2lf\n%.2lf\n",cos(t)*sqrt(n),sin(t)*sqrt(n));
    }
        return 0;

}

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

bool che[8][8][8][8][8][8][8];

class puzzle{
public:
	int p[8];
	int cnt;
	puzzle &operator=(const puzzle &o){
		for (int i = 0; i < 8; i++){
			p[i] = o.p[i];
		}
		cnt = o.cnt;
		return *this;
	}
};

bool isOK(int p[]){
	if (p[0] == 0 && p[1] == 1 && p[2] == 2 && p[3] == 3 && p[4] == 4 && p[5] == 5 && p[6] == 6 && p[7] == 7){
		return true;
	}
	return false;
}

void init_che(puzzle P){
	for (int a = 0; a < 8; a++){
		for (int b = 0; b < 8; b++){
			for (int c = 0; c < 8; c++){
				for (int d = 0; d < 8; d++){
					for (int e = 0; e < 8; e++){
						for (int f = 0; f < 8; f++){
							for (int g = 0; g < 8; g++){
								che[a][b][c][d][e][f][g] = false;
							}
						}
					}
				}
			}
		}
	}
	che[P.p[0]][P.p[1]][P.p[2]][P.p[3]][P.p[4]][P.p[5]][P.p[6]] = true;
}

bool isCheck(puzzle P){
	if (che[P.p[0]][P.p[1]][P.p[2]][P.p[3]][P.p[4]][P.p[5]][P.p[6]])
		return false;
	che[P.p[0]][P.p[1]][P.p[2]][P.p[3]][P.p[4]][P.p[5]][P.p[6]] = true;
	return true;
}

bool ch_u(puzzle& P,int o){
	if (o / 4 == 1){
		return false;
	}
	swap(P.p[o], P.p[o + 4]);
	return true;
}

bool ch_d(puzzle& P, int o){
	if (o / 4 == 0){
		return false;
	}
	swap(P.p[o], P.p[o - 4]);
	return true;
}

bool ch_r(puzzle& P, int o){
	if (o % 4 == 3){
		return false;
	}
	swap(P.p[o], P.p[o + 1]);
	return true;
}

bool ch_l(puzzle& P, int o){
	if (o % 4 == 0){
		return false;
	}
	swap(P.p[o], P.p[o - 1]);
	return true;
}

int main(){
	puzzle P;
	int o;
	while (cin >> P.p[0]){
		if (cin.eof()){
			break;
		}
		for (int i = 1; i < 8; i++){
			cin >> P.p[i];
		}
		P.cnt = 0;
		init_che(P);

		queue<puzzle> que;
		que.push(P);

		if (isOK(P.p)){
			cout << P.cnt << endl;
			continue;
		}

		while (!que.empty()){
			P = que.front();
			que.pop();

			for (int i = 0; i < 8; i++){
				if (P.p[i] == 0){
					o = i;
					break;
				}
			}

			P.cnt += 1;
			if (ch_u(P, o)){
				if (isOK(P.p)){
					cout << P.cnt << endl;
					break;
				}
				if (isCheck(P))
					que.push(P);
				swap(P.p[o], P.p[o + 4]);
			}
			if (ch_d(P, o)){
				if (isOK(P.p)){
					cout << P.cnt << endl;
					break;
				}
				if (isCheck(P))
					que.push(P);
				swap(P.p[o], P.p[o - 4]);
			}
			if (ch_r(P, o)){
				if (isOK(P.p)){
					cout << P.cnt << endl;
					break;
				}
				if (isCheck(P))
					que.push(P);
				swap(P.p[o], P.p[o + 1]);
			}
			if (ch_l(P, o) && isCheck(P)){
				if (isOK(P.p)){
					cout << P.cnt << endl;
					break;
				}
				que.push(P);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const int INF = (1LL<<31)-1;


int main(){
    ll x,y,a,b,c; cin >> x >> y >> a >> b >> c;
    priority_queue<ll> que0,que1,que2;
    rep(i,a){
        ll p; cin >> p;
        que0.push(p);
    }
    rep(i,b){
        ll q; cin >> q;
        que1.push(q);
    }
    rep(i,c){
        ll r; cin >> r;
        que2.push(r);
    }

    ll ans = 0;
    ll X=x,Y=y;
    rep(i,X+Y){
        ll p=0,q=0,r=0;
        ll ma = 0;

        if(!que0.empty() && a>0 && x>0){
            p=que0.top();
        }
        if(!que1.empty() && b>0 && y>0){
            q=que1.top();
        }
        if(!que2.empty() && c>0){
            r=que2.top();
        }
        ma = max(p,q); ma = max(ma,r);
        ans+=ma;

        if(ma == p){
            a--;
            x--;
            que0.pop();
            continue;
        }
        if(ma == q){
            b--;
            y--;
            que1.pop();
            continue;
        }
        if(ma == r){
            c--;
            que2.pop();
            continue;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 6388
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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")
    };
}

fn main() {
    input! { _n:usize, s:chars }
    let mut prev = '🌾';
    let mut count = 0;
    for c in s {
        if prev == 'O' && c == 'X' {
            count += 1;
            prev = '🌸';
        } else if prev == 'X' && c == 'O' {
            count += 1;
            prev = '💓';
        } else if prev != 'X' && prev != 'O' {
            prev = c;
        }
    }
    println!("{}", count);
}



Measured memory_bytes: 5040
#include<bits/stdc++.h>
#define dd double

using namespace std;

int main()
{
    dd xa,ya,xb,yb,x1,y1,a,b,c,x,y;
    scanf("%lf %lf %lf %lf",&xa, &ya, &xb, &yb);
    int q;
    cin >> q;
    a = yb - ya;
    b = xa - xb;
    c = xb * ya - xa * yb;

    while(q--){
        scanf("%lf %lf",&x1,&y1);
        if(xb == xa){
            x = xa;
            y = y1;
            printf("%0.10f %0.10f\n",x,y);
            continue;
        }
        if(yb == ya){
            x = x1;
            y = yb;
            printf("%0.10f %0.10f\n",x,y);
            continue;
        }
        dd k = (a * y1) - (b * x1);
        x =   (b * k + a * c)/(-a * a - b * b);
        y =  ( c * b - a * k) /(-a * a  - b * b);

        printf("%0.10f %0.10f\n",x,y);
       // cout << fixed << setprecision(18) << x << " " << y << endl;
    }

    return 0;
}




Measured memory_bytes: 3244
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int L = scanner.nextInt();
		int pie = 0;
		
		if (L >= 0) {
			//System.out.println("1こめ");
			pie = (1 + N) * N / 2 + (L - 1) * N - L;
		} else if (L + N - 1 < 0) {
			//System.out.println("2こめ");
			pie = N * (N - 1) / 2 + (L - 1) * (N - 1);
		} else {
			//System.out.println("3こめ");
			pie = (1 + N) * N / 2 + (L - 1) * N;
		}
		System.out.println(pie);
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long 
#define int long long 
#define vll vector<long long>
#define pii pair<long long ,long long > 
#define vvi vector< vector<long long > > 
#define vpii vector<pair<int,int>> 
#define pll  pair<long long ,long long > 
#define pb  push_back
#define ff  first 
#define sec second  
#define SORT(a) sort(a.begin(),a.end())
#define SORTR(a) sort(a.rbegin(),a.rend()) 
#define m_p make_pair
#define all(x)   (x.begin(),x.end()) 
#define sz(v)     ((int)(v.size()))
#define INF 1e9+7
typedef vector< long long > vi ;
const int MOD=1e9 +7 ;
int size=10000000; 

int32_t main(){
  fast; 
  
    string s; cin>>s; 
    for(int i=0;i<s.length();i++){
      s[i]='x'; 
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define N 200010
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int n,v,tot=-1,bin[22],R[22][N],num[22],f1[N<<3],f2[N<<3],a[N];//R[i][k],第i层的第k条线段的右端点 
//num[i],第i层的线段条数 f1[s],选择s状态的层数,左边从1开始最远能覆盖到哪里 
int main(){
//	freopen("a.in","r",stdin);
	n=read();v=read();bin[0]=1;
	for(int i=1;i<=20;++i) bin[i]=bin[i-1]<<1;
	for(int i=1;i<=n;++i) a[i]=read();int x=v*2;
	while(x){
		x/=2;tot++;
		for(int i=1;i<=n-1;++i){
			if(a[i+1]-a[i]<=x) continue;
			R[tot][++num[tot]]=i;
		}R[tot][++num[tot]]=n;
	}if(num[0]>tot+1){
		for(int i=1;i<=n;++i) puts("Impossible");return 0;
	}
	for(int s=0;s<=bin[tot]-1;++s) f2[s]=n+1;
	for(int s=0;s<=bin[tot]-1;++s)
		for(int i=1;i<=tot;++i){
			if(s&bin[i-1]) continue;
			f1[s|bin[i-1]]=max(f1[s|bin[i-1]],*upper_bound(R[i]+1,R[i]+num[i]+1,f1[s]));
			f2[s|bin[i-1]]=min(f2[s|bin[i-1]],R[i][lower_bound(R[i]+1,R[i]+num[i]+1,f2[s]-1)-R[i]-1]+1);
		}
	for(int i=1;i<=num[0];++i){
		bool flag=0;
		for(int s=0;s<=bin[tot]-1;++s)
			if(f1[s]>=R[0][i-1]&&f2[bin[tot]-1-s]<=R[0][i]+1){flag=1;break;}
		for(int j=R[0][i-1]+1;j<=R[0][i];++j) puts(flag?"Possible":"Impossible");
	}return 0;
}

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

using namespace std;

bitset<100005> hsh;

int main()
{
  int n;

  scanf("%d",&n);
  queue<pair<int,int> > q;
  q.push({1,1});
  q.push({6,1});
  q.push({36,1});
  q.push({216,1});
  q.push({1296,1});
  q.push({7776,1});
  q.push({46656,1});
  q.push({9,1});
  q.push({81,1});
  q.push({729,1});
  q.push({6561,1});
  q.push({59049,1});
  while(!q.empty())
  {
    if (!hsh[q.front().first])
    {
      hsh[q.front().first]=true;
      if (q.front().first==n)
      {
        printf("%d\n",q.front().second);
        break;
      }
      if (q.front().first+1<100005&&!hsh[q.front().first+1])
      q.push({q.front().first+1,q.front().second+1});
      if (q.front().first+6<100005&&!hsh[q.front().first+6])
      q.push({q.front().first+6,q.front().second+1});
      if (q.front().first+36<100005&&!hsh[q.front().first+36])
      q.push({q.front().first+36,q.front().second+1});
      if (q.front().first+216<100005&&!hsh[q.front().first+216])
      q.push({q.front().first+216,q.front().second+1});
      if (q.front().first+1296<100005&&!hsh[q.front().first+1296])
      q.push({q.front().first+1296,q.front().second+1});
      if (q.front().first+7776<100005&&!hsh[q.front().first+7776])
      q.push({q.front().first+7776,q.front().second+1});
      if (q.front().first+46656<100005&&!hsh[q.front().first+46656])
      q.push({q.front().first+46656,q.front().second+1});
      if (q.front().first+9<100005&&!hsh[q.front().first+9])
      q.push({q.front().first+9,q.front().second+1});
      if (q.front().first+81<100005&&!hsh[q.front().first+81])
      q.push({q.front().first+81,q.front().second+1});
      if (q.front().first+729<100005&&!hsh[q.front().first+729])
      q.push({q.front().first+729,q.front().second+1});
      if (q.front().first+6561<100005&&!hsh[q.front().first+6561])
      q.push({q.front().first+6561,q.front().second+1});
      if (q.front().first+59049<100005&&!hsh[q.front().first+59049])
      q.push({q.front().first+59049,q.front().second+1});
    }
    q.pop();
  }
}


Measured memory_bytes: 1536
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cassert>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
using namespace std;

int n, X, x[210000];
long long ans = 8e18;
long long sum[210000];

int main() {
	scanf("%d%d", &n, &X);
	for (int i = 1; i <= n; i++)
		scanf("%d", &x[i]);
	for (int i = 1; i <= n; i++)
		sum[i] = sum[i - 1] + x[i];
	for (int l = n; l; l--) {
		long long tmp = 1LL * X * n + 1LL * X * l;
		for (int i = n; i > 0; i -= l) {
			int r = i, L = max(1, i - l + 1);
			int p = (n - i) / l;
			int ss;
			if (p == 0) {
				ss = 5;
			}else {
				ss = 2 * p + 3;
			}
			if (1LL * (sum[r] - sum[L - 1]) >= (ans + ss - 1) / ss)
				tmp = ans;
			else
				tmp += 1LL * ss * (sum[r] - sum[L - 1]);
			tmp = min(tmp, ans);
		}
		ans = min(ans, tmp);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> cnt(200100);
  
  rep(i, n) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  sort(cnt.begin(), cnt.end());
  reverse(cnt.begin(), cnt.end());
  ll ans = 0;
  rep(i, 200100) {
    if(i < k) continue;
    ans += cnt[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) y) { return (f)(begin(y), end(y), ## __VA_ARGS__); })(x)
using namespace std;
int main() {
    int n, k, x0; cin >> n >> k >> x0; -- k;
    if (x0 == 0) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> cnt(256); {
        uint64_t x = x0;
        repeat (i,n) {
            cnt[int8_t(x >> 56) + 128] += 1;
            x ^= x << 13;
            x ^= x >> 7;
            x ^= x << 17; // xorshift 64
        }
    }
    int acc = 0;
    int j = 0;
    for (; acc + cnt[j] <= k; ++ j) {
        acc += cnt[j];
    }
    vector<uint64_t> a; {
        uint64_t x = x0;
        repeat (i,n) {
            if (int8_t(x >> 56) + 128 == j) a.push_back(x);
            x ^= x << 13;
            x ^= x >> 7;
            x ^= x << 17; // xorshift 64
        }
    }
    whole(sort, a);
    cout << int64_t(a[k - acc]) << endl;
    return 0;
}

Measured memory_bytes: 7052
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

map<int,ll>dp[60][60];
int main(){
	int n,K;cin>>n>>K;
	dp[0][0][0]=1;
	rep(i,n)rep(j,i+1){
		for(auto p:dp[i][j]){
			if(j){
				(dp[i+1][j][p.first]+=p.second*j*2%MOD)%=MOD;
				(dp[i+1][j-1][p.first+i*2]+=p.second*j%MOD*j%MOD)%=MOD;
			}
			(dp[i+1][j][p.first]+=p.second)%=MOD;
			(dp[i+1][j+1][p.first-i*2]+=p.second)%=MOD;
		}
	}
	cout<<dp[n][0][K]<<endl;
}

Measured memory_bytes: 26240
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

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

    string res = "Christmas";
    if (day == 22) res = "Christmas Eve Eve Eve";
    else if (day == 23) res = "Christmas Eve Eve";
    else if (day == 24) res ="Christmas Eve";

    cout << res << endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int k, t;
int a[100000];

int main() {
    cin >> k >> t;
    forn(i, t) {
        cin >> a[i];
    }
    sort(a, a + t);
    forn(i, t - 1) {
        a[t - 1] -= a[i];
    }
    cout << max(0, a[t - 1] - 1) << endl;
    return 0;
}


Measured memory_bytes: 256