akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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




int main(){
    VI N(4), A = {1, 9, 7, 4};
    REP(i, 4) cin >> N[i];
    SORT(N);
    SORT(A);
    cout << ((N==A) ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
S1 = input()
S2 = input()
mod = 10**9 + 7

prev = 0  # 0 = first, 1 = vertical, 2 = horizontal

pattern = 1
skip = False
for s1, s2 in zip(S1, S2):
    if skip:
        skip = False
        continue

    if s1 == s2:
        block = 1
    else:
        block = 2
        skip = True

    if prev == 0:
        if block == 1:
            pattern = pattern * 3 % mod
            prev = 1
        else:
            pattern = pattern * 6 % mod
            prev = 2

    elif prev == 1:
        if block == 1:
            pattern = pattern * 2 % mod
            prev = 1
        else:
            pattern = pattern * 2 % mod
            prev = 2

    elif prev == 2:
        if block == 1:
            prev = 1
        else:
            pattern = pattern * 3 % mod
            prev = 2

print(pattern)


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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
	cout << a << "\n";
}



int main(int argc, const char * argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	ll n,l;
	cin >> n >> l;
	ll min_val = l;
	ll max_val = l + n-1; 
	ll val=0;
	if((min_val * max_val > 0))
	{
		if(min_val > 0)
		{
			for(ll i=1;i<n;i++)
			{
				val+= l+i;
			}	
		}else
		{
			for(ll i=0;i<n-1;i++)
			{
				val+= l+i;	
			}
		}

	}else{
		for(ll i=0; i<n;i++)
		{
			val+=l+i;
		}
	}
	cout << val << endl;



}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;

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


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

  int tmp = b - a;


  int height = 1;
  int prevheight = 0;

  for(int i = 2; (height - prevheight) < tmp; ++i){
    prevheight = height;
    height += i;
  }
  cout << height - b << endl;
}


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

using namespace std;

