akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=1e5+100;
ll n;
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n;
    if(n%2==0)cout<<n<<"\n";
    else cout<<n*2<<"\n";
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int N, K, X, Y;
signed main()
{
    cin >> N >> K >> X >> Y;
    int ans = 0;
    for(int i = 1; i <= N; ++i) {
        if(i <= K) { ans += X; }
        else { ans += Y; }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e;
  
  cin>> a >> b >> c >> d >> e ;
  
  if(a==0){
    cout<<"1"<<endl;}
  else if(b==0){
    cout<<"2"<<endl;}
  else if(c==0){
    cout<<"3"<<endl;}
  else if(d==0){
    cout<<"4"<<endl;}
  else if(e==0){
    cout<<"5"<<endl;}
  
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {
    
    
    // int x,a;
    // cin>>x>>a;
    // if(x<=a)fin(0);
    // else fin(10);
    // string s;
    // cin>>s;
    // Sort(s);
    // if(s=="abc")fin("Yes");
    // else fin("No");
    string s;
    cin>>s;
    rep(i,s.size()){
        cout<<s[i];
        i++;
    }
    cout<<endl;
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            int s = Integer.parseInt(in.next());

            // 出力
            if (s == 1000000000) {
                for (int i = 0; i < k; i++) {
                    out.printf("%d ", s);
                }
                for (int i = 0; i < n - k; i++) {
                    out.printf("%d ", 1);
                }
                out.printf("\n");
            } else {
                for (int i = 0; i < k; i++) {
                    out.printf("%d ", s);
                }
                for (int i = 0; i < n - k; i++) {
                    out.printf("%d ", s + 1);
                }
                out.printf("\n");
            }

        }

    }
}



Measured memory_bytes: 102404
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	int room[] = new int[450];  // 配列確保（大きめに）
        int n = scanner.nextInt(); // データ数
        int p1 = 0,p2 = 0,p3 = 0;
        int a,b,c,x = 0;
        
        //データ初期化
        for (int i = 0; i < 450; i++) {
            room[i] = 0;
        }
        
        // データ入力
        for (int i = 0; i < n; i++) {
            a = scanner.nextInt();
            b = scanner.nextInt();
            c = scanner.nextInt();
            x = a *100 + b * 10 + (c - 1);
            room[x] += scanner.nextInt();
        }
	  	//出力
        for (int i = 1; i <= 4; i++) {
        	p1 = i * 100; 
        	for(int j = 1; j <= 4; j ++){
        		p2 = j * 10 + p1;
        		for(int k = 0; k < 10 ; k ++  ){
        			p3 = p2 + k;
		        	if(j == 4 && !(i == 4)) {
		        		if(k == 9)
		        			System.out.println("##");
		        		else
		        			System.out.print("##");
		        	}
		        	if(!(j == 4)) {
		        		if(k == 9)
		        			System.out.println(" "+ room[p3]);
		        		else
		        			System.out.print(" "+ room[p3]);
		        	}
		        	
				}
        		if(i == 4 && j == 3) {
    				//System.out.print("\n");
        			break;
        		}
				//System.out.println("");
        	}
        }
        scanner.close();
  }
}


Measured memory_bytes: 29204
using System;
using System.Linq;

namespace aaaaa
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string A = Console.ReadLine();
            int s = int.Parse(A);
            string a;
            a=Console.ReadLine();
            string[] b = a.Split();
            int[] g = new int[s];
            for(int i=0; i < s; i++)
            {
                g[i] = int.Parse(b[i]);
            }
            int d = 0;
            int w = g[0];
            for(int i = 1;i<s;i++)
            {
                if (w > g[i]) { d = i+1 ; w = g[i]; }
            }
            Console.WriteLine(d);
        }
    }
}



Measured memory_bytes: 22932
getNum :: Int -> Int
getNum n
  | n == 100 = 101
  | otherwise = n

getZero :: Int -> Int
getZero d
  | d == 0 = 1
  | d == 1 = 100
  | otherwise = 10000

