akhauriyash/Code-Regression huggingface dataset:
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;


void calc() {

	Int N, X, Y; std::cin >> N >> X >> Y;
	std::vector<std::vector<Int>> graph(N);
	rep(i, N - 1) {
		graph[i].push_back(i + 1);
		graph[i + 1].push_back(i);
	}
	graph[X - 1].push_back(Y - 1);
	graph[Y - 1].push_back(X - 1);
	//std::vector<Int> dist(N, -1);
	//std::map<Int, Int> m; //[距離, 個数]
	//dist[0] = 0;
	//
	//std::queue<Int> q; q.push(0);
	//while (!q.empty()) {
	//	Int n = q.front(); q.pop();
	//	for (const auto& elem : graph[n]) {
	//		if (dist[elem] == -1) {
	//			dist[elem] = dist[n] + 1;
	//			m[dist[elem]]++;
	//			q.push(elem);
	//		}
	//	}
	//}
	//
	//for (Int k = 1; k < N; ++k) {
	//	Int ans = 0;
	//	for (Int num = 0; num < N; ++num) {
	//		Int d = k + dist[num];
	//		ans += m[d];
	//	}
	//	std::cout << ans << "\n";
	//}
	std::map<Int, Int> m;
	for (Int i = 0; i < N; ++i)for (Int j = 0; j < N; ++j) {
		if (i == j)continue;
		std::queue<Int> q; q.push(i);

	}

	rep(i, N) {
		std::queue<Int> q; q.push(i);
		std::vector<Int> dist(N, -1); dist[i] = 0;
		while (!q.empty()) {
			Int num = q.front(); q.pop();
			for (const auto& elem : graph[num]) {
				if (dist[elem] == -1) {
					dist[elem] = dist[num] + 1;
					m[dist[elem]]++;
					q.push(elem);
				}
			}
		}
	}

	for (Int i = 1; i < N; ++i) {
		std::cout << m[i] / 2 << std::endl;
	}

}


int main() {

	calc();

	return 0;
}

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