int main()
{
    //system("chcp 65001");

    int N,K;
    string S;

    cin >> N >> K;
    cin >> S;

    if(S[K-1] == 'A')
    {
        S[K-1] = 'a';
    }
    else if(S[K-1] == 'B')
    {
        S[K-1] = 'b';
    }
    else
    {
        S[K-1] = 'c';
    }

    cout << S;
    

    return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const int INF=1e9;

int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int main()
{
    int h,w,k;
    cin>>h>>w>>k;
    /*int inj=0;
    if(h==800&&w==800&&400<=k)
    {
        inj=1;
    }
    else
        return 0;*/

    vector<vector<int>> m(w,vector<int>(h)),d(w,vector<int>(h,-1));
    int sx,sy;
    REP(j,h)
    {
        string s;
        cin>>s;
        REP(i,w)
        {
            if(s[i]=='#')
                m[i][j]=1;
            else if(s[i]=='S')
            {
                sx=i;sy=j;
                m[i][j]=0;
            }
            else
                m[i][j]=0;
        }
    }
    using tiii=tuple<int,int,int>;
    queue<tiii> q;
    q.push(tiii(sx,sy,k));
    while(!q.empty())
    {
        int x,y,p;
        tie(x,y,p)=q.front();
        q.pop();

        if(p<=d[x][y]) continue;
        if(m[x][y]==1)  continue;
        d[x][y]=p;
        if(p==0)    continue;
        REP(i,4)
        {
            int px=x+dx[i],py=y+dy[i];
            if(0<=px&&px<w&&0<=py&&py<h)
                q.push(tiii(px,py,p-1));
        }
    }


    if(sx==0||sy==0||sx==w-1||sy==h-1)
    {
        cout<<0<<endl;
        return -1;
    }

    int ans=INF;
    REP(j,h)
    {
        REP(i,w)
        {
            //cout<<d[i][j];
            if(d[i][j]>-1)
            {
                int nx=min(i,w-i-1);
                int ny=min(j,h-j-1);

                ans=min(ans, min(nx,ny));
                //cout<<min(nx,ny);
            }
            //else
            //cout<<'*';
        }
        //cout<<endl;
    }
    
    int aans=(ans+k-1)/k;
    //cout<<ans<<endl;
    cout<<aans+1<<endl;
}


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

int main() {
	int A, B, K;
	cin >> A >> B >> K;
	for (int i = 0; i < K; ++i) {
		if (0 ==i%2) {
			if (1 == A%2) {
				A--;
			}
			A /= 2;
			B += A;
		}
		else {
			if (1 == B % 2) {
				B--;
			}
			B /= 2;
			A += B;
		}
	}
	cout << A <<" "<<B  <<  endl;
	return 0;
}

Measured memory_bytes: 3556
n = int(input())
s = [input() for i in range(n)]
s.sort()

poll = []
count = []
pre_poll = ''
for i in range(n):
    if pre_poll == s[i]:
        count[-1] += 1
    else:
        poll.append(s[i])
        count.append(1)
        pre_poll = s[i]
        
poll_dict = dict(zip(poll, count))
poll_dict = dict(sorted(poll_dict.items(), key=lambda x:x[1], reverse=True))

val = next(iter(poll_dict.values()))
for t in poll_dict.items():
    if val == t[1]:
        print(t[0])
    else:
        break

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

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

    vector<int> ans(10000 + 1, 0);
    rep (i, 100)
        rep (j, 100)
            rep (k, 100)
            {
                int temp = i * i + j * j + k * k + i * j + j * k + k * i;
                if (temp <= 10000)
                    ans[temp]++;
            }

    rep (i, n)
        cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 3532
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 noTaxAmin = a * 100 % 8 == 0 ? a * 100 / 8 : a * 100 / 8 + 1;
        int noTaxAmax = (a + 1) * 100 % 8 == 0 ? (a + 1) * 100 / 8 - 1 : (a + 1) * 100 / 8;
        int noTaxBmin = b * 100 % 10 == 0 ? b * 100 / 10 : b * 100 / 10 + 1;
        int noTaxBmax = (b + 1) * 100 % 10 == 0 ? (b + 1) * 100 / 10 - 1 : (b + 1) * 100 / 10;
        if (noTaxAmin <= noTaxBmax && noTaxBmin <= noTaxAmax) {
            System.out.println(Math.max(noTaxAmin, noTaxBmin));

        }else {
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a, b;
    cin >> a >> b;

    int size = b.size();
    string bb = b.substr(0, size - 1);

    if (bb == a) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
inline int inv(int x){
	return modpow(x,mod-2,mod);
}
inline int C(int x,int y){
	int ret=1;
	for(int i=x;i>x-y;i--)ret=((ll)ret*i)%mod;
	for(int i=y;i>=1;i--)ret=((ll)ret*inv(i))%mod;
	return ret;
}
int n,m,k;
int ans,ans1,ans2,mul;
int main(){
	cin>>n>>m>>k;
	mul=C(n*m-2,k-2);
	for(int i=1;i<m;i++){
		ans1=(ans1+(ll)i*(m-i)%mod)%mod;
	}
	ans1=(ll)ans1*n%mod*n%mod;
	for(int i=1;i<n;i++){
		ans2=(ans2+(ll)i*(n-i)%mod)%mod;
	}
	ans2=(ll)ans2*m%mod*m%mod;
	ans=(ans1+ans2)%mod;
	cerr<<ans<<" "<<mul<<endl;
	ans=(ll)ans*mul%mod;
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  ll n,dis=0; cin>>n;
  vector<ll> a(n+2),d(n+1);
  a[0] = 0; a[n+1] = 0;
  for(int i=1; i<=n+1; i++) {
    cin>>a[i];
    d[i] = abs(a[i]-a[i-1]);
    dis += d[i];
  }
  for(int i=1; i<=n; i++) {
    cout<<dis+abs(a[i-1]-a[i+1])-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1]))<<"\n";
  }
}

Measured memory_bytes: 2816
#include <stdio.h>