main = do
  [d, n] <- (map read . words) <$> getLine
  print $ ((getNum n) * (getZero d))

Measured memory_bytes: 3872
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>

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

const int INF = 1<<30;

int main(){
  int n, T;cin>>n>>T;
  vector<int> t(n);
  for(int i=0;i<n;i++){
    cin>>t[i];
  }
  int ans=t[n-1]+T;
  for(int i=1;i<n;i++){
    ans -= max(0, t[i]-(t[i-1]+T));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int i,j,max=0,l;
  char s[100010];
  scanf("%s",s);
  for(l=0;s[l];l++);
  for(i=1;i*2<l-1;i++){
    for(j=0;j<i;j++){
      if(s[j]-s[i+j])break;
    }
    if(i==j)max=i;
  }
  printf("%d\n",max*2);    
  return 0;
}


Measured memory_bytes: 128
// scanf 等でエラーを出さないように追加
#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <memory>
#include <algorithm>
#include <numeric>
#include <set>
#include <functional>
#include <utility>


using namespace std;


typedef long long ll;


int N, K;

int main() {

	scanf("%d %d", &N, &K);

	ll answer = K;

	for (int i = 1; i < N; i++) {

		answer *= K - 1;
	}



	cout << answer << endl;

	return 0;
}

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

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll dp[10001];


int main(){
  ll H, N, C, k;
  ll A[1000], B[1000];
  

  scanf("%lld%lld", &H, &N);

  for (int i = 0; i < N; i++)
  {
      scanf("%lld%lld", A+i, B+i);
  }

  dp[0] = 0;
  for (ll i = 1; i <= H; i++)
  {
    dp[i] = 1000000000;
  }
  

  for (ll i = 0; i < H; i++)
  {
      for (ll j = 0; j < N; j++)
      {
          if(i + A[j] >= H){
              dp[H] = MIN(dp[H], dp[i] + B[j]);
          }
          else{
              dp[i+A[j]] = MIN(dp[i+A[j]], dp[i] + B[j]);
          }
      }
  }
  
  printf("%lld\n", dp[H]);
  
  return 0;
}

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("../in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n;
    cin>>n;


    vector <int> a(n);
    multiset <int> ms;

    loop(i,0,n)
    {
        cin>>a[i];
        ms.insert(-a[i]);
    }

    loop(i,0,n)
    {
        ms.erase(ms.find(-a[i]));
        cout<< -1LL*(*ms.begin())<< "\n";

        ms.insert(-a[i]);
    }



    return 0;
}


Measured memory_bytes: 14268
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
const long long MOD  = 1000000007LL;
const long long MOD2 = 1012455881LL;
const long long MOD3 = 930446593LL;
const long long INF = 1e16;
const int INT_INF   = 1e8;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD, long long tot = 1) {
    for(;exp > 0; exp >>= 1, base = base * base % mod) if((exp & 1) == 1) tot = tot * base % mod;
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD, long long tot = 0) {
    for(;exp > 0; exp >>= 1, base = base * 2 % mod) if((exp & 1) == 1) tot = (tot + base) % mod;
    return tot;
}
struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