int main() {
	int d;
	vector<int> c(26);
	
	cin >> d;
	vector<vector<ll>> s(d,vector<ll>(26));
	vector<ll> sumd(26,0);

	ll sum=0;
	rep(i,26){
		cin >> c[i];
	}
	rep(i,d){
		rep(j,26){
			cin >> s[i][j];
		}
	}
	vector<ll> ans(d);
	ll a,x=0;

	rep(i,d){
		cin >> a;
		x += s[i][a-1];
		rep(j,26){
			if(j == a-1){
				sumd[j] = 0;
			}
			else{
				sumd[j] += c[j];
			}
			sum += sumd[j];
		}
		ans[i] = x - sum;
	}
	
	rep(i,d){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<algorithm>
using namespace std;
int x,y,ans=10000000000;
int main()
{
    cin>>x>>y;
    if(x==y){cout<<0<<endl;return 0;}
    if(y>x)ans=min(y-x,abs(y+x)+1);
    else ans=min(abs(x+y)+1,2+abs(x-y));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod=1000000007;
ll N;
ll A[1000005];
ll comb[1000005];
ll modpow(ll x,ll y){
if(y==0)
  return 1;
  else if(y%2==0){
    ll z=modpow(x,y/2);
    return (z*z)%mod;
  }
  else{
  ll z=modpow(x,y/2);
    return (x*((z*z)%mod))%mod;
  }
}
int main(){
  cin>>N;
  A[0]=1;
  for(ll i=1;i<=N;i++)
    A[i]=(A[i-1]*i)%mod;
  comb[0]=1;
  for(ll i=1;i<=N;i++){
  ll a=((N-2*i)*comb[i-1])%mod;
    a=(a*(N-2*i-1))%mod;
    ll b=(i*(N-i-1))%mod;
    b=modpow(b,mod-2);
    comb[i]=(a*b)%mod;
   }ll ans=((N-1)*A[N-1])%mod;
  for(ll i=1;i<=N-1;i++){
  ll b=(((A[i-1]*A[N-i])%mod)*comb[N-i])%mod;
    ans=(ans+mod-b)%mod;
  }cout<<ans<<endl;
    
  return 0;
}

Measured memory_bytes: 19228
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;

/**
 * main
 */
int main () {
  ll a; cin >> a;
  ll b; cin >> b;
  ll c; cin >> c;

  ll lh = 4 * a * b;
  ll rh = a * a + b * b + c * c + 2 * (a * b - b * c - c * a);

  if (c- a - b <= 0) {
    cout << "No" << endl;
  } else {
    cout << (lh < rh ? "Yes" : "No") << endl;
  }
}


Measured memory_bytes: 256
N=gets.strip.to_i
a=[]
(0..N-1).each do |i|
  a[i]=gets.strip.to_i
end
ans=0
c=0
a.each do |v|
  t=(c+v)/2
  ans+=t
  if v==0
    c=0
  else
    c=(c+v)%2
  end
end

puts ans

Measured memory_bytes: 2632
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
int64 f(int64 n) {
	return (n * (n + 1) / 2);
}

void solve() {
	int64 N; cin >> N;
	int64 ans = 0;
	for (int64 i = 1; i <= N; ++i) {
		ans += (i * f(N / i));
	}
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

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

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

    if (a - b >= 0) {
        cout << "delicious" << endl;
    }
    else if (b - a <= x) {
        cout << "safe" << endl;
    }
    else {
        cout << "dangerous" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

vector<pii> pos;

long double dist(pii x, pii y) {
  long double ret = 0;
  ret = (x.first - y.first) * (x.first - y.first) +
        (x.second - y.second) * (x.second - y.second);
  ret = sqrt(ret);
  return ret;
}

// vector<int> visited(30);
long double dfs(int now, int visited, double dis) {
  // debug2(now, visited);
  if (now != -1) visited |= 1 << now;

  bool flag = true;
  rep(i, 0, N - 1) {
    if (visited >> i & 1) {
    } else {
      flag = false;
    }
  }
  if (flag) {
    return dis;
  }

  long double ret = 0;
  rep(i, 0, N - 1) {
    if (i == now) continue;
    if (((visited >> i) & 1) == 0) {
      ret += dfs(i, visited, dis + dist(pos[now], pos[i]));
    }
  }
  // debug(ret);
  return ret;
}

void input() {
  ;
  cin >> N;
  int a, b;
  rep(i, 0, N - 1) {
    cin >> a >> b;
    pos.push_back(pii(a, b));
  }

  ;
}
void solve() {
  long double ans = 0;
  rep(i, 0, N - 1) { ans += dfs(i, 0, 0); };

  int r = 1;
  rep(i, 1, N) { r *= i; }
  long double aa = ans / r;
  cout << setprecision(20) << aa << endl;

  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
def n_nimotsu_if_P(P, k, arr):
	weight = 0
	n_trucks = 1
	for i, a in enumerate(arr):
		if P < a:
			return i
		if weight + a <= P:
			weight += a
		else:
			n_trucks += 1
			weight = a
		if n_trucks == k + 1:
			return i

	return len(arr)

n, k = map(int, input().split())
luggages = []
for _ in range(n):
	luggages.append(int(input()))

left, right = 0, 10000 * n
i_break = 0
while right - left > 1:
	mid = (left + right) // 2
	if n <= n_nimotsu_if_P(mid, k, luggages):
		right = mid
	else:
		left = mid

print(right)


Measured memory_bytes: 9560
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

int main()
{
  int N;
  cin >>N;
  double x1,y1,x2,y2,x3,y3;
  for(int i = 0;i < N;i++){
    cin >>x1>>y1>>x2>>y2>>x3>>y3;
    double a =(x1-x2);
    double b =(y1-y2);
    double c = -(pow(x1,2)+pow(y1,2))+(pow(x2,2)+pow(y2,2));
    double d =(x2-x3);
    double e =(y2-y3);
    double f =-(pow(x2,2)+pow(y2,2))+(pow(x3,2)+pow(y3,2));
    double l =(c*e-f*b)/(a*e-d*b);
    double m =(c*d-a*f)/(b*d-a*e);
    double n = -(pow(x1,2)+pow(y1,2))-(l*x1+m*y1);
    double x = -l/2;
   
    double y =-m/2;
   
    double r =(sqrt(pow(l,2)+pow(m,2)-4*n))/2.0;
    printf("%.3f %.3f %.3f\n",x,y,r);
  }
  
  return 0;
}

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

int main(){
    int i,flag=0,j,n; scanf("%d", &n);
    char s[n + 5],ara1[n],ara2[n];
    scanf("%s", s);
    int len=strlen(s),k=0;
    if(n%2 != 0) puts("No");
    else{

        for(i=0;i<(len/2);i++)
        {
            ara1[i]=s[i];
        }
        ara1[i]='\0';
        for(j=i;j<len;j++)
        {
            ara2[k]=s[j];
            k++;
        }
        ara2[k]='\0';
        for(i=0;i<(len/2);i++)
        {
            if(ara1[i]!=ara2[i])
            {
                        flag=1;
            }
        }
        if(flag==1)
            printf("No\n");
        if(flag==0)

            printf("Yes\n");


    }
//    printf("%s\n%s\n",ara1,ara2);

    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
const int N = 2e5 + 10;
 
int main(){
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> b[i];
  }
  a[0] = b[0];
  for (int i = 1; i < n - 1; i++) {
    a[i] = min(b[i], b[i - 1]);
  }
  a[n - 1] = b[n - 2];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <numeric>
#include <iostream>
#include <algorithm>
#include <vector>

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

    std::vector< int > as(n);
    for (auto &a: as) std::cin >> a;

    std::cout << *min_element(as.begin(), as.end()) << " " << *max_element(as.begin(), as.end()) << " " << accumulate(as.begin(), as.end(), 0ll) << std::endl;
}



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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
//const int INF = INT_MAX  ;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;

typedef tuple<ll, int, int, int> PC;

int dp[101][4][4][4];

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

    dp[0][3][3][3] = 1;

    rep(len, n) {
        rep(c1, 4) {
            rep(c2, 4) {
                rep(c3, 4) {
                    if (dp[len][c1][c2][c3] == 0) {
                        continue;
                    }

                    for (int a = 0; a < 4; a++) {
                        if (a == 2 && c1 == 1 && c2 == 0) continue;
                        if (a == 2 && c1 == 0 && c2 == 1) continue;
                        if (a == 1 && c1 == 2 && c2 == 0) continue;
                        if (a == 2 && c1 == 1 && c3 == 0) continue;
                        if (a == 2 && c2 == 1 && c3 == 0) continue;

                        dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3];
                        dp[len + 1][a][c1][c2] %= mod;
                    }

                }
            }
        }
    }

    int ans = 0;
    rep(c1, 4) {
        rep(c2, 4) {
            rep(c3, 4) {
                ans += dp[n][c1][c2][c3];
                ans %= mod;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		String t = scan.next();
		int a = s.length();
		int b = t.length();
		char[] cs = new char[s.length()];
		for (int i = 0; i < s.length(); i++) {
			cs[i] = s.charAt(i);
		}
		Character[] ct = new Character[t.length()];
		for (int i = 0; i < t.length(); i++) {
			ct[i] = t.charAt(i);
		}
		Arrays.sort(cs);
		Arrays.sort(ct, Comparator.reverseOrder());
		boolean f = true;
		boolean same = true;
		for (int i = 0; i < Math.min(a, b); i++) {
			if (cs[i] > ct[i]) {
				f = false;
				same = false;
				break;
			}
			if (cs[i] < ct[i]) {
				same = false;
				break;
			}
		}
		if (same == true && a>=b) {
			f = false;
		}
		if (f) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> a(N);
  int x;
  int sum = 0;
  for(int i=0; i<N; i++){
    cin>>x;
    a.at(i)=x;
    sum+=x;
  }
  int b;
  if(sum%(4*M) == 0) b = sum/(4*M);
  else b = sum/(4*M)+1;
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  if(a.at(M-1)>=b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3552
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <iomanip>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<std::map<int, int>> cities_each_pref(N);

  rep(i, M)
  {
    int p, y;
    cin >> p >> y;
    p--;
    cities_each_pref[p][y] = i;
  }

  vector<string> cities(M);
  rep(i, N)
  {
    int pos = 1;
    for (auto it = cities_each_pref[i].begin(); it != cities_each_pref[i].end(); it++)
    {
      std::ostringstream oss;
      oss << std::setfill('0') << std::setw(6) << (i + 1);
      string p = oss.str();
      std::ostringstream oss2;
      oss2 << std::setfill('0') << std::setw(6) << pos;
      p += oss2.str();
      cities[it->second] = p;
      pos++;
    }
  }

  rep(i, M)
  {
    cout << cities[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 16384
local N, Q, _ = io.read("n", "n", "l")
local S_tmp = io.read("l")
local S = {}
for i=1,N do
    S[i] = string.sub(S_tmp, i, i)
end

local tbl = {}
tbl[0] = 0
local prev = '_'
for i=1,N do
    local c = S[i]
    if prev .. c == 'AC' then
        tbl[i] = tbl[i-1] + 1
    else
        tbl[i] = tbl[i-1]
    end
    prev = c
end

for i=1,Q do
    local l, r = io.read("n", "n")
    local count = tbl[r] - tbl[l]
    print(count)
end

Measured memory_bytes: 6704
#include<iostream>
#include<cstdlib>
#include<iomanip>
#include<cmath>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

int main()
{
	char c;
	cin >> c;
	cout << (char)(c + 1) << endl;
}

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

const int Nmax=710;
int n;
bool g[Nmax][Nmax];
int vis[Nmax];
void dfs(int v,int t,int (&d)[2]){
	if(vis[v]!=-1){
		if(vis[v]==t)return;
		cout<<-1<<endl;
		exit(0);
	}
	vis[v]=t;
	d[t]++;
	REP(i,n)if(g[v][i])
		dfs(i,t^1,d);
}
bool dp[Nmax];
int c2(int x){
	return x*(x-1)/2;
}

signed main(){
	n=read();
	int m=read();
	REP(i,n)REP(j,n)if(i!=j)g[i][j]=1;
	REP(_,m){
		int a=read()-1,b=read()-1;
		g[a][b]=0;
		g[b][a]=0;
	}
	ONE(vis);
	dp[0]=true;
	REP(i,n)if(vis[i]==-1){
		int d[2]{};
		dfs(i,0,d);
		for(int j=n;j>=0;j--){
			bool x=false;
			REP(k,2)if(j>=d[k])
				x|=dp[j-d[k]];
			dp[j]=x;
		}
	}
	int ans=inf;
	REP(i,n+1)if(dp[i])
		chmin(ans,c2(i)+c2(n-i));
	print(ans);
}


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

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}

	sort(s.begin(), s.end());

	int c = 0;
	long long int ans = 0;
	rep(i, n-1) {
		if (s[i] == s[i + 1]) {
			c++;
			ans += c;
		}
		else c = 0;
	}
	cout << ans << endl;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    string s;cin >> s;
    if(s == "ABC")
    {
        cout << "ARC" << endl;
    }else
    {
        cout << "ABC" << endl;
    }
}

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

int main() {
    int n, k; cin >> n >> k;
    map<int, int> a;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }
    vector<int> c;
    for (auto p : a) {
        c.push_back(p.second);
    }

    sort(c.begin(), c.end());
    int ans = 0;
    if (c.size() <= k) puts("0");
    else {
        for(int i = 0; i < c.size()-k; i++) {
            ans += c[i];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 10748
#include <iostream>
#include <vector>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	vector<int> num(n);
	for(int i=1;i<n;i++){
		int a; cin>>a; num[a-1]++;
	}
	for(int i=0;i<n;i++)cout<<num[i]<<'\n';
}


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

int main()
{
  const double PI=3.14159265359;
  double inp;
  cin >> inp;
  double en;
  double men;
  en = inp * inp * PI;
  men = 2 * inp * PI;
   cout << fixed << setprecision(5) << en << " " << men << endl;

}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
#ifndef LOCAL
#pragma GCC optimize(3)
#else
#endif
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

typedef long long ll;
const double eps=1e-6;
const int inf=0x3f3f3f3f;
const int maxn=1e5+100;

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif // LOCAL
    int a, b;
    cin >> a >> b;
    for (int i=max(-1000000, b-a+1); i<=min(1000000, b+a-1); i++) 
        cout << i << " ";
    return 0;
}

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

bool IsHashad(int n) {
  int d = 0;
  for (int m = n; m; m /= 10)
    d += m % 10;
  return n % d == 0;
}

int main() {
  int n;
  cin >> n;
  cout << (IsHashad(n) ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    l = LI()
    m = max(l)
    s = sum(l)
    if m * 2 < s:
        return 'Yes'

    return 'No'



print(main())




Measured memory_bytes: 5460
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<vector>
using namespace std;
int maxn;
string s[200005];
string st[200005];
int top;
int main()
{
	int n;
	cin>>n;
	for(int i=1; i<=n; i++)cin>>s[i];
	sort(s+1,s+n+1);
	int i;
	int w=1;
	int f=0;	
//	for(int i=1;i<=n;i++)cout<<s[i]<<endl;
//	cout<<endl;
	while(true)
	{
		string k=s[w];
		int sum=0;
		//	if(w>=n)break;
		//cout<<s[w]<<":";
	//	cout<<s[w]<<":";
		for(i=w; i<=n; i++)
		{
			if(s[i]==s[w])sum++;
			else
			{
				w=i;
				break;
			}
		}
	//	cout<<sum<<" "<<maxn<<" "<<top;
		if(sum==maxn)
		{
			st[++top]=k;
		//	cout<<" == "<<top<<endl;
		}
		else if(sum>maxn)
		{
			top=0;
			st[++top]=k;
			maxn=sum;
			//cout<<" > "<<top<<endl;
		}
	//	else cout<<" < "<<top<<endl;
		if(i>n)break;
		//if(w+1>n)break;
	}
	for(int i=1; i<=top; i++)cout<<st[i]<<endl;
}



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

int mod = 1e9+7;
int main(){
  string s;cin>>s;
  int k;cin>>k;
  vector< vector<int> > dp(k,vector<int>(2,0));
  dp[0][0] = 1;
  // mod and smaller 
  // smaller 
  // 0 equal 1 smaller
  
  for(int i=0;i<s.length();++i){
    vector< vector<int> > currDP(k,vector<int>(2,0));
    for(int m=0;m<k;++m){ 
      for(int n=0;n<2;++n){
        for(int j=0;j<10;++j){
          if(j>(s[i]-'0') && !(n==1)){
            break;
          }
          currDP[(m+j)%k][n||j<(s[i]-'0')] += dp[m][n];
          currDP[(m+j)%k][n||j<(s[i]-'0')] %= mod;
        }      
      }
    }
    /*
    for(auto i:currDP){
      for(auto j:i){
        cout<<j<<" ";
      }
      cout<<endl;
    }
    */
    dp = currDP;
  }
  
  int result = (dp[0][0]+dp[0][1])%mod;
  result--;
  
  if (result < 0){
    result = mod -1;
  }
  
  cout<<result<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  char str[64];
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}





Measured memory_bytes: 11916
#include <stdio.h>

int main(){
  char s[4];
  int b[100]={};
  for(int i=0;i<4;i++){
    scanf("%c",&s[i]);
  }
  
  int cast;
  for(int i=0;i<4;i++){
    cast = s[i];
    b[cast] += 1;
  }
  int count = 0;
  for(int i=65;i<91;i++){
    if(b[i] == 2){
      count += 1;
    }
  }
  if(count == 2){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
s = int(input())
s_list = [s,]

for i in range(2,1000001):
    if s%2 == 0:
        s = s//2
        s_list.append(s)
    else:
        s = s*3 + 1
        s_list.append(s)
    if s_list.count(s) == 2:
        print(i)
        break

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

const ll di[] = {-1, 0, 1, 0};
const ll dj[] = {0, -1, 0, 1};

vector<ll> load[100005];

typedef pair<ll,ll> Pair;

int main(){

    ll H, W;
    ll Ch, Cw;
    ll Dh, Dw;

    cin >> H >> W;
    cin >> Ch >> Cw;

    Ch--;Cw--;

    cin >> Dh >> Dw;

    Dh--;Dw--;

    vector<string> S(H);

    for (ll i = 0; i < H;++i)
        cin >> S[i];

    // 距離を求める配列
    vector<vector<ll>> dist(H, vector<ll>(W, INF));

    // ある地点から行けるマスを格納
    deque<Pair> q;

    // 初期値の距離はコスト0で初期化
    dist[Ch][Cw] = 0;

    // 左から初期値をキューに突っ込む
    q.emplace_back(Ch,Cw);

    while(!q.empty()){

        ll i = q.front().first;
        ll j = q.front().second;
        ll d = dist[i][j];
        q.pop_front();

        // コスト0で移動できる場所
        for (ll ii = 0; ii < 4;++ii){
          ll ni = i + di[ii];
          ll nj = j + dj[ii];

          if(nj < 0 ||  ni < 0 || ni >= H || nj >= W)
              continue;
          if (S[ni][nj] == '#')
              continue;
          if (dist[ni][nj] <= d)
              continue;
          dist[ni][nj] = d;
          q.emplace_front(ni,nj);
        }

        // コスト1で移動できる場所

        for (ll ei = -2; ei <= 2;++ei)
        {
            for (ll ej = -2; ej <= 2;++ej)
            {

                ll ni = i + ei;
                ll nj = j + ej;

                if(nj < 0 ||  ni < 0 || ni >= H || nj >= W)
                  continue;
                if (S[ni][nj] == '#')
                  continue;
                if (dist[ni][nj] <= d+1)
                  continue;

                dist[ni][nj] = d+1;
                q.emplace_back(ni,nj);

            }

        }

    }

if(dist[Dh][Dw] == INF)
    cout << "-1" << endl;
else 
    cout << dist[Dh][Dw] << endl;

    return 0;

}   


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

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

  vector<long long> f(10000010);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j*i <= n; j++) {
      f.at(j*i) += 1;
    }
  }

  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    ans += i * f.at(i);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  a -= u == s;
  b -= u == t;
  cout << a << ' ' << b << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  int n,k,x,y,ans=0;
  cin>>n>>k>>x>>y;
  if(n>k){
    ans+=k*x;
    ans+=(n-k)*y;
  }else{
    ans+=n*x;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private final static long MOD = (long) 1e9 + 7;

    public static void main( String[] args ) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        char[][] grid = new char[n][m];

        for (int i = 0; i < n; i++) {
            grid[i] = scanner.next().toCharArray();
        }

        Long[][] dp = new Long[n][m];

        System.out.println(recurse(0, 0, n, m, dp, grid));
    }

    private static long recurse( int row, int col, int n, int m, Long[][] dp, char[][] grid ) {
        if (row == n - 1 && col == m - 1)
            return 1;

        if (dp[row][col] != null)
            return dp[row][col];

        long ans = 0;
        if (row + 1 < n && grid[row + 1][col] == '.') {
            ans += recurse(row + 1, col, n, m, dp, grid);
            ans %= MOD;
        }

        if (col + 1 < m && grid[row][col + 1] == '.') {
            ans += recurse(row, col + 1, n, m, dp, grid);
            ans %= MOD;
        }

        return dp[row][col] = ans;
    }
}

Measured memory_bytes: 71496
L = int(input())
A = [int(input()) for _ in range(L)]

INF = 1E50
ans1 = sum(A)  # None
ans2 = ans1 - 1 if ans1 > 0 else 0

a_alpha_t = list(map(lambda x: 2 if x == 0 else x % 2, A))
a_b_t = list(map(lambda x: (x + 1) % 2, A))

total_val = 0
a_b_val = 0
a_alpha_val = 0
total = [0 for _ in range(L)]
a_b = list(total)
a_alpha = list(total)
for i in range(L):
    total_val += A[i]
    a_b_val += a_b_t[i]
    a_alpha_val += a_alpha_t[i]
    total[i] = total_val
    a_b[i] = a_b_val
    a_alpha[i] = a_alpha_val








ans = [0 for _ in range(5)]
for i, a in enumerate(A):
    tmp_ans=  [INF for _ in range(5)]
    tmp_ans[0] = total[i]
    tmp_ans[1] = min(ans[1]+a_alpha_t[i],total[i])
    tmp_ans[2]= min(tmp_ans[1],ans[2]+a_b_t[i])
    tmp_ans[3]= min(tmp_ans[2],ans[3]+a_alpha_t[i])
    tmp_ans[4] = min(tmp_ans[3],ans[4]+A[i])
    ans = tmp_ans

print(min(ans+[ans1,ans2]))

Measured memory_bytes: 39476
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      int num;
      int result;
      List<Integer> prime = new ArrayList<>(); 
      while(true) {

        if( ((line = br.readLine()) == null) || line.isEmpty() ) break;

        num = Integer.parseInt(line);
        if( num == 0 || num == 1) {
          result = 0;
          System.out.println(result);
          continue;
        }
        
        result = 0;
        prime.clear();
        for ( Integer i = 2; i <= num; i++ ) {
          if( isPrime(i,prime) ) {
            prime.add(i);
            result += 1;
          }
        }
        System.out.println(result);
      }
    }
  }

  public static boolean isPrime(Integer num,List<Integer> prime) {
    Integer k = Double.valueOf( Math.sqrt(num) ).intValue();
    for(Integer i: prime) {
      if ( num % i == 0) return false;
      if ( i > k ) return true;
    }
    return true;
  }
}


Measured memory_bytes: 157384
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test(t) int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
#define what(x) cerr<<#x<<" = "<<x<<endl

const int MOD = 1e9+7,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////


int main()
{	
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i+2<n;i++)
	{
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') cnt++;
 	}
 	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
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; }

void _main() {
  int K, T;
  cin >> K >> T;
  int a[T];
  rep(i, 0, T) cin >> a[i];

  sort(a, a+T);
  int sum = accumulate(a, a+T, 0);
  int ans = max(0, a[T-1] - (sum - a[T-1]) - 1);

  cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

if n % 2 == 0:
    S = set()
    for i in range(m):
        a = i
        b = n - i - 1
        while b - a in S or a - b + n in S or b - a == a - b + n:
            b -= 1
        S.add(b - a)
        S.add(a - b + n)
        print(a + 1, b + 1)
else:
    for i in range(m):
        print(i + 1, m * 2 - i)

Measured memory_bytes: 17600
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
using P = pair<int, int>;

int vis[1010][1010] = {};
int dir[] = { -1, 0, 1, 0, -1 };

void solve(long long H, long long W, std::vector<std::string> A){
    V<P> q;
    loop (H, i) loop (W, j) {
        if (A[i][j] == '#') {
            q.push_back({ i, j });
            vis[i][j] = 1;
        }
    }
    int ans = 0;
    while (1) {
        V<P> nxt;
        for (auto p : q) {
            loop (4, di) {
                int i = p.first + dir[di], j = p.second + dir[di + 1];
                if (i < 0 || i >= H || j < 0 || j >= W) continue;
                if (vis[i][j]) continue;
                vis[i][j] = 1;
                nxt.push_back({ i, j });
            }
        }
        if (nxt.empty()) break;
        q = nxt;
        ans++;
    }
    cout << ans << endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<std::string> A(H);
    for(int i = 0 ; i < H ; i++){
        std::cin >> A[i];
    }
    solve(H, W, std::move(A));
    return 0;
}



Measured memory_bytes: 18408
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1 << 15;
int f[N], a[N], b[N];
int g[N], n, m;

signed main ()
{
	memset (f, 127, sizeof f);
	long long pre = f[(1 << n) - 1];
	f[0] = 0;
	scanf ("%lld%lld", &n, &m);
	for (int i = 1; i <= m; ++i)
	{
		scanf ("%lld%lld", &a[i], &b[i]);
		for (int j = 1; j <= b[i]; ++j)
		{
			int tmp;
			scanf ("%lld", &tmp);
			g[i] |= 1 << (tmp - 1);
		}
	}
	for (int k = 0; k < (1 << n); ++k)
	{
		for (int i = 1; i <= m; ++i)
		{
			f[k | g[i]] = min (f[k | g[i]], f[k] + a[i]);
		}
	}
	if (f[(1 << n) - 1] == pre)
	{
		printf ("-1\n");
		return 0;
	}
	printf ("%lld\n", f[(1 << n) - 1]);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define itn int
#define REP(i,n) for(int i=0;i<n;i++)
#define IREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=k;i<n;i++)
#define REPEACH(itr,k) for(auto itr : k)
#define MOD 1000000007

using namespace std;
typedef long long ll;

const ll INF = 1LL<<60;

int main(){
	ll k,x;
	cin >> k >> x;
	ll start,goal;
	if(x-k+1<-1000000){
		start=-1000000;
		goal=x+k-1;
	}
	else if(x+k-1>1000000){
		start=x-k+1;
		goal=1000000;
	}
	else{
		start=x-k+1;
		goal=x+k-1;
	}
	for(ll i=start;i<=goal;i++){
		cout << i;
		if(i!=goal){
			cout << " ";
		}
		else{
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int dp[2][(1 << 18)];

signed main(){
    
    while(1){
        int n; cin >> n;
        if(!n) break;
        
        memset(dp, -1, sizeof(dp));
        dp[0][0] = 0;
        
        int cur = 0;
        int nxt = 1;
        for(int i = 0; i < n; i++){
            int m, l; cin >> m >> l;
            vector<int> s(m);
            vector<int> e(m);
            for(int j = 0; j < m; j++){ 
                cin >> s[j] >> e[j];
                s[j] -= 6;
                e[j] -= 6;
            }
            for(int bit = 0; bit < (1 << 18); bit++){
                if(dp[cur][bit] == -1) continue;

                //デートしない
                dp[nxt][bit] = max(dp[nxt][bit], dp[cur][bit]);


                //デートする
                bool ok = true;
                int nxtbit = 0;
                for(int j = 0; j < m; j++){
                    for(int k = s[j]; k < e[j]; k++) nxtbit = nxtbit | (1 << k);       
                }

                for(int k = 0; k < 18; k++) if(nxtbit & (1 << k) && bit & (1 << k)) ok = false;
                nxtbit = bit | nxtbit;
                if(ok) dp[nxt][nxtbit] = max(dp[nxt][nxtbit], dp[cur][bit] + l);
            }
        
            swap(cur, nxt);
        }
        
        int ans = -1;
        for(int j = 0; j < (1 << 18); j++) ans = max(ans, dp[cur][j]);
        cout << ans << endl;
    }
    return 0;
}




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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"

int n;
int a[222222];

int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}

	int ans = 0;
	for (int i = 0, j; i < n; i = j) {
		j = i;
		while(j < n && a[i] == a[j]) ++j;
		ans += (j - i) / 2;
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	if((b+w*t>(a+v*t))||((b-w*t)<(a-v*t))){
		cout<<"NO";
	}else cout<<"YES";
	
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define N               200005
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pq_max          priority_queue<ll>
#define pq_min          priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void fio(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    fio();

    ll n,x,t;
    cin>>n>>x>>t;

    ll j = n / x;
    if(n%x != 0) j++;

    cout<<j * t;

    return 0;
}

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

int main(){

  int N,m;
  cin >> N >> m;
  vector<int> is(N+1,1);

  for(int i=0; i<m; i++){ // 500
    int c,d;
    cin >> c >> d;
    if(c < d)
      for(int j=c; j<d; j++){ // 1000
	is[j] = 3;
      }
  }
  int ans = 0;
  for(int i=0; i<=N; i++){
    ans += is[i];
  }
  cout << ans << endl;

}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "C"
int n;
int a[100001];
vector <ll> v;
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    read(n);
    FOR(i, 1, n) read(a[i]);
    sort(a+1, a+n+1);
    int old=-1;
    ll ans=0;
    DFOR(i, n, 1){
        if(a[i]==old){
            v.pb(a[i]);
            old=-1;
        }
        else old=a[i];
    }
    if(v.size()>1) ans=v[0]*v[1];
    writeln(ans);
}

Measured memory_bytes: 1276
// AtCoder Regular Contest 080 C - 4-adjacent
// 2018.1.11 bal4u

#include <stdio.h>
#include <string.h>

#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int N, a;
	int i, n4, odd, ans;			// n4: 4の倍数

	odd = n4 = 0;
	N = in();
	for (i = 0; i < N; i++) {
		a = in();
		if (a & 1) odd++;
		else if (!(a & 3)) n4++;
	}
	ans = 0;
	if (n4 >= odd) ans = 1;
	else if (n4 == odd-1 && odd + n4 == N) ans = 1;
	puts(ans? "Yes": "No");
	return 0;
}

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

int main(){
    int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    vector<int>b;
    for(int i=0;i<n;i++){
        auto it = lower_bound(b.begin(),b.end(),a[i]);
        if(it == b.begin()) b.insert(it,a[i]);
        else{
          it--;
          *it=a[i];
        }
    }
  
   // for(int i=0;i<b.size();i++)cout<<b[i];
  cout<<b.size();


    
}

Measured memory_bytes: 4304
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)              cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,w;
    cin >> n >> w;
    std::vector<ll> weight(n+1),value(n+1);
    rep(i,1,n+1) cin >> weight[i] >> value[i];
    ll dp[n+1][w+1]={0};
    for(ll i=0; i<=n; i++){
        for(ll j=0; j<=w; j++){
            dp[i][j]=0;
        }
    }
    for(ll i=1; i<=n; i++){
        for(ll j=0; j<=w; j++){
            if(weight[i]>j) dp[i][j]=dp[i-1][j];
            else{
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-weight[i]]+value[i]);
            }
        }
    }
    cout << dp[n][w];
    return 0;
}

Measured memory_bytes: 79232