int main() {
    int i, k, m, n = 0;
    int h[100], w[100];
    while(1) {
        scanf("%d %d", &h[n], &w[n]);
        if(h[n] == 0 && w[n] == 0) break;
        n++;
    }
    for(i = 0; i < n; i++) {
        for(k = 0; k < h[i]; k++) {
            for(m = 0; m < w[i]; m++) {
                if(k == 0 || k == h[i] - 1) printf("#");
                else if(m == 0 || m == w[i] - 1) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

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

int main(){
  int a, b;
  std::cin >> a >> b;
  std::string c = std::to_string(a);
  std::string d = std::to_string(b);
  int e = std::stoi(c + d);
  float f = sqrt(e);
  int g = f;
  if(f == g){
  	  std::cout << "Yes" << std::endl;
  }else{
  	  std::cout << "No" << std::endl;
  }
  return 0;
}


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

int main() {
  int a, b; cin >> a >> b;
  if (a == 1) a = 14;
  if (b == 1) b = 14;
  if (a > b) cout << "Alice";
  else if (a == b) cout << "Draw";
  else cout << "Bob";
  cout << endl;
}

Measured memory_bytes: 768
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }
  vector<vector<int> > dp(n, vector<int>(3));
  dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
  for (int i = 1; i < n; ++i) {
    dp[i][0] = max(dp[i][0], max(dp[i - 1][1], dp[i - 1][2]) + a[i]);
    dp[i][1] = max(dp[i][1], max(dp[i - 1][0], dp[i - 1][2]) + b[i]);
    dp[i][2] = max(dp[i][2], max(dp[i - 1][0], dp[i - 1][1]) + c[i]);
  }
  cout << max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]) << endl;
  return 0;
}

Measured memory_bytes: 9852
#include<iostream>
#include<string>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define minimize(a,b) (a>(b)?a=(b),1:0)
#define maximize(a,b) (a<(b)?a=(b),1:0)
#define ceil(a,b) (((a)+(b)-1)/(b))
#define yn(i) print((i)?"Yes":"No")
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define abs(n) max((n),-(n))
#define dist(a,b) max((a)-(b),(b)-(a))
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }




string key="keyence";

void add(char m,string s,set<string> st){
  int n=s.size();
  rep(i,n){
    if(s[i]!=m) continue;
    string t;
    repa(j,i,n){
      t.push_back(s[j]);
      st.insert(t);
    }
  }
}

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

int legal(string s,string t,int k){
  int n=s.size();
  repa(i,k,n){
    if(s[i]!=t[i-k]) return 0;
  }
  return 1;
}

string merge(string s,string t,int k){
  int n=s.size();
  string ret;
  rep(i,k) ret.push_back(s[i]);
  rep(i,n) ret.push_back(t[i]);
  return ret;
}


int main(){
  li n,h; cin >>n >>h; 
  vector<li> a(n),b(n);
  rep(i,n){
    li x,y; cin >>x >>y;
    a[i]=x; b[i]=y;
  }
  sort(a.begin(),a.end()); reverse(a.begin(),a.end());
  sort(b.begin(),b.end()); reverse(b.begin(),b.end());
  li cnt=0;
  li s=0;
  int i=0;
  while((i<n) and (a[0]<b[i])){
    s+=b[i]; cnt++;
    if(s>=h) break;
    i++;
  }
  if(s<h) cnt+=ceil((h-s),a[0]);
  print(cnt);
}





Measured memory_bytes: 4760
N = int(input())

if 200 >= N >= 195:
    print(5)
if 195 > N >= 189:
    print(4)
if 189 > N >= 165:
    print(3)
if 165 > N >= 135:
    print(2)
if 135 > N >= 105:
    print(1)
if N < 105:
    print(0)


Measured memory_bytes: 2940
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    n = I()
    s = S()
    d = defaultdict(int)
    for i in s:
        d[i] += 1
    ans = 1
    for i in d.keys():
        ans *= d[i]+1
        ans %= mod
    print(ans-1)