//int f[100005],done[100005];
bitset<22> grid[22], vis[22];
int dx[4] = {-1,1,0,0};
int dy[4] = {0,0,-1,1};
int bfs(int x, int y){
    int ans = 0;
    for(int i = 0; i < 22; ++i) vis[i].reset();
    queue<vector<int>> q;
    vis[x][y]=1;
    q.push({x, y, 0});
    while(!q.empty()){
        int x=q.front()[0], y=q.front()[1], m=q.front()[2]; q.pop();
        ans=max(ans,m);
        for(int i = 0; i < 4; ++i){
            if(!grid[dx[i]+x][dy[i]+y])continue;
            if(vis[dx[i]+x][dy[i]+y])continue;
            vis[dx[i]+x][dy[i]+y]=1;
            q.push({dx[i]+x,dy[i]+y,m+1});
        }
    }
    return ans;
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    //char c; cin >> c;
    //cout << (char) (c+1) << endl;

    /*int n, k, m; cin >> n >> k >> m;
    m *= n;
    for(int a, b = 1; b < n; ++b){cin >> a; m -= a;}
    m=max(0,m);
    if(m>k)cout<<"-1\n";
    else cout<<m<<"\n";*/

    /*string s;int n,m;cin>>n>>m;
    int cor=0,pen=0;
    for(int a,i=0;i<m;++i){
        cin>>a>>s;
        if(s=="AC"&&!done[a]){++cor;done[a]=1;pen+=f[a];}
        else if(s=="WA") ++f[a];
    }
    cout << cor << " " << pen << "\n";*/

    char c;
    int h,w;cin>>h>>w;
    for(int i=1;i<=h;++i){
        for(int j=1;j<=w;++j){
            cin>>c;grid[i][j]=c=='.';
        }
    }

    int best = 0;
    for(int i = 1; i <= h; ++i)
        for(int j = 1; j <= w; ++j)
            if(grid[i][j])
                best = max(best, bfs(i,j));
    cout<<best<<"\n";


    return 0;

}


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

int N, M;
vector<vector<int> >G(100010);
vector<vector<int> >GC(100010);
int s, t;
int H[400100];
int Hn=0;
int Hc[400100];
int vis[100010];
int val[100010];
vector<vector<int> >G2(100010);

void addHeap(int nd, int c)
{
	Hn ++;
	H[Hn] = nd;
	Hc[Hn] = c;
	int i=Hn, j;
	while(i>1){
		j = i/2;
		if(Hc[j] > c){
			H[i] = H[j];
			Hc[i] = Hc[j];
			i = j;
		}
		else
			break;
	}
	H[i] = nd;
	Hc[i] = c;
}

void delHeap(int &nd, int &c)
{
	nd = H[1];
	c = Hc[1];
	int tmp = H[Hn];
	int tmpc = Hc[Hn];
	Hn --;
	int i = 1, j;
	while(2*i<=Hn){
		j = 2*i;
		if(j+1<=Hn && Hc[j+1]<Hc[j])
			j ++;
		if(Hc[j] < tmpc){
			H[i] = H[j];
			Hc[i] = Hc[j];
			i = j;
		}
		else
			break;
	}
	H[i] = tmp;
	Hc[i] = tmpc;
} 

int exist(int c, int nd)
{
	int i;
	for(i=0; i<G2[nd].size(); i++){
		if(G2[nd][i] == c)
			return 1;
	}
	return 0;
}

void solve()
{
	int i;
	int res = -1;
	s = 0;
	t = N-1;
	Hn = 0;
	addHeap(s, 0);
	while(Hn > 0){
		int nd, c;
		delHeap(nd, c);
		if(nd == t){
			res = c;
			break;
		}
		if(vis[nd] == 1)
			continue;
		vis[nd] = 1;
		for(i=0; i<G[nd].size(); i++){
			int v = G[nd][i];
			if(vis[v] == 0){
				if(val[v] == 0){
					int c2 = c;
					if( !exist(GC[nd][i], nd) ){
						c2 ++;
					}
					val[v] = c2;
					G2[v].push_back(GC[nd][i]);
					addHeap(v, c2);
				}
				else{
					int c2 = c;
					if( !exist(GC[nd][i], nd) ){
						c2 ++;
					}
					if(c2 == val[v]){
						G2[v].push_back(GC[nd][i]);
						//addHeap(v, c2);
					}
					else if(c2 < val[v]){
						G2[v].clear();
						val[v] = c2;
						G2[v].push_back(GC[nd][i]);
						addHeap(v, c2);
					}
				}
			}
			else{
				if(exist(GC[nd][i], nd)==1 && val[v]==c && exist(GC[nd][i], v)==0){
					vis[v] = 0;
					G2[v].push_back(GC[nd][i]);
					addHeap(v, c);
				}
			}
		}
	}
	printf("%d\n", res);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int i;
	scanf("%d%d", &N, &M);
	for(i=0; i<M; i++){
		int p, q, c;
		scanf("%d%d%d", &p, &q, &c);
		p --;
		q --;
		G[p].push_back(q);
		GC[p].push_back(c);
		G[q].push_back(p);
		GC[q].push_back(c);
	}
	solve();
	return 0;
}

