akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

vector<vector<ll>> graph;
vector<bool> visited;

void dfs(ll now) {
	visited[now] = true;
	for (ll to : graph[now]) {
		if (!visited[to]) {
			dfs(to);
		}
	}
}

int main() {
	ll N, M;
	cin >> N >> M;
	graph.resize(2*N);
	rep(i,0,M) {
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[2*a].push_back(2*b+1);
		graph[2*b+1].push_back(2*a);
		graph[2*a+1].push_back(2*b);
		graph[2*b].push_back(2*a+1);
	}
	visited.resize(2*N);
	dfs(0);
	ll cnt = 0;
	rep(i,0,N) {
		if (visited[2*i]) {
			cnt++;
		}
	}
	ll ans = 0;
	rep(i,0,N) {
		bool have_true = false;
		bool have_false = false;
		for (ll to : graph[2*i]) {
			to /= 2;
			if (visited[2*to]) {
				have_true = true;
			} else {
				have_false = true;
			}
		}
		ll ans_loc = 0;
		if (have_true) {
			ans_loc += cnt;
			if (visited[2*i]) {
				ans_loc--;
			}
		}
		if (have_false) {
			ans_loc += N - cnt;
			if (!visited[2*i]) {
				ans_loc--;
			}
		}
		// cout << i+1 << ":" << ans_loc << endl;
		ans += ans_loc;
	}
	cout << ans / 2 - M << endl;
}


Measured memory_bytes: 13056
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort()

ans = 0
space = C
dept = 0
for t in T:
    if t <= dept and space > 0:
        space -= 1
        continue
    dept = t+K
    space = C-1
    ans += 1
print(ans)

Measured memory_bytes: 7384
s = input()
t = input()

def f(x):
    dic = {}
    for c in x:
        if c in dic:
            dic[c] += 1
        else:
            dic[c] = 1
    return dic

d1 = f(s)
d2 = f(t)
l1 = [i for i in d1.values()]
l2 = [i for i in d2.values()]
l1.sort()
l2.sort()