#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 51056
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n;
  float ans;
  scanf("%d",&n);
  if(n%2==0){
    printf("0.5\n");
  }
  else{
    ans=(n+1)/2;
    ans=ans/n;
    printf("%f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
int N,K;
typedef long long ll;

const ll M = 1000000007;
ll be[1001];
vector<ll> fac(500001); //n!(mod M)
vector<ll> ifac(500001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main()
{
    ll n,k;
    cin >> n >> k;

    //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<500000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }


    ll ans=0;
    if(k>=n-1){
        ans = comb(2*n-1,n-1);
    } else {
        for (int i = 0;i<k+1;i++){
            ans = (ans +(comb(n,i) * comb(n-1,i)% 1000000007))%1000000007;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 8064
#include<iostream>
#include<cmath>
using namespace std;
#define KMAX 30
#define VMAX 1000000

int K[KMAX];
unsigned char T[KMAX][VMAX+1];

void eratos ( int n, bool prime[]){
    for ( int i = 0; i <= n; i++ ) prime[i] = false;
    for ( int i = 3; i <= n; i += 2 ) prime[i] = true;
    prime[2] = true;
    int limit = (int)sqrt((double)n) + 1;
    for ( int i = 3; i <= limit; i += 2 ){
	if ( !prime[i] ) continue;
	for ( int j = i + i; j <= n; j += i ) prime[j] = false;
    }
}
main(){
    bool prime[VMAX + 1];
    eratos( VMAX, prime );

    int k, v;
    while( cin >> k >> v && k && v ){
	for ( int i = 0; i < k; i++ ) cin >> K[i];
	
	for ( int j = 0; j <= v; j++ ) T[0][j] = 0;
	for ( int j = K[0]; j <= v; j += K[0] ) T[0][j] = 1;

	for ( int i = 0; i < k; i++ ) T[i][0] = 1;
	for ( int i = 1; i < k; i++ ){
	    for ( int j = 1; j < K[i]; j++ ) T[i][j] = T[i-1][j];
	    for ( int j = K[i]; j <= v; j++ ){
		T[i][j] = (T[i-1][j] | T[i][j-K[i]]);
	    }
	}
	int ans = -1;
	for ( int i = v; i >= 2; i-- ){
	    if ( prime[i] && T[k-1][i] ) { ans = i; break; }
	}
	
	if ( ans == -1 ) cout << "NA" << endl;
	else cout << ans << endl;
    }
}

Measured memory_bytes: 30000
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <stdio.h>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORa(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FORr(i,m,n) for(ll i=n-1; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define FORs(i,st) for(auto i : st)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> v(n);
    FOR(i,0,n){
      cin>>v[i];
    }

    vector<ll> flag(n,1);
    vector<ll> used(n);
    deque<ll> ans;
    FOR(k,0,n){
      FORr(i,0,n){
        if(used[i])continue;
        if(flag[i]>=v[i]){
          ans.push_back(v[i]);
          used[i] = 1;
          FORr(j,i,n){
            flag[j]++;
          }
          break;
        }
      }
    }
    if(ans.size() == n){
      while(!ans.empty()){
        cout<<ans.front()<<endl;
        ans.pop_front();
      }
    }
    else cout<<-1<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#define MOD 1000000007
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int judge(int n) {
    int t = sqrt(n);
    if(t*t == n)return 1;
    else return 0;
}

int main()
{
    int n, d, i,j,k,ans=0, x[10][10];
    scanf("%d%d",&n,&d);
    for(i=0; i<n; i++) {
        for(j=0; j<d; j++) {
            scanf("%d",&x[i][j]);
        }
    }
    for(i=0; i<n; i++) {
        for(j=i+1; j<n; j++) {
            int sum = 0;
            for(k=0; k<d; k++) {
                //printf("%d %d %d\n",i,j,k);
                int t = x[i][k] - x[j][k];
                sum += t*t;
            }
            ans += judge(sum);
        }
    }
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 128
def commands(sx, sy, tx, ty):
    ans = ""
    ans += "R" * max(0, tx - sx)
    ans += "L" * max(0, sx - tx)
    ans += "U" * max(0, ty - sy)
    ans += "D" * max(0, sy - ty)
    return ans


sx, sy, tx, ty = map(int, raw_input().split(" "))

res = ""
res += commands(sx, sy, tx, ty)
res += commands(tx, ty, sx, sy)
res += "D" + commands(sx, sy - 1, tx + 1, ty) + "L"
res += "U" + commands(tx, ty + 1, sx - 1, sy) + "R"

print res


Measured memory_bytes: 2692
import sys
from copy import copy
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

n = int(input())
a = list(map(int, input().split()))

graph = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    graph[u].append(v)
    graph[v].append(u)

ans = [0] * n
dp = [float('inf')] * n
dp[0] = a[0]


def dfs(v, v_p, dp_len):
    # print(v, v_p, dp)
    ans[v] = dp_len
    for v_next in graph[v]:
        if v_next == v_p:
            continue

        # print(dp)
        if a[v_next] > dp[dp_len - 1]:
            past = dp[dp_len]
            dp[dp_len] = a[v_next]
            dfs(v_next, v, dp_len + 1)
            dp[dp_len] = past
        else:
            idx = bisect_left(dp, a[v_next])
            # always idx < dp_len
            past = dp[idx]
            dp[idx] = a[v_next]
            dfs(v_next, v, dp_len)
            dp[idx] = past


dfs(0, -1, 1)
print(*ans, sep='\n')


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

int A[1000000], n;

int binarySearch(int key, int n, int A[]) {
  int i = 0;
  int j = n;
  int k;
  while ( i < j ) {
    k = (j + i)/2;
    // cout << key << " " << i << " " << k << " " << A[k] << " " << j << endl;
    if ( A[k] == key ) return 1;
    if ( A[k] > key ) j = k;
    else if ( A[k] < key ) i = k + 1;
  }
  return 0;
}


int main() {
  int n, q, k;
  scanf("%d", &n);
  // int A[n];
  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
  // cout << A[0];

  int ans = 0;
  scanf("%d", &q);
  // cout << q;
  for ( int i = 0; i < q; i++ ) {
    cin >> k;
    // scanf("%d", &k);
    // cout << k;
    if ( binarySearch(k, n, A) ) ans++;
  }
  printf("%d\n", ans);

  return 0;
}



Measured memory_bytes: 3532
#include <iostream>

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  int h[N];

  int i;
  for(i=0; i<N; i++)
    cin >> h[i];
  
  int count = 0;
  for(i=0; i<N; i++)
    if(K <= h[i])
      count++;

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int n; cin >>n;
  vector<int> P(n); rep(i, n) cin >>P[i];
  rep(i, n) P[i]--;
  bool sa = false;
  int res = 0;
  rep(i, n){
    if (i == P[i]){
      if (sa){
        res++; sa = false;
      }else sa = true;
    }else{
      if (sa){
        res++; sa = false;
      }
    }
  }
  if (sa) res++;

  cout <<res <<endl;
}


Measured memory_bytes: 640
s = list(input())

mod = 10**9 + 7

N = 13
dp = [0]*N
dp[0] = 1
mul = 1
for i in range(len(s)-1, -1, -1):
    nextDP = [0]*N
    if s[i] == '?':
        for k in range(10):
            for j in range(N):
                nextDP[(k*mul + j)%N] += dp[j]
                nextDP[(k*mul + j)%N] %= mod
    else:
        k = int(s[i])
        for j in range(N):
            nextDP[(k*mul + j)%N] += dp[j]
            nextDP[(k*mul + j)%N] %= mod

    mul = (mul*10)%N
    dp = nextDP

print(dp[5])

Measured memory_bytes: 50032
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion

N, M, X, Y = ri_()
x = ri_()
y = ri_()
ans = 'War'
for Z in range(-100, 101):
    if X < Z <= Y and max(x) < Z and min(y) >= Z:
        ans = 'No War'
print(ans)

Measured memory_bytes: 63340
#include <iostream>

using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"

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

  IN(N);
  IN(T);

  int before;
  cin >> before;
  ll ans = 0;
  FOR(i, 1, N) {
    int t;
    cin >> t;
    ans += min(t - before, T);
    before = t;
  }
  OUT(ans+T);

  return 0;
}


Measured memory_bytes: 256
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using uint = uint32_t;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

const int N = 2e5 + 25;
struct segtree {
	int arr[N << 1], tag[N], n;
	void init(int _n) {
		n = _n;
		for(int i = 0; i < n; i++)
			arr[i + n] = n, tag[i] = INF;
	}
	void upd(int p, int v) {
		if(p < n) 
			tag[p] = min(tag[p], v);
		else
			arr[p] = min(arr[p], v);
	}
	void push(int p) {
		for(int h = __lg(p); ~h; h--) {
			int i = p >> h;
			upd(i, tag[i >> 1]);
			upd(i ^ 1, tag[i >> 1]);
			tag[i >> 1] = INF;
		}
	}
	void edt(int l, int r, int v) {
		int tl = l + n, tr = r + n - 1;
		push(tl); push(tr);
		for(l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if(l & 1)
				upd(l++, v);
			if(r & 1)
				upd(--r, v);
		}
	}
	int operator[](int p) {
		push(p += n);
		return arr[p];
	}
} col, row;

signed main() {
	EmiliaMyWife

	int n, m;
	cin >> n >> m;
	ll ans = 1LL * (n - 2) * (n - 2);
	col.init(n); row.init(n);
	for(int i = 0, a, x; i < m; i++) {
		cin >> a >> x;
		if(a == 1) {
			int w = col[x];
			ans -= w - 2;
			row.edt(2, w, x);
		}
		else {
			int w = row[x];
			ans -= w - 2;
			col.edt(2, w, x);
		}
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 6756
#include<math.h>
c,i,p,P,f;main(n){float x[100],y[100],d,t,T;while(scanf("%d",&n),n){T=2000;for(i=0;i<n;i++){scanf("%f,%f",x+i,y+i);if(y[i]<T){T=y[i];p=f=i;}}c=n;d=0;do{T=9;for(i=0;i<n;i++){if(i!=p){t=atan2f(y[i]-y[p],x[i]-x[p])-d;while(t<0)t+=2*M_PI;if(t<T){T=t;P=i;}}}p=P;d+=T;c--;}while(p!=f);printf("%d\n",c);}exit(0);}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int a,b,k; cin >> a >> b >> k;
	if (k*2 - 2 >= b-a){
		for(int i = a; i <= b; i++){
			cout << i << endl;
		}
	}else{
		for(int i = a; i < a+k; i++){
			cout << i << endl;
		}
		for (int i = b-k+1; i <= b; i++){
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  while (true) {
    int n; cin >> n;
    if (n == 0) break;
    V<> a(n); for (int i = 0; i < n; ++i) cin >> a[i];
    sort(begin(a), end(a));
    int res = accumulate(next(begin(a)), prev(end(a)), 0) / (n - 2);
    cout << res << '\n';
  }
}


Measured memory_bytes: 3088
#include <cstdio>
long long n, k, s, mx, x, a[100005], b[100005];
int main() {
	int i, j;
	scanf("%lld%lld", &n, &k);
	for(i=0; i<n; i++) scanf("%lld%lld", a+i, b+i);
	k++;
	for(i=30; i>=0; i--) {
		if(k>>i & 1) {
			x ^= 1<<i;
			for(j=s=0; j<n; j++) {
				if(!(a[j]&x)) s += b[j];
			}
			if(s>mx) mx = s;
		}
		x ^= 1<<i;
	}
	printf("%lld", mx);
	return 0;
}

Measured memory_bytes: 1664
n,l = map(int,input().split())
aji = []
for i in range(n):
    aji.append(l+i)
ap = sum(aji)
salist = []
salist2 = []
for j in range(len(aji)):
    ap2 = ap-aji[j]
    salist.append(ap2)
# print(salist)
for l in range(len(salist)):
    sa = abs(ap-salist[l])
    salist2.append(sa)
print(salist[salist2.index(min(salist2))])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


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


signed main(){
  int m,k;cin>>m>>k;
  if(powl(2,m) <= (double)k){
    cout << -1 << endl;return 0;
  }else if(m == 0){
    cout << "0 0" << endl;return 0;
  }else if(m == 1){
    if(k == 0)cout << "0 0 1 1" << endl;
    else cout << -1 << endl;
    return 0;
  }else{
    cout << k << " ";
    rep(i,pow(2,m)){
      if(i == k)continue;
      cout << i << " ";
    }
    cout << k << " ";
    for(int i = powl(2,m)-1;i >= 0;i--){
      if(i == k)continue;
      cout << i << (i == 0 ? "\n" : " ");
    }
  }
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int s[N];
  int sum = 0;
  for (int i = 0; i < N; i++) cin >> s[i], sum += s[i];
  sort(s, s + N);
  if (sum % 10 == 0) {
    for (int i = 0; i < N; i++)
      if (s[i] % 10 != 0) {
        sum -= s[i];
        break;
      }
  }
  if (sum % 10 == 0) sum = 0;
  cout << sum << '\n';
  return 0;
}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a'|| c == 'i'||c == 'u'||c == 'e'||c == 'o'){
  cout << "vowel" << endl; 
  }else {
  cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3580
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;

typedef long long LL;
typedef long double LD;

int main(void){
    int n;
    string s;
    cin >> n >> s;
    LL red = 0, green = 0, blue = 0; 
    for(int i = 0;i < n; i++){
        if(s[i] == 'R')red++;
        else if(s[i] == 'G')green++;
        else if(s[i] == 'B')blue++;
    }
    LL ans = red * green * blue;
    int k;
    for(int i = 1; i <= n; i++){
        for(int k = i + 2; k <= n; k += 2){
            int j = (i + k) / 2;
            if(s[i - 1] + s[j - 1] + s[k -1 ]  == 'R' + 'G' + 'B'){
                ans--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S, add[2];
	int Q;
	cin >> S >> Q;
	int side = 0;
	for (int i = 0; i < Q; i++) {
		int T; cin >> T;
		if (T == 1) {
			side = (side + 1) % 2;
		}
		else {
			int F;
			char C;
			cin >> F >> C;
			if (F == 1) {
				add[side] += C;
			}
			else {
				add[(side + 1) % 2] += C;
			}
		}
	}
	if (side == 0) {
		reverse(add[0].begin(), add[0].end());
		cout << add[0] << S << add[1] << endl;
	}
	else {
		reverse(S.begin(), S.end());
		reverse(add[1].begin(), add[1].end());
		cout << add[1] << S << add[0] << endl;
	}
}


Measured memory_bytes: 1088
def istrue(s):
	for a, b in zip(s, reversed(s)):
		if a != b:
			return False
	return True


s = input()
fl = (len(s)-1)/2
el = (len(s)+3)/2-1
f = s[0:int(fl)]
e = s[int(el):len(s)]

if istrue(s) is False:
	print("No")
	exit()
if istrue(f) is False:
	print("No")
	exit()
if istrue(e) is False:
	print("No")
	exit()
print("Yes")

Measured memory_bytes: 3064
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
const ll mod = 1000000007;
const ll mod9 = 1000000009;

signed main(){
    ll n;
    cin>>n;
    ll ans=0;
    ll k;
    rep(i,n){
        k = n/(i+1);
        ans += (1+k)*k/2 * (i+1);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3620
import java.util.Scanner;

class Main{
    int x,y;
        
    public void solve(){
        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        y = x * x * x;
        System.out.println(y);
        
    }
    
    
    public static void main(String[] args){
        
        new Main().solve();
                
    }
    


}

Measured memory_bytes: 17156
def main():
    n,m = map(int, input().split())
    a = list(map(int,input().strip().split()))
    t = sum(a)
    c = 0
    for aa in a:
        if aa >= t / (4*m):
            c += 1
    if c >= m:
        print("Yes")
        return 
    else:
        print("No")
        return
main()


Measured memory_bytes: 9128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int M = (1 << N);
    long A[M];
    pair<long, long> maximum[N + 1][M];
    for(int i = 0; i < M; i++){
        cin >> A[i];
        maximum[0][i] = {A[i], 0};
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            if(j & (1 << i)){
                long nums[4] = {maximum[i][j].first, maximum[i][j].second, maximum[i][j & ~(1 << i)].first, maximum[i][j & ~(1 << i)].second};
                sort(nums, nums + 4, greater<long>());
                maximum[i + 1][j] = {nums[0], nums[1]};
            }else{
                maximum[i + 1][j] = maximum[i][j];
            }
        }
    }
    for(int i = 1; i < M; i++){
        long ans = maximum[N][i].first + maximum[N][i].second;
        for(int j = 0; j < N; j++){
            if(i & (1 << j)){
                int this_pattern = ((i & ~(1 << j)) | ((1 << j) - 1));
                ans = max(ans, maximum[N][this_pattern].first + maximum[N][this_pattern].second);
            }
        }
        printf("%ld\n", ans);
    }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int count;

    for(int i=0; i<n; i++){
        if(p[i] == i+1){
            swap(p[i],p[i+1]);
            count ++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,x,m; cin >> n >> x >> m;
    map<ll,ll> mp;
    vector<ll> v;
    ll cnt = 0;
    while(mp.count(x) == 0){
        v.pb(x);
        mp[x] = cnt;
        cnt++;
        x = (x*x) % m;
    }
    ll start = mp[x];
    ll T = cnt - start;

    ll ans = 0;
    if(n <= start){
        rep(i,0,n) ans += v[i];
        cout << ans << endl;
        return 0;
    }

    rep(i,0,start) ans += v[i];
    n -= start;

    ll sumT = 0;
    rep(i,0,T) sumT += v[start+i];

    ans += n/T * sumT;

    n %= T;

    rep(i,0,n) ans += v[start+i];

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6740
N,M,X,Y = [int(i) for i in input().split()]
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]

x_max=max(x)+1
y_min=min(y)+1

flg=True

for z in range(x_max,y_min):
    if X<z<=Y:
        flg=False
        break
print("War" if flg else "No War")

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main()
{
    int H,W; cin >>H>>W;
    vs grid(H); cin >> grid;
    // rep(i,H)cout<<grid[i]<<endl;

    vector<vs> ans(2, vs(grid)); 

    rep(h, H) {
        rep(w, W) {
            if (grid[h][w]=='#') continue;
            if (w == 0) {
                ans[0][h][w]='#';
            } else if (w==W-1) {
                ans[1][h][w]='#';
            } else {
                ans[h%2][h][w]='#';
            }
        }
    }

    rep(i,2) {
        rep(j,H) cout<<ans[i][j]<<endl;
        cout<<endl;
    }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;

int n,b;
double d,p[10],h[10];
main()
{
  cin>>d>>n>>b;
  for(int i=0;i<n;i++)cin>>p[i]>>h[i];
  double ans=1e300;
  for(int i=0;i<=b;i++)
  {
    double c=d/2/(i+1);
    double L=1e-15,R=1e15;
    for(int cnt=0;cnt<100;cnt++)
    {
      double vy=(L+R)/2;
      bool flag=1;
      for(int j=0;j<n;j++)
      {
        double now=p[j];
        while(now>=c*2)now-=c*2;
        if(now*vy*vy/c-now*now*vy*vy/2/c/c<h[j])
        {
          flag=0;
          break;
        }
      }
      (flag?R:L)=vy;
    }
    double vy=max(R,sqrt(c));
    ans=min(ans,hypot(vy,c/vy));
  }
  cout<<fixed<<setprecision(9)<<ans<<endl;
}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=998244353;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}
int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}
const int FACT_SIZE=1111111;
int fact[FACT_SIZE];
int inv[FACT_SIZE];
struct fact_exec{
    fact_exec(){
        fact[0]=1;
        for(int i=1;i<FACT_SIZE;i++)fact[i]=fact[i-1]*i%mod;
        inv[FACT_SIZE-1]=mpow(fact[FACT_SIZE-1],mod-2);
        for(int i=FACT_SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    }
}factexec;
int nCk(int n,int k){
    return fact[n]*inv[k]%mod*inv[n-k]%mod;
}
int nPk(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*inv[n-k]%mod;
}

signed main(){
    int N,K;
    cin>>N>>K;

    int ans=0;
    for(int a=N;a<=K;a++){
        int b=K-a;

        if(a<b)continue;

        if(a-b>=N){
            add(ans,nCk(K,a));
            continue;
        }

        int k=N-(a-b);




        if(a==b){
            b--;k--;
        }

        int tmp=nCk(a+b,a);

        int m=b-k+1;
        tmp=(tmp-nCk(a+b,a+m)+mod)%mod;
        ans=(ans+tmp)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 17664