Measured memory_bytes: 31864
/* ****revpro**** */
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  100005
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll a[3];
		ll s=0;
		rep(i,0,3) cin>>a[i],s+=a[i];
		if(s>=22) cout<<"bust";
		else cout<<"win\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl



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

	ll N;
	cin >> N;
	double dp[N+1][N+1];// dp[表][裏]
	dp[0][0] = 1;

	FOR(i,1,N+1){
		double p;
		cin >> p;
		dp[0][i] = dp[0][i-1] * (1.0-p);
		dp[i][0] = dp[i-1][0] * p;
		FOR(j,1,i){
			dp[i-j][j] = dp[i-j-1][j] * p + dp[i-j][j-1] * (1.0-p);
		}
	}

	double ans = 0;
	FOR(i,0,N+1){
		if(i>(N-i))ans += dp[i][N-i];
	}
	cout << setprecision(10) << ans << endl;
}

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

int main() {
  int x;
  cin >> x;
  
  if (x == 2) {
    cout << x << endl;
  }
  else if (x == 3) {
    cout << x << endl;
  }
  else {
    for (int i = x; i < 100000000000; i++) {
      if (i % 2 == 0) {
        continue;
      }
      double sqi = sqrt(i);
      int flg = 0;
      for (int j = 3; j <= sqi; j += 2) {
        if (i % j == 0) {
          flg = 1;
          break;
        }
      }
      if (flg == 0) {
        cout << i << endl;
        break;
      }
    }
  }
}

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

class Dice {
    public:
        int a, b, c, d, z, f;
        Dice(int a, int b, int c, int d, int z, int f) {
            this->a = a;
            this->b = b;
            this->c = c;
            this->d = d;
            this->z = z;
            this->f = f;
        }

        void s() {
            int tmp = this->b;
            this->b = this->a;
            this->a = this->z;
            this->z = this->f;
            this->f = tmp;
        }

        void e() {
            int tmp = this->c;
            this->c = this->a;
            this->a = this->d;
            this->d = this->f;
            this->f = tmp;
        }

        void n() {
            int tmp = this->b;
            this->b = this->f;
            this->f = this->z;
            this->z = this->a;
            this->a = tmp;
        }

        void w() {
            int tmp = this->c;
            this->c = this->f;
            this->f = this->d;
            this->d = this->a;
            this->a = tmp;
        }

        void zAxis() {
            int tmp = this->b;
            this->b = this->c;
            this->c = this->z;
            this->z = this->d;
            this->d = tmp;
        }

        void tf(int top, int front) {
            bool tp = this->a == top;
            bool ft = this->b == front;
            while (!(tp && ft)) {
                if (tp && !ft) {
                    while (!ft) {
                        this->zAxis();
                        ft = this->b == front;
                        if (ft) break;
                    }
                }
                else if (!tp && ft) {
                    while (!tp) {
                        this->e();
                        tp = this->a == top;
                        if (tp) break;
                    }

                }
                else {
                    this->s();
                    tp = this->a == top;
                    ft = this->b == front;
                }
            }
        }

        void printTop() {
            cout << this->a << endl;
        }
        void printRight() {
            cout << this->c << endl;
        }
};