if l1 == l2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int a, b;
    cin >> a >> b;

    cout << max(a+b, max(a-b, a*b)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int Q=1e5+5;
int p[Q],n;
ll op[1<<20];
int as[1<<20],maxn=0;
void Try(int MOD)
{
    if(p[0]%MOD)return;
    int lim=min(n,MOD-2);
    fill(op,op+lim+1,0);
    for(int i=0;i<=n;i++)
        op[i%(MOD-1)]+=p[i];
    for(int i=0;i<=lim;i++)
        if(op[i]%MOD)return;
    as[++maxn]=MOD;
}
int main()
{
    scanf("%d",&n);
    int had=0;
    for(int i=n;i>=0;--i)
        scanf("%d",&p[i]);
    int x=p[n];
    if(x<0)x=-x;
    for(int j=2;j*j<=x;j++)
        if(x%j==0){
            while(x%j==0)x/=j;
            Try(j);
        }
    if(x>1)Try(x);
    for(int i=2;i<=10000;i++){
        int gg=0;
        for(int j=2;j*j<=i;j++)
            if(i%j==0){
                gg=1;
                break;
            }
        if(!gg)Try(i);
    }
    sort(as+1,as+maxn+1);
    maxn=unique(as+1,as+maxn+1)-as-1;
    for(int i=1;i<=maxn;i++)
        printf("%d\n",as[i]);
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

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

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


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


int main() {

ll a,b;
cin>>a>>b;
if(a==b){cout<<a<<endl;
return 0;}

ll ans=0;

ll k;
if(a%2==0 && b%2==0){
if((b/2-a/2)%2)k=1;
else k=0;
}
if(a%2==0 && b%2){
if((b/2-a/2+1)%2)k=1;
else k=0;
}
if(a%2 && b%2==0){
	if((b/2-a/2)%2) k=1;
	else k=0;
}
if(a%2 && b%2){
	if((b/2-a/2+1)%2) k=1;
	else k=0;
}
ans+=k;



ll v=1;
for(ll i=1;i<=48;i++){
v*=2;
ll s=0;
if(a>=v){
	ll aa=a-v;
	aa%=v;
	if(a%(v*2)>=v)
s-=aa;
}
if(b>=v){
	ll bb=b-v;
	bb%=v;
	if(b%(v*2)>=v)
	s-=(v-bb-1);
}

if((s+inf)%2) ans+=v;
}

cout<<ans<<endl;

}


Measured memory_bytes: 256
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($A,$B) =  explode(" ",trim(fgets(STDIN)));
$A =  explode(" ",trim(fgets(STDIN)));
$B =  explode(" ",trim(fgets(STDIN)));

$m = 0;
for($i=0;$i<$N;$i++) {
  $left = min($A[$i],$B[$i]);
  $m += $left;
  $A[$i] -= $left;
  $B[$i] -= $left;

  $right = min($A[$i+1],$B[$i]);
  $m += $right;
  $A[$i+1] -= $right;
  $B[$i] -= $right;
}
printf("%d\n",$m);


Measured memory_bytes: 20980
#include <stdio.h>
#include <stdlib.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define W 700

typedef struct tuple{int x,y;}T;

int qidx[500010];
T query[500010];//[x,y]
int qcmp(const void*p,const void*q){
	if(query[*(int*)p].x/W<query[*(int*)q].x/W)return -1;
	if(query[*(int*)p].x/W>query[*(int*)q].x/W)return 1;
	if(query[*(int*)p].y<query[*(int*)q].y)return -1;
	if(query[*(int*)p].y>query[*(int*)q].y)return 1;
	return 0;
}


int c[500010];
int ans[500010];
int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	rep(i,1,n+1)scanf("%d",c+i);
	rep(i,0,q)scanf("%d%d",&query[i].x,&query[i].y);
	
	//クエリをソート
	rep(i,0,q)qidx[i]=i;
	qsort(qidx,q,sizeof(int),qcmp);
	
	//クエリに答える
	int*qi=qidx;
	rep(i,0,n/W+1){
		int temp[500010]={};
		int cnt=0;
		int l,r;
		if(qi-qidx<q&&query[*qi].x/W==i){
			rep(p,query[*qi].x,query[*qi].y+1)cnt+=!temp[c[p]]++;
			ans[*qi]=cnt;
			l=query[*qi].x;
			r=query[*qi].y;
			qi++;
		}
		while(qi-qidx<q&&query[*qi].x/W==i){
			while(l<query[*qi].x)cnt-=!--temp[c[l++]];
			while(l>query[*qi].x)cnt+=!temp[c[--l]]++;
			while(r<query[*qi].y)cnt+=!temp[c[++r]]++;
			ans[*qi]=cnt;
			qi++;
		}
	}

	rep(i,0,q)printf("%d\n",ans[i]);
}

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

lst = list(map(int, input().split()))

lst2 = [0 for i in range(N)]

for i in range(N):
	lst2[lst[i]-1] = i+1

for i in range(N):
	if i != N-1:
		print(lst2[i],end = " ")
	else:
		print(lst2[i])


Measured memory_bytes: 13880
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main(){
    //std::stack<int> stack;
    int n;
    cin >> n;
    int ans = (n+1)/2;
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

  ll N;
  cin >> N;
  ll m1 = 0;
  ll m2 = 0;
  vector<ll> A(N);
  REP(i, N){
    cin >> A[i];
    if (A[i] >= m1){
      m2 = m1;
      m1 = A[i];
    }else if(A[i] > m2) m2 = A[i];
  }
  REP(i, N){
    if (A[i] == m1) cout << m2 << endl;
    else cout << m1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3200
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


void Main(){
    string S;
    cin >> S;
    string s="Sunny", c="Cloudy", r="Rainy", t;
    if(S==s){
        t=c;
    }else if(S==c){
        t=r;
    }else if(S==r){
        t=s;
    }
    cout << t << el;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n;
int a,b;
int main(){
    cin>>n;
    int t;
    cin>>a>>b;
    int la=0,lb=0,lc=0;
    for(int i=0;i<n;i++){
        scanf("%d",&t);
        if(t<=a)
           la++;
        else if(t<=b)
            lb++;
        else
            lc++;
    }
    printf("%d\n",min(la,min(lb,lc)));

}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int n = 0, mov[500500], sum[500500], dp[500500];
bool able[500500];
int main()
{
	#define pud(x, y) min((x), abs((x) - (y)))
	scanf("%d%d", &n, sum);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", mov + i);
		sum[i] = pud(sum[i - 1], mov[i]);
	}
	dp[n + 1] = 1;
	for(int i = n; i >= 1; i--)
	{
		able[i] = (sum[i - 1] >= dp[i + 1]);
		dp[i] = dp[i + 1] + mov[i];
		if(pud(dp[i + 1], mov[i]) == dp[i + 1]) dp[i] = min(dp[i], dp[i + 1]);
		if(mov[i] - dp[i + 1] >= 0 and pud(mov[i] - dp[i + 1], mov[i]) == dp[i + 1]) dp[i] = min(dp[i], mov[i] - dp[i + 1]);
	}
	int q = 0; scanf("%d", &q);
	for(int i = 1; i <= q; i++)
	{
		int s = 0; scanf("%d", &s);
		puts(able[s]? "YES": "NO");
	}
	return 0;
}

Measured memory_bytes: 8320
// Problem : D - Derangement
// Contest : AtCoder - AtCoder Beginner Contest 072
// URL : https://atcoder.jp/contests/abc072/tasks/arc082_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int t=1;
	while(t--)
	{
		int n,count=0;
		cin>>n;
		vi a(n+1);
		l00p(i,1,n+1)
		cin>>a[i];
		l00p(i,1,n)
		{
			if(a[i]==i && a[i+1]==i+1)
			{
				count++;
				swap(a[i],a[i+1]);
				i++;
			}
			if(a[i]==i && a[i+1]!=i+1)
			{
				count++;
				swap(a[i],a[i+1]);
				i++;
			}
		}
		if(a[n]==n)
		count++;
		cout<<count;
	}
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3688
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#define pi 3.14159265358979323846
#define max max_element
#define min min_element
using namespace std;
 
template<typename T> 
	T gcd(T a, T b) {
		return b ? gcd(b, a % b) : a;
	}
template<typename T>
	T lcm(T a, T b) {
		return a * b / gcd(a, b);
	}
 
int main() {
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(i%2==0){
      if(s[i]!='R'&&s[i]!='U'&&s[i]!='D'){
        cout<<"No"<<endl;
        break;
      }
    }else {
        if(s[i]!='L'&&s[i]!='U'&&s[i]!='D'){
        cout<<"No"<<endl;
        break;
      }
      }
            if(i==s.size()-1) cout<<"Yes"<<endl;
    }
  }

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
template <class T>
vector<ll> countVector(vector<T>v,T guard=0){
    ll size=v.size();
    v.push_back(guard);
    vector<ll>ret;
    ll count=1;
    for(int i=0;i<size;i++){
        if(v[i]==v[i+1]){
            count++;
        }else{
            ret.push_back(count);
            count=1;
        }
    }
    return ret;
}
ll gcd(ll a,ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(){
	init();
	ll N,K;cin>>N>>K;
	vector<char>s(N);
	for(int i=0;i<N;i++)cin>>s[i];
	vector<ll>v=countVector(s);
	if(s[0]=='0')v.insert(v.begin(),0);
	//for(auto&&i:v)cout<<i<<endl;
	for(int i=0;i<3*K;i++)v.push_back(0);
	//sum
	ll n=N+3;
	N=v.size();
	vector<ll>sum(N+1,0);
	for(int i=0;i<N;i++){
		sum[i+1]=sum[i]+v[i];
	}
	
	ll ans=0;
	for(int i=0;i+2*K+1<N;i+=2){
		ans=max(ans,sum[i+2*K+1]-sum[i]);
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 6156
#include <bits/stdc++.h>
using namespace std;
int n;
int x;
int t;
double sd;
int main()
{
	scanf("%d %d %d",&n,&x,&t);
	if(n%x==0)
	{
		printf("%d",n/x*t);
	}
	else
	{
		printf("%d",(n/x+1)*t);
	}
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
const int maxn = 186;
const int LN = 20;
const int S = LN * maxn * maxn * maxn;
int pool[S],*idx = pool + S;
int * f[LN][maxn][maxn];
int * g[LN][maxn][maxn];
int sum[maxn][maxn];
int n,m;
inline bool ok(int x0,int y0,int x1,int y1) {
	int s = sum[x1][y1] - sum[x1][y0 - 1] - sum[x0 - 1][y1] + sum[x0 - 1][y0 - 1]; 
	return !s || s == (x1 - x0 + 1) * (y1 - y0 + 1);
}
inline void up(int & x,int y) {
	if(x < y)
		x = y;
}
inline void update(int x0,int y0,int x1,int y1,int v) {
	if(x0 <= x1 && y0 <= y1) {
		up(f[v][x0][x1][y0],y1);
		up(g[v][y0][y1][x0],x1);
	}
}
int main()
{
	std::ios::sync_with_stdio(false),std::cin.tie(0);
	for(int i = 0;i < LN;++i) {
		for(int j = 1;j < maxn;++j) {
			for(int k = j;k < maxn;++k){
				f[i][j][k] = idx -= maxn;
				g[i][j][k] = idx -= maxn;
			}
		}
	}
	std::cin >> n >> m;
	for(int i = 1;i <= n;++i) {
		for(int j = 1;j <= m;++j) {
			char ch; std::cin >> ch;
			sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + ch % 2;
		}
	}
	for(int j = 1;j <= n;++j) for(int k = j;k <= n;++k) for(int l = 1;l <= m;++l){
		int & x = f[0][j][k][l] = l;
		for(;x <= m && ok(j,l,k,x);) ++ x;
		-- x;
	}
	for(int j = 1;j <= m;++j) for(int k = j;k <= m;++k) for(int l = 1;l <= n;++l){
		int & x = g[0][j][k][l] = l;
		for(;x <= n && ok(l,j,x,k);) ++ x;
		-- x;
	}
	for(int i = 1;i <= n;++i) 
		for(int j = 1;j <= m;++j) 
			for(int k = i;k <= n;++k) 
				for(int l = j;l <= m && ok(i,j,k,l);++l) 
					update(i,j,k,l,0);
	for(int i = 0;;++i) {
		for(int j = 1;j <= n;++j) for(int k = m;k >= j;--k) for(int l = 1;l <= m;++l) {
			up(f[i][j][k][l],f[i][j][k][l - 1]);
			if(j != 1) up(f[i][j][k][l],f[i][j - 1][k][l]);
			if(k != n) up(f[i][j][k][l],f[i][j][k + 1][l]);
		}
		for(int j = 1;j <= m;++j) for(int k = m;k >= j;--k) for(int l = 1;l <= n;++l) {
			up(g[i][j][k][l],g[i][j][k][l - 1]);
			if(j != 1) up(g[i][j][k][l],g[i][j - 1][k][l]);
			if(k != m) up(g[i][j][k][l],g[i][j][k + 1][l]);
		}
		for(int j = 1;j <= n;++j) for(int k = j;k <= n;++k) for(int l = 1;l <= m;++l) {
			const int to = f[i][j][k][l];
			update(j,l,k,to == m ? m : f[i][j][k][to + 1],i + 1);
		}
		for(int j = 1;j <= m;++j) for(int k = j;k <= m;++k) for(int l = 1;l <= n;++l) {
			const int to = g[i][j][k][l];
			update(l,j,to == n ? n : g[i][j][k][to + 1],k,i + 1);
		}
		if(f[i][1][n][1] == m || g[i][1][m][1] == n) {
			std::cout << i << '\n';
			return 0;
		}
	}
}


Measured memory_bytes: 462720
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
#define fprint(NUM,X) cout << fixed << setprecision(NUM) << (X) << endl
#define fprints(NUM,X,Y) cout << fixed << setprecision(NUM) << (X) << " " << (Y) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];
double w[1000],v[1000];
double box[200010];

#define MAX 100000
#define INFTY (1 << 30)

class Edge{
public:
  int t,w;
  Edge(){}
  Edge(int t,int w): t(t),w(w){}
};

vector<Edge> G[MAX];

bool vis[MAX];
int cnt;

void dfs(int s){
  for(int i = 0;i < n;i++)d[i] = INFTY;
  queue<int> que;
  que.push(s);
  d[s] = 0;
  int u;
  while(!que.empty()){
    u = que.front();que.pop();
    for(int i = 0;i < G[u].size();i++){
      Edge e = G[u][i];
      if(d[e.t] == INFTY){
        d[e.t] = d[u] + e.w;
        que.push(e.t);
      }
    }
  }
}

void solve(){
  dfs(0);
  ll maxv = 0;
  int tgt = 0;
  for(int i = 0;i < n;i++){
    if(d[i] == INFTY)continue;
    if(maxv < d[i]){
      maxv = d[i];
      tgt = i;
    }
  }

  dfs(tgt);
  maxv = 0;
  for(int i = 0;i < n;i++){
    if(d[i] == INFTY)continue;
    maxv = max(maxv,d[i]);
  }
  cout << maxv << endl;
}

int main(){
  int s,t,w;
  cin >> n;
  for(int i = 0;i < n-1;i++){
    cin >> s >> t >> w;
    G[s].push_back(Edge(t,w));
    G[t].push_back(Edge(s,w));
  }
  solve();
  return 0;
}


Measured memory_bytes: 10224
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define D 1000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.14159265358979323
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"

const ll MAXN=100005;
ve<ve<ll>> vec(MAXN);
bool vis[MAXN];
ve<ll> disa(MAXN),disb(MAXN);

void bfs(ll s, bool a) 
{ 
    for(int i = 0; i < MAXN; i++) 
        vis[i] = false; 
    list<ll> queue; 
    vis[s] = true; 
    queue.push_back(s); 
    if(a)
        disb[s]=0;
    else
        disa[s]=0;
    ll x=0;
    while(!queue.empty()) 
    { 
        s = queue.front();
        queue.pop_front(); 
        for (auto i = vec[s].begin(); i != vec[s].end(); ++i) 
            if (!vis[*i]) 
            { 
                vis[*i] = true; 
                queue.push_back(*i); 
                if(a)
                    disb[(*i)]=disb[s]+1;
                else
                    disa[(*i)]=disa[s]+1;
            }
    }
}

int main() 
{
    FAST;
    ll n,a,b;
    cin>>n>>a>>b;
    ll x,y;
    for(int i=1;i<n;i++)
    {
        cin>>x>>y;
        vec[x].pb(y);
        vec[y].pb(x);
    }
    
    bfs(a,0);
    bfs(b,1);
    ll ma=0;
    for(int i=1;i<=n;i++)
        if(disa[i]<disb[i])
            ma=max(ma,disb[i]-1);
    cout<<ma;
    subt;   
    return 0;
}

Measured memory_bytes: 9844
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a,b,c;
	int flag=0;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b)
	{
		flag=1;
	}
	if(b==c)
	{
		flag=1;
	}
	if(a==c)
	{
		flag=1;
	}
	if(a==b&&b==c)
	{
		flag=0;
	}
	if(flag==0)
	{
		printf("No");
	}
	else
	{
		printf("Yes");
	}
 } 

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include <queue>
#include <stack>
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define MOD 1000000007
#define MAX 100000
using namespace std;
typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;

int main()
{
	int N,W;
	cin >> N >>W;
	if(N>W){
		cout<<"safe"<<endl;
	}else{
	cout<<"unsafe"<<endl;
	}
	return 0;

}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

bool isMale() {
    string result;
    cin >> result;
    if (result == "Vacant") {
        exit(0);
    }
    return result == "Male";
}

int main() {
    int N;
    cin >> N;
    int left = 0;
    int right = N - 1;
    cout << 0 << endl;
    bool leftMale = isMale();
    while (left < right) {
        int mid = (left + right + 1) / 2;
        cout << mid << endl;
        bool midMale = isMale();
        if ((mid - left) % 2 == (leftMale == midMale)) {
            right = mid;
        } else {
            left = mid;
            leftMale = midMale;
        }
    }
}

Measured memory_bytes: 852
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:String,
    }
    let a=a.chars().collect_vec();
    let v="CODEFESTIVAL2016";
    let mut v=v.chars().collect_vec();
    let mut b=0;
    for i in 0..a.len(){
        if a[i]!=v[i]{
            b+=1;
        }
    }
    println!("{}",b)
}

Measured memory_bytes: 2188
#include<bits/stdc++.h>
#define int long long 
#define pb push_back
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define N 1005

int INF=1000000;
const int mod=1e9+7;
using namespace std;
int dp[N][N];
int n,r;
vector<int> v;

void need_for_speed(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}



int32_t main(){
	need_for_speed();
    string s,t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i]) cnt++;
    }
    cout<<cnt<<endl;
        
        
    
    return 0;
}
    
 

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007LL;