int main () {
        int a,  b,  c,  d,  z,  f;
        cin >> a >>  b >>  c >>  d >>  z >>  f;
        int q;
        cin >> q;
        for(int i=0; i<q; i++) {
            Dice dd(a, b, c, d, z, f);
            int top, front;
            cin >> top >> front;
            dd.tf(top, front);
            dd.printRight();
        }
        return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

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

typedef long long ll;

int SURP = 1000000007;

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

	string ret = "";
	if (N >= 1000){
		ret = "ABD";
	}else{
		ret = "ABC";
	}
	cout << ret << endl;
	return 0;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[2] == s[3] and s[4] == s[5]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
    
}



Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    S = [str(c) for c in input().strip()]
    T = [str(c) for c in input().strip()]

    n = len(S) - len(T) + 1
    candidate = []
    for i in range(n):
        check = [False] * len(T)
        for j in range(len(T)):
            if T[j] == S[j+i] or S[j+i] == '?':
                check[j] = True

        if all(check):
            can = ''
            B = S[:i] + T + S[i+len(T):]
            for a in B:
                if a == '?':
                    can += 'a'
                else:
                    can += a

            candidate.append(can)

    if len(candidate) == 0:
        print('UNRESTORABLE')
    else:
        candidate = sorted(candidate)
        print(candidate[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

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

  ll X, Y;
  cin >> X >> Y;

  if (abs(X - Y) > 1) {
    cout << "Alice" << endl;
  } else {
    cout << "Brown" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include <vector>
#include <sstream>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
int main(){
    int n;
    bool save = true;
    int res, a; 
    cin >> n;
    cin >> res;
    for (int i = 1; i<n; i++){
    	cin >> a;
    	if (a < res) save = false;
    	else if (a > res){
    		res = a-1;
		}
		else{
			res = a;
		}
	}
	if (save == false) cout << "No";
	else cout << "Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int dy8[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dx8[] = {0, 1, 0, -1, 1, 1, -1, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{

    int H,W; cin >> H >> W;
    int c[10][10];
    REP(i,10) REP(j,10) cin >> c[i][j];
    REP(k,10) REP(i,10) REP(j,10){
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    }

    int A[H][W];
    ll ans=0;
    REP(i,H) REP(j,W){
        int a; cin >> a;
        if(a>=0) ans += c[a][1];
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    using namespace std;
    constexpr unsigned long C = 26;
    unsigned long D;
    cin >> D;
    vector<unsigned long> c(C);
    for(auto&& i : c)cin >> i;
    vector v(D, vector<unsigned long>(C));
    for(auto&& i : v)for(auto&& j : i)cin >> j;

    vector<unsigned long> last(C);

    for(unsigned long i{0}; i < D; ++i){
        unsigned long mx{0}, mxi{0};
        for(unsigned long j{0}; j < C; ++j){
            unsigned long tmp{v[i][j] + c[j] * (i + 1 - last[j]) * (D - i)};
            if(tmp > mx){
                mx = tmp;
                mxi = j;
            }
        }
        cout << mxi + 1 << endl;
        last[mxi] = i + 1;
    }

    return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから

void solve(){
  int n;
  cin>>n;
  cout<<800*n-n/15*200;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<n; ++i)

template <class T>
void print_answer(vector<T>& a) {
    for (auto& x : a)
        cout << x << endl;
}

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

    int rank = 1;
    for (int i=2000; i>400; i -= 200) {
        if (x >= i-200) {
            cout << rank;
            break;
        }
        rank++;
    }
    return 0;
}


Measured memory_bytes: 3220
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,m;
  cin >> n;
  ll d[n];
  map<ll,ll> mp;
  for(int i=0;i<n;i++){
    cin >> d[i];
    mp[d[i]]++;
  }
  cin >> m;
  ll t;
  for(int i=0;i<m;i++){
    cin >> t;
    if(mp[t]>0){
      mp[t]--;
    }else{
      cout << "NO\n";
      return 0;
    }
  }
  cout <<"YES\n";
}


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

using namespace std;

using ll = long long;

int main(){
    ll h,n;cin>>h>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    cout << ((accumulate(a.begin(),a.end(),0LL)>=h) ? "Yes" : "No") << endl;
}


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
LL n,a[N];
LL ans;
int sta;
vector<LL>l,r;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;LL x=0,sta=0;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		if(a[i]<0)l.pb(a[i]);
		else if(a[i]>=0)ans+=a[i],r.pb(a[i]);
	}
	sort(l.begin(),l.end());
	sort(r.begin(),r.end());
	for(int i=2;i<=l.size();i+=2){
		ans-=l[i-1];
		ans-=l[i-2];
	}
	if(l.size()%2==1){
		if(r.size()&&r[0]+l[l.size()-1]<0){
			ans-=l[l.size()-1];
			sta=1;
		}		
	}
	if(sta)ans-=2*r[0];
	else if(l.size()&&l.size()%2==1&&!sta)ans+=l[l.size()-1];
	cout<<ans<<endl;
	return 0;
}






Measured memory_bytes: 2424
INF = 10 ** 9
MOD = 10 **9 + 7
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  collections import deque
from math import factorial

def main():
    n,m = map(int,input().split())
    War = [tuple(map(int,input().split())) for _ in range(m)]
    War.sort(key = lambda x:x[1])

    last_cut = 0
    ans = 0
    for a,b in War:
        if last_cut < a:
            last_cut = b - 1
            ans += 1
    print(ans)
if __name__=='__main__':
    main()

Measured memory_bytes: 18516
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>

using namespace std;

    int main(){
    int gh,gm,gs,bh,bm,bs,inh,inm,ins,i;
    for(int i=0;i<3;i++){
        cin>>gh>>gm>>gs;
        cin>>bh>>bm>>bs;
        inh=bh-gh;
        inm=bm-gm;
        ins=bs-gs;
        if(ins<0){
             inm-=1;
             ins+=60;
        } if(inm<0){
             inh-=1;
             inm+=60;
        }
        cout<<inh<<" "<<inm<<" "<<ins<<endl ;
     }
     return 0;
}

Measured memory_bytes: 1160
#include "iostream"
#include "cstdio"
#include "cstring"
#include "algorithm"
#include "queue"
#include "stack"
#include "cmath"
#include "utility"
#include "map"
#include "set"
#include "vector"
#include "list"
#include "string"
#include "cstdlib"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define st first
#define nd second
#define exp 1e-8
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int MAXN = 1e5 + 5;
int w, h, c, d;
priority_queue<int, std::vector<int>, greater<int> > a, b;
ll ans = 0;
int main(int argc, char const *argv[])
{
	scanf("%d%d", &w, &h);
	for(int i = 0; i < w; ++i) {
		int x;
		scanf("%d", &x);
		a.push(x);
	}
	for(int i = 0; i < h; ++i) {
		int x;
		scanf("%d", &x);
		b.push(x);
	}
	while(!a.empty() && !b.empty()) {
		int x = a.top(), y = b.top();
		if(x < y) {
			ans += 1ll * x * (h + 1 - d);
			c++;
			a.pop();
		}
		else {
			ans += 1ll * y * (w + 1 - c);
			d++;
			b.pop();
		}
	}
	while(!a.empty()) {
		int x = a.top();
		ans += 1ll * x * (h + 1 - d);
		c++;
		a.pop();
	}
	while(!b.empty()) {
		int y = b.top();
		ans += 1ll * y * (w + 1 - c);
		d++;
		b.pop();
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    ll N, A, B, C;
    cin >> N >> A >> B >> C;
    vector<string> s(N);
    for(auto& x: s) cin >> x;

    vector<char> ans(N);
    for(int i=0; i<N; i++){
        if(s[i] == "AB"){
            if(A == 0 && B == 0){
                cout << "No" << endl; return 0;
            }
            if(A < B){
                A++; B--;
                ans[i] = 'A';
            }else if(A > B){
                A--; B++;
                ans[i] = 'B';
            }else if(i!=N-1 && s[i+1]=="BC"){
                A--; B++;
                ans[i] = 'B';
            }else{
                A++; B--;
                ans[i] = 'A';
            }
        }

        else if(s[i] == "BC"){
            if(B == 0 && C == 0){
                cout << "No" << endl; return 0;
            }
            if(B < C){
                B++; C--;
                ans[i] = 'B';
            }else if(B > C){
                B--; C++;
                ans[i] = 'C';
            }else if(i!=N-1 && s[i+1]=="AC"){
                B--; C++;
                ans[i] = 'C';
            }else{
                B++; C--;
                ans[i] = 'B';
            }
        }

        else{
            if(C == 0 && A == 0){
                cout << "No" << endl; return 0;
            }
            if(C < A){
                C++; A--;
                ans[i] = 'C';
            }else if(C > A){
                C--; A++;
                ans[i] = 'A';
            }else if(i!=N-1 && s[i+1]=="AB"){
                C--; A++;
                ans[i] = 'A';
            }else{
                C++; A--;
                ans[i] = 'C';
            }
        }
    }

    cout << "Yes\n";
    for(int i=0; i<N; i++) cout << ans[i] << "\n";
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ll mod=1e9+7;
const ld PI = 2 * acos(0.0);
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int a,b,c,k;cin>>a>>b>>c>>k;
    int ans=0;
    if(k<=a)
    {
        cout<<k<<endl;
        return 0;
    }
    else
    ans+=a,k-=a;
    if(k<=b)
    {
        cout<<ans<<endl;
        return 0;
    }
    else
    k-=b;
    ans+=-k;
    cout<<ans<<endl;   
    return 0;
}

Measured memory_bytes: 3652
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let x = input!(i64);

    if x == 6 {
        println!("1");
    } else {
        let result = x / 11;
        if x % 11 == 0 {
            println!("{}", result * 2);
        } else if x % 11 <= 6 {
            println!("{}", result * 2 + 1);
        } else {
            println!("{}", result * 2 + 2);
        }
    }
}


Measured memory_bytes: 4352
//by Sshwy
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/
const int N=17,M=17,P=1e9+7;
int pw(int a,int m){
    int res=1;
    while(m)m&1?res=1ll*res*a%P:0,a=1ll*a*a%P,m>>=1;
    return res;
}

int n,m,nn;
int a[M];
int f[1<<N];
//f[mask]表示mask集合对应的区间的最小值是a中的元素

int fac[(1<<N)+1],fnv[(1<<N)+1];

int binom(int n,int m){
    if(n<0||m<0||n<m)return 0;
    return fac[n]*1ll*fnv[m]%P*fnv[n-m]%P;
}
void add(int &x,int y){x=(x+y)%P;}
int sig(int x){return 1-2*(x&1);}
int main(){
    scanf("%d%d",&n,&m);
    nn=1<<n;

    fac[0]=1;
    FOR(i,1,nn)fac[i]=1ll*fac[i-1]*i%P;
    fnv[nn]=pw(fac[nn],P-2);
    ROF(i,nn,1)fnv[i-1]=1ll*fnv[i]*i%P;

    FOR(i,1,m)scanf("%d",&a[i]);

    f[0]=1;//初始时

    ROF(i,m,1){
        ROF(mask,nn-1,0){//滚动数组
            int sum=mask;//sum表示已经使用过的数字的个数。恰好等于mask
            FOR(j,0,n-1)if(!(mask>>j&1)){
                add(f[mask|(1<<j)],binom(nn-sum-a[i],(1<<j)-1)*1ll*fac[1<<j]%P*f[mask]%P);
            }
        }
    }

    int ans=0;

    FOR(mask,0,nn-1)add(ans,sig(__builtin_popcount(mask))*1ll*f[mask]%P*fac[nn-mask-1]%P);

    ans=ans*1ll*nn%P;

    add(ans,P);

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


Measured memory_bytes: 1024
n = input()
keta = len(n)
n=int(n)
if keta==1:
  print(n)
else:
  count=0
  odd_keta = [k for k in range(1,keta) if k%2==1]
  counts = [9*10**(o-1) for o in odd_keta]
  count +=sum(counts) 

  if keta%2==1: #奇数桁なら
    count += (n-10**(keta-1))+1

  print(count)

Measured memory_bytes: 3060
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << "[" << pa.first << ", " << pa.second << "]";
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  os << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "}";
  return os;
}

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

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

  ll n;
  std::cin>>n;

  std::vector<ll> a(n);
  bool flag=true;
  rep(i,0,n)std::cin>>a[i];

  rep(i,1,n)if(a[i-1]>=a[i])flag=false;
  if(flag){
    std::cout<<1;
    return 0;
  }

  ll left=1,right=n+1;

  while(right-left>1){
    ll mid=(left+right)/2;

    std::map<ll,ll> chara;

    bool isok=true;
    ll len=0;
    rep(i,0,n){
      if(a[i]>len){
        len=a[i];
      }else{
        while((!chara.empty())&&chara.rbegin()->first>=a[i]){
          ll val=chara.rbegin()->first;
          chara.erase(val);
        }
        chara[a[i]-1]++;
        ll now=a[i]-1;
        while(chara[now]>=mid){
          chara.erase(now);
          now--;
          chara[now]++;
          if(now<0)isok=false;
        }
        if(!isok)break;
        len=a[i];
      }
    }
    if(isok)right=mid;
    else left=mid;
  }

  std::cout<<right;

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>
#define y1 y11
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define NAME ""

using namespace std;
	
typedef long long ll;
typedef long double ld;

const ld PI = acos(-1.0);


string s[11];

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	int h, w;
	cin >> h >> w;
	int cn = 0;
	for (int i = 0; i < h; i++)
	{
		cin >> s[i];
		for (int j = 0; j < w; j++)
		{
			if (s[i][j] == '#') cn++;
		}
		s[i] += '.';
	}
	s[h].resize(w, '.');
	if (cn != h + w - 1)
	{
		cout << "Impossible" << endl;
		return 0;
	}
	int x = 0, y = 0;
	while ((x < h - 1) || (y < w - 1))
	{
		if (s[x + 1][y] == s[x][y + 1])
		{
			cout << "Impossible" << endl;
			return 0;
		}
		if (s[x + 1][y] == '#') x++;
		else y++;
	}
	cout << "Possible" << endl;
	return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

const int MAX_N = 1005;

int cnt[MAX_N][MAX_N];
int n, D, mx;
int sm[2*MAX_N][2*MAX_N][2];

#define comp(a, b, c, d, k) (sm[c+1][d+1][k] - sm[c+1][b][k] - sm[a][d+1][k] + sm[a][b][k])

bool possible(int b)
{
    rep(i,D){
        rep(j,D){
            if(comp(i+b+1,j+b+1,i+D-1,j+D-1,0) == 0 && comp(i+b+1,j,i+D-1,j+b,1) == 0 && comp(i,j+b+1,i+b,j+D-1,1) == 0) return true;
        }
    }
    return false;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> D;
    rep(i,n){
        int x,y;
        cin >> x >> y;
        cnt[x%D][y%D]++;
    }
    rep(i,D){
        rep(j,D){
            cmx(mx,(int)ceil(sqrt(cnt[i][j]))-1);
        }
    }
    rep(i,D){
        rep(j,D){
            sm[i+1][j+1][0] = sm[i+D+1][j+1][0] = sm[i+1][j+D+1][0] = sm[i+D+1][j+D+1][0] = (cnt[i][j] > mx*mx);
            sm[i+1][j+1][1] = sm[i+D+1][j+1][1] = sm[i+1][j+D+1][1] = sm[i+D+1][j+D+1][1] = (cnt[i][j] > mx*(mx+1));
        }
    }
    rep(i,2*D+1){
        rep(j,2*D){
            rep(k,2){
                sm[i][j+1][k] += sm[i][j][k]; 
            }
        }
    }
    rep(j,2*D+1){
        rep(i,2*D){
            rep(k,2){
                sm[i+1][j][k] += sm[i][j][k];
            }
        }
    }
    int l = -1, r = D-1;
    while(r-l>1){
        int mid = (l+r)/2;
        if(possible(mid)){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout << (ll)mx*D+r << "\n";
    return 0;
}

Measured memory_bytes: 35584