void SetZero(vector<vector<ll>>& a) {
    int m = a.size();
    for ( int i = 0; i < m; i++ ) {
        for ( int j = 0; j < m; j++ ) {
            a[i][j] = 0;
        }
    }
}

void PlusOn(vector<vector<ll>>& a, vector<vector<ll>>& b) {
    int m = a.size();
    for ( int i = 0; i < m; i++ ) {
        for ( int j = 0; j < m; j++ ) {
            a[i][j] += b[i][j];
            a[i][j] %= MOD;
        }
    }
}

vector<vector<ll>> TMP;
void MultiplyOn(vector<vector<ll>>& a, vector<vector<ll>>& b) {
    int m = a.size();
    SetZero(TMP);
    for ( int i = 0; i < m; i++ ) {
        for ( int j = 0; j < m; j++ ) {
            for ( int k = 0; k < m; k++ ) {
                TMP[i][j] += (a[i][k]*b[k][j]) % MOD;
            }
            TMP[i][j] %= MOD;
        }
    }
    a.swap(TMP);
}

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

    vector<vector<ll>> S(W, vector<ll>(W));
    vector<vector<ll>> Sp1(W, vector<ll>(W)), Sp2(W, vector<ll>(W));
    ll n = 0, n1 = 0, n2 = 0;
    n = 1;
    for ( int k = 0; k < W; k++ ) {
        n2 = n1;
        n1 = n;
        n = (n1 + n2) % MOD;
        Sp2.swap(Sp1);
        Sp1.swap(S);
        SetZero(S);
        PlusOn(S, Sp1);
        S[k][k] += n1;
        if ( k > 0 ) {
            PlusOn(S, Sp2);
            S[k-1][k] += n2;
            S[k][k-1] += n2;
        }
    }

    vector<vector<ll>> SH(W, vector<ll>(W));
    for ( int i = 0; i < W; i++ ) {
        SH[i][i] = 1;
    }
    TMP.resize(W, vector<ll>(W));
    for ( int i = 0; i < H; i++ ) {
        MultiplyOn(SH, S);
    }
    
    ll ans = SH[K-1][0];
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{   
    int n;
    cin>>n;
    vector<vector<ll> > a(n, vector<ll> (n,0));
    for(int i =0; i<n; i++)
    {
        for(int j = 0; j<n; j++)
            cin>>a[i][j];
    }

    ll max_mask = (1<<n);
    vector<ll> dp(max_mask);
    for(int mask = 0; mask < max_mask ; mask ++ )
    {
        for(int i = 0; i< n; i++)
        {
            if((mask & (1<<i) )== 0)
                continue;
            for(int j = i + 1; j <n; j++)
            {
                if((mask & (1<<j)) == 0)
                    continue;
                dp[mask] += a[i][j];
            }
        }
    }
    

    for(int mask = 1; mask < max_mask; mask ++)
    {
        for(int ss = mask ; ss> 0 ; ss = (ss -1)& mask)
            {
                dp[mask ] = max(dp[mask] , dp[ss] + dp[ss ^ mask]);
            }
    }
    cout<<dp[max_mask -1]<<"\n";


    

}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    int n;
    cin >> n;
    string ans = "";
    if (n == 0) {
        ans = "0";
    } else {
        while (n != 0) {
            if (n % 2 == 0) {
                ans = '0' + ans;
            } else {
                n--;
                ans = '1' + ans;
            }
            n /= -2;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int p[1005];

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	
	for (int i = 0; i < n; i++) scanf("%d", &p[i]);
	
	sort(p, p + n);
	
	int res = 0;
	
	for (int i = 0; i < k; i++) res += p[i];
	
	printf("%d\n", res);
}


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

int gcd(int a, int b)
{
	int c;

	if (a < b) {
		a += b; b = a - b; a -= b;
	}

	while (b != 0) {
		c = a % b;
		a = b;
		b = c;
	}

	return a;
}

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (C % gcd(A, B) == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  //ll n; cin>>n;
 ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  //string s; cin>>s;
  ll result = 0;
  ll buf = 0;
  ll buf2 = 0;
  ll buf3 = 0;
  bool judge = true;
  cout<<(a*3+b)/2<<endl;

  /*
  vector<ll> a(n);
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=0;i<n;i++){

  }
  */

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

typedef pair<int, int> P;

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

long x[101];
int main() {
	int A, B;
	cin >> A>>B;
	int a = A + B, b = A - B, c = A * B;
	cout << max(a, (max(b, c))) << endl;
}


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

long long DP[101][101][301];

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

	long long w0;
	vector<pair<int, int>>wv(N);
	cin >> wv[0].first >> wv[0].second;
	w0 = wv[0].first; wv[0].first -= w0;
	for (int i = 1; i < N; i++) {
		cin >> wv[i].first >> wv[i].second;
		wv[i].first -= w0;
	}

	for (int i = 0; i < N; i++) {
		for (int k = 0; k < i+1; k++) {
			for (int j = 0; j < 301; j++) {
				if (j + wv[i].first + w0*(k + 1) <= W)DP[i + 1][k + 1][j + wv[i].first] = max(DP[i + 1][k + 1][j + wv[i].first], DP[i][k][j] + wv[i].second);
				DP[i+1][k][j] = max(DP[i + 1][k][j], DP[i][k][j]);
			}
		}
	}

	long long ans = 0;
	for (int k = 0; k <= N; k++) {
		for (int j = 0; j < 301; j++) {
			ans = max(DP[N][k][j], ans);
		}
	}

	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 22272
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
I=h*w
d=[I]*I
m+=d,
a=~w+a*w+b
q=[a]
d[a]=1
for s in q:
 for x in range(4):
  for z in range(k):
   y=~z,0,z+1,0,~z;i,j=s//w+y[x],s%w+y[x+1];t=i*w+j;p=d[s]+1
   if'.'!=m[i][j]or d[t]<p:break
   if d[t]>p:q+=t,;d[t]=p
print(d[~w+f*w+g]%I-1)

Measured memory_bytes: 133160
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
typedef vector<int> vi;

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

    int ans = 0;
    rep(i, A+1){
        rep(j, B+1){
            rep(k, C+1){
                if(500*i + 100*j + 50*k == X) ans++;
            }
        }
    }

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

Measured memory_bytes: 3564
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n,c;

int d[33][33];
int cc[510][510];
int q[33][3]={{},{},{}};

int main(){
	cin>>n>>c;
	for(int i=0;i<c;i++)
		for(int j=0;j<c;j++)
			cin>>d[i][j];
		
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>cc[i][j];
		
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			int t=cc[i][j];
			q[t][(i+j)%3]++;
		}
	}
	
	int ans=INF;
	
	for(int i=1;i<=c;i++){
		for(int j=1;j<=c;j++){
			for(int k=1;k<=c;k++){
				if(i!=j&&j!=k&&k!=i){
					int tans=0;
					for(int l=1;l<=c;l++){
						if(l!=i){
							tans+=q[l][0]*d[l-1][i-1];
						}
					}
					
					for(int l=1;l<=c;l++){
						if(l!=j){
							tans+=q[l][1]*d[l-1][j-1];
						}
					}
					
					for(int l=1;l<=c;l++){
						if(l!=k){
							tans+=q[l][2]*d[l-1][k-1];
						}
					}
					ans=min(ans,tans);
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}
	

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 1e9+7;

int main(){
  int x,ans = 0;
  cin >> x;
  for(int c=1;c<=x;c++){
    if(100*c <=x && 105*c >= x) {ans = 1;break;}
  } 
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct edge{
  long to,cap,rev;//capは残りどれだけ流せるか, revはv[to][rev]が自分への逆辺を表す
  edge(){}
  edge(long t,long c,long r):to(t),cap(c),rev(r){}
};
class flow{
  long n;
  vector<vector<edge>>v;
  vector<bool>used;
  public:
  
  long dfs(long s,long t,long f){
    if(s==t)return f;
    used[s]=1;
    for(long i=0;i<v[s].size();i++){
      edge e=v[s][i];
      if(!used[e.to]&&e.cap>0){
        long r=dfs(e.to,t,min(f,e.cap));
        if(r>0){
          v[s][i].cap-=r;v[e.to][e.rev].cap+=r;
          return r;
        }
      }
    }
    return 0;
  }
  long solve(long s,long t){//最大流を求める
    long ans=0;
    while(1){
      used.clear();used=vector<bool>(n,0);
      long f=dfs(s,t,LONG_MAX);
      if(f==0)return ans;
      else ans+=f;
    }
  }
  flow(){}
  flow(const vector<vector<edge>>&v_)
    :n(v_.size()),v(vector<vector<edge>>(v_.size())){
      for(long i=0;i<n;i++)for(long j=0;j<v_[i].size();j++){
        edge e=v_[i][j];
        v[i].push_back(edge(e.to,e.cap,v[e.to].size()));//辺の追加
        v[e.to].push_back(edge(i,0,v[i].size()-1));//逆辺の追加
      }
    }
};

int main(){
  //素数前処理
  long M=10000001;
  vector<bool>prime(M,1);prime[0]=0,prime[1]=0;
  for(long i=2;i<=M;i++){
    if(prime[i]){
      for(long j=2;i*j<=M;j++)prime[i*j]=0;
    }
  }
  
  long N;cin>>N;
  vector<long>X(N);for(long i=0;i<N;i++)cin>>X[i];
  vector<long>O,E;
  for(long i=0;i<N;i++){
    if(i==0||X[i]-1!=X[i-1]){if(X[i]%2)O.push_back(X[i]);else E.push_back(X[i]);}
    if(i==N-1||X[i]+1!=X[i+1]){if((X[i]+1)%2)O.push_back(X[i]+1);else E.push_back(X[i]+1);}
  }
  
  vector<vector<edge>>A(2+O.size()+E.size());
  for(long i=0;i<O.size();i++)A[0].push_back(edge(1+i,1,0));
  for(long i=0;i<E.size();i++)A[1+O.size()+i].push_back(edge(1+O.size()+E.size(),1,0));
  for(long i=0;i<O.size();i++)for(long j=0;j<E.size();j++){
    long d=abs(O[i]-E[j]);
    if(prime[d])A[1+i].push_back(edge(1+O.size()+j,1,0));
  }
  flow f(A);long k=f.solve(0,1+O.size()+E.size());
  long ans=k+2*((O.size()-k)/2)+2*((E.size()-k)/2)+3*((O.size()-k)%2);
  cout<<ans;
}

/*
*/

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
string n,t="0",m;
int x,y,z;
bool ye;
int main()
{
    cin>>n;
    m=n;
    for (int i=n.size()-1,j=1;i>=0;i--,j*=10)
        z+=(n[i]-48)*j;
    y=z+1;
    for (int i=1,j=z;i<=z/2;i++,j--)
    {
        if (t[t.size()-1]!='9')
            t[t.size()-1]++;
        else
        {
            for (int j=t.size()-1;j>=0;j--)
            {
                if (t[j]!='9')
                {
                    ye=true;
                    t[j]++;
                    for (int q=j+1;q<t.size();q++)
                        t[q]='0';
                    break;
                }
            }
            if (!ye)
            {
                for (int j=0;j<t.size();j++)
                    t[j]='0';
                t+='1';
                reverse(t.begin(),t.end());
            }
        }
        ye=false;
        if (m[m.size()-1]!='0')
            m[m.size()-1]--;
        else
        {
            for (int j=m.size()-1;j>=0;j--)
            {
                if (m[j]!='0')
                {
                    ye=true;
                    m[j]--;
                    for (int q=j+1;q<m.size();q++)
                        m[q]='9';
                    break;
                }
            }
            if (!ye)
            {
                for (int j=0;j<m.size();j++)
                    m[j]='9';
                m.erase(m.begin(),m.begin()+1);
            }
        }
        ye=false;
        for (int j=0;j<m.size();j++)
        {
            x+=m[j]-48;
        }
        for (int j=0;j<t.size();j++)
        {
            x+=t[j]-48;
        }
        if (x<y)
            y=x;
        x=0;
    }
    cout<<y;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std ;

int main()
{

 int ar[5],k;
 for(int i=0;i<5;i++)
 {
     cin>>ar[i];
 }
 cin>>k;

 if(ar[4]-ar[0]>k)
    
    cout<<":(";
 else cout<<"Yay!";
    return 0;
}



Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef complex<double> C;

typedef string::const_iterator State;

set<int> expression(State& begin);
set<int> factor(State& begin);

set<int> factor(State& begin) {
    if (*begin == '(') {
        begin++;
        auto ret = expression(begin);
        begin++;
        return ret;
    } else {
        set<int> ret;
        int tmp = 0;
        while (isdigit(*begin)) {
            tmp = 10*tmp + (*begin-'0');
            begin++;
        }
        ret.insert(tmp);
        return ret;
    }
}

set<int> expression(State& begin) {
    vector<set<int> > nums;
    vector<char> ops;
    nums.push_back(factor(begin));
    while (*begin == '+' || *begin == '-' || *begin == '*' || *begin == '/') {
        ops.push_back(*begin);
        begin++;
        nums.push_back(factor(begin));
    }
    int n = ops.size();
    vector<int> perm(n);
    for (int i = 0; i < n; i++) perm[i] = i;
    set<int> ret;
    do {
        vector<set<int> > buff = nums;
        bool ng = false;
        for (int i = 0; i < n; i++) {
            int L = perm[i], R = L+1;
            char op = ops[perm[i]];
            while (L >= 0 && buff[L].size() == 0) {
                L--;
            }
            if (L < 0) {
                ng = true;
                break;
            }
            set<int> to;
            for (auto el1 : buff[L]) {
                for (auto el2 : buff[R]) {
                    if (op == '+') to.insert(el1+el2);
                    if (op == '-') to.insert(el1-el2);
                    if (op == '*') to.insert(el1*el2);
                    if (op == '/' && el2 != 0) to.insert(el1/el2);
                }
            }
            buff[L] = to;
            buff[R].clear();
        }
        if (!ng) {
            for (int el : buff[0]) {
                ret.insert(el);
            }
        }
    } while (next_permutation(perm.begin(), perm.end()));
    return ret;
}

void solve(const string& s) {
    State begin = s.begin();
    auto ans = expression(begin);
    cout << ans.size() << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    while (cin >> s) {
        if (s == "#") break;
        solve(s);
    }
    return 0;
}

Measured memory_bytes: 1252
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_Training
{

    public class Program
    {
        static void Main(string[] args)
        {
            var nkq = Console.ReadLine().Split(' ');
            var n = int.Parse(nkq[0]);
            var k = int.Parse(nkq[1]);
            var q = int.Parse(nkq[2]);
            int[] points = new int[n];
            for(int i = 0;i < q; i++)
            {
                var idx = int.Parse(Console.ReadLine()) - 1;
                points[idx]++;
            }
            for(int i = 0; i < n; i++)
            {
                Console.WriteLine(points[i] - q + k > 0 ? "Yes" : "No");
            }
        }
    }
}


Measured memory_bytes: 17600
#include<bits/stdc++.h>
using namespace std;
int n,i,k,m,d[200008],t[200008];
int main(){
  cin>>n;
  for(i=1;i<=n;i++)cin>>d[i];
  cin>>m;
  for(i=1;i<=m;i++)cin>>t[i];
  sort(d+1,d+n+1);
  sort(t+1,t+m+1);
  bool flag=true;k=1;
  while(d[k]<t[1]&&k<=n)k++;
  if(n<m)flag=false;
  else for(i=1;i<=m;i++){
  	if(d[k]!=t[i]||k>n){
  		flag=false;break;
	  }
	  k++;
	if(t[i]!=t[i+1])
	  while(d[k]==d[k-1])k++;
    while(d[k]<t[i+1]&&k<=n)k++;
}
    if(flag)cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 1920
#include <stdio.h>

int main(void)
{
	int W,H,x,y,r;
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	
	if ((y-r>=0&&y+r<=H)&&(x-r>=0&&x+r<=H))
	{printf("Yes\n");
	}
	else {printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int A, B; std::cin >> A >> B;
  if (A>9||B>9) std::cout << -1 << std::endl;
  else          std::cout << A*B << std::endl;
  return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N, K, S = map(int, input().split())

    if S == 10 ** 9:
        ans = [S] * K + [1] * (N - K)
    else:
        ans = [S] * K + [10 ** 9] * (N - K)

    print(" ".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 17952
#include <cstdio>
#include <iostream>
#define MAX 100
using namespace std;
int N;
int a[MAX];
int cnt=0;
void ss(int *a,int n){
    int minj;
    for(int i=0;i<N;i++){
        minj=i;
        for(int j=i;j<N;j++){
            if(a[j]<a[minj]){
                minj=j;
            }
        }
        swap(a[i],a[minj]);
        if(minj!=i){
            cnt++;
        }
    }
}

int main(){
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    ss(a,N);
    printf("%d",a[0]);
    for(int i=1;i<N;i++){
        printf(" %d",a[i]);
    }
    printf("\n%d\n",cnt);
}


Measured memory_bytes: 3216
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

	int n;
	cin >> n;

	int sum = 0;
	int x = 0;
	for(int i=1; i<=n; i++){
		sum += i;
		if(sum >= n){
			x = i;
			break;
		}
	}
	int dif = sum - n;
	for(int i=1; i<=x; i++){
		if(i == dif){
			continue;
		}
		cout << i << endl;
	}


    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  
   long int n;
  int k;
  scanf("%ld%d",&n,&k);
  int h[n],i,cnt=0;
  for(i=0;i<n;++i)
  {
    scanf("%ld",&h[i]);
    if(h[i]>=k)
        cnt++;
  }
  
  printf("%ld",cnt);
  
}

Measured memory_bytes: 640
# /usr/bin/python
# -*- coding: utf-8 -*-
import math




def get_gcd(a,b):
  if a == 0:
    return b
  else:
    if a > b:
      a,b = b,a
    return get_gcd(b%a,a)


N = int(input())
ans = int(input())
for _ in range(N-1):
  t = int(input())
  ans = ans * t // get_gcd(ans,t)
print(ans)

Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, 0, n)

const int inf = 999999999;
const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	cin.tie(0);
	char x, y;
	cin >> x >> y;
	int xi = x - 'A';
	int yi = y - 'A';
	if (xi < yi) cout << "<";
	else if (xi > yi) cout << ">";
	else cout << "=";
	system("pause");
	return 0;
}

Measured memory_bytes: 504
(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(defparameter N (parse-integer (read-line)))
(defparameter lst (split " " (read-line)))

(defparameter *my-string* (make-array 0
                                      :element-type 'character
                                      :fill-pointer 0
                                      :adjustable t))

(loop for i from 0 below N do
      (vector-push-extend (char (car lst) i) *my-string*)
      (vector-push-extend (char (cadr lst) i) *my-string*))

(format t "~A" *my-string*)


Measured memory_bytes: 12388
import java.io.IOException;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
                while (true) {
            final String[] data = sc.nextLine().split(" ");
            final int n = Integer.parseInt(data[0]);
            final int x = Integer.parseInt(data[1]);
            if (n == 0 && x == 0)
                break;
            int count = 0;
            for (int i = 1; i <= n - 2; i++) {
                for (int j = i + 1; j <= n - 1; j++) {
                    for (int k = j + 1; k <= n; k++) {
                        if ((i + j + k) == x)
                            count++;
                    }
                }
            }
            System.out.println(count);
 
        }
    }
 
}

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

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

    vector<int> v(K);
    for(int i = 0; i < K && N > 0; i++){
        if(i == K-1){
            v[i]++;
            N--;
            i = -1;
            continue;
        }
        v[i]++;
        N--;
    }
    int maxK = *max_element(v.begin(), v.end());
    int minK = *min_element(v.begin(), v.end());
    cout << abs(maxK - minK) << endl;
}

Measured memory_bytes: 256