akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<vd> vvd;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
const int MAX = 1000000000;
const int MOD = 1000000007;
int main(){
  int x;
  cin>>x;
  if(x==7||x==5||x==3){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
}

Measured memory_bytes: 256
function Main(input){
	var xs = input.trim().split(' ').map(v=>parseInt(v,10));
    if(xs[0] <= xs[2] && xs[0] + xs[1] >= xs[2]){
    console.log("YES");
    }else{
    console.log("NO");
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    const double pi = acos(-1);
    double angm = (m / 60.0) * 2 * pi;
    double angh = (h / 12.0) * 2 * pi + (m / 60.0) * 2 * pi / 12;
    //double ang = min(abs(angm - angh), 2 * pi - abs(angm - angh));
    double ang = abs(angm - angh);
    double ans = a * a + b * b - 2 * a * b * cos(ang);
    ans = sqrt(ans);
    cout << fixed << setprecision(10);
    cout << ans << endl;
    //cout << ang << endl;
    //cout << "angm " << angm << endl;
    //cout << "angh " << angh << endl;
    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    std::cout << (n / 500) * 500 << std::endl;
    return 0;
}



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

int main() {
    string res = "";
    int a, b;
    cin >> a >> b;
    if (a > b) {
        int temp = a;
        a = b;
        b = temp;
    }
    for (int i = 0; i < b; i++) {
        res += (a + '0');
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3560
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum mod = 10L^^9 + 7;

void main() {
    auto k = readln.chomp;
    int n = k.length.to!int;
    int d;
    scan(d);

    auto dp = new long[][][](n + 1, 2, d);
    dp[0][0][0] = 1;

    foreach (i ; 0 .. n) {
        foreach (m ; 0 .. 2) {
            foreach (r ; 0 .. d) {
                foreach (a ; 0 .. (m ? 10 : k[i] - '0' + 1)) {
                    (dp[i+1][m | (a < k[i] - '0')][(r + a % d) % d] += dp[i][m][r]) %= mod;
                }
            }
        }
    }

    auto ans = dp[n][0][0] + dp[n][1][0] - 1 + mod;
    ans %= mod;

    writeln(ans);
}


int LIS(T)(T[] arr) {
    import std.range, std.algorithm;

    auto n = arr.length;
    auto dp = repeat(T.max, n + 1).array.assumeSorted;
    dp[0] = T.min;

    int res;

    foreach (i; 0 .. n) {
        auto j = dp.lowerBound(arr[i]).length;
        dp[j] = arr[i];
        res = max(res, j);
    }

    return res;
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 25852
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;


int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    vector<int>dp(n);
    dp[0]=0;
    for(int i=1;i<v.size();i++){
        dp[i] = (v[i-1]>=v[i]) ? dp[i-1]+1 : 0;
    }

    cout<<*max_element(dp.begin(),dp.end())<<endl;
    return 0;
}

Measured memory_bytes: 1024
x, n = map(int, input().split())
p = list(map(int, input().split()))
for base in range(x+1):
    if p.count(x+base*-1) == 0:
        print(x+base*-1)
        break
    if p.count(x+base) == 0:
        print(x+base)
        break

Measured memory_bytes: 9120
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    cin >> n;
    
    long a, max_a = -1000000, min_a = 1000000, total = 0;
    for(int i = 0; i < n; i++){
        cin >> a;
        max_a = max(a, max_a);
        min_a = min(a, min_a);
        total += a;
    }
    
    cout << min_a << " " << max_a << " " << total << endl;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint int
using namespace std;
     
typedef long long lo;
     
template<typename tp> inline void read(tp &x) {
	x = 0; char c = getchar(); int f = 0;
	for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
	for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
	if (f) x = -x;
}

#define GG (puts("NO"), exit(0))
const int N = 3e5 + 233;
int H, W, n, sr, sc;
char S[N], T[N];

int main(void) {
	read(H); read(W); read(n);
	read(sr); read(sc);
	scanf("%s", S + 1);
	scanf("%s", T + 1);
	{
		int l = 0, r = H + 1;
		int die = 0;
		for (int i = n; i >= 1; i--) {
			
			if (T[i] == 'U') r++;
			if (T[i] == 'D') l--;
			l = max(l, 0);
			r = min(r, H + 1);
			if (l + 1 >= r) die = 1;
			
			if (S[i] == 'U') l++;
			if (S[i] == 'D') r--;
			if (l + 1 >= r) die = 1;
			l = max(l, 0);
			r = min(r, H + 1);
		}
		cerr << l << " " << r << " " << die << "\n";
		if (die || sr <= l || sr >= r) GG;
	}
	{
		int l = 0, r = W + 1;
		int die = 0;
		for (int i = n; i >= 1; i--) {
			
			if (T[i] == 'L') r++;
			if (T[i] == 'R') l--;
			l = max(l, 0);
			r = min(r, W + 1);
			if (l + 1 >= r) die = 1;
			
			if (S[i] == 'L') l++;
			if (S[i] == 'R') r--;
			if (l + 1 >= r) die = 1;
			l = max(l, 0);
			r = min(r, W + 1);
		}
		cerr << l << " " << r << " " << die << "\n";
		if (die || sc <= l || sc >= r) GG;
	}
	cout << "YES\n";
}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main(void){
    int h,w;
    cin >> h >> w;
    while(h != 0 || w != 0){
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(i%2 == 0 && j%2 == 0 || i%2 == 1 && j%2 == 1){
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
}



Measured memory_bytes: 3084
import java.util.Scanner;
  
public class Main {
	
  public static void main(String[] args) {
	  Scanner sc=new Scanner(System.in);
	  int S=Integer.parseInt(sc.next());
	 
	  int h=S/(60*60);
	  int m=(S-h*3600)/60;
	  int s=(S-3600*h-60*m);
	  
	  System.out.println(h +":"+ m +":" + s);
    
  }
}

Measured memory_bytes: 17120
import copy

h,w = map(int, raw_input().split(" "))

c = []

def search(num,c,prev,now,nopath):
  if num == 1:
    return now
  mindata = prev + c[num][1]
  for a in range(10):
    if a==1:continue
    if a in nopath:
      continue
    if (prev + c[num][a]) < mindata:
      np2 = copy.deepcopy(nopath)
      np2.append(a)
      q = search(a,c,prev + c[num][a],prev + c[num][1],np2)
      if q < mindata:
        mindata = q
  if mindata < now:
    return mindata
  else:
    return now

for a in range(0,10):
  c.append(map(int, raw_input().split(" ")))

wall = ""

for a in range(h):
  q = raw_input().split(" ")
  for x in q:
    if x != "-1":
      wall += x

#print "%r" % wall

# search num
num = [0]*10
for a in range(10):
  if str(a) in wall:
    num[a] = -1

# search minimum

for a in range(10):
  if a == 1:
    num[a] = 0
  if num[a] == -1:
    q = [a]
    num[a] = search(a,c,0,c[a][1],q)
  else:
    continue

ans = 0
for a in wall:
  ans += num[ int(a) ]
print ans


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int s;
	cin >> s;
	
	bool exist[1000001];
	rep(i, 1000001) exist[i] = false;
	exist[s] = true;
	
	int cnt = 1;
	while (1) {
		if (s % 2 == 0) s = s / 2;
		else s = 3 * s + 1;
		
		if (exist[s]) {
			cout << cnt + 1 << endl;
			return 0;
		}
		exist[s] = true;
		cnt++;
	}
	
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

struct Node{
    vector<ll> par;
};

struct Status{
    bool visited[10];
};

Node node[10];
ll N, M;
ll dfs(ll start, Status status){
    status.visited[start]=true;
    bool existnext=false;
    ll tori=0;
    rep(i, node[start].par.size()){
        if(!status.visited[node[start].par[i]]){
            tori+=dfs(node[start].par[i], status);
            existnext=true;
        }
    }
    bool ok=true;
    rep(i, N){
        if(status.visited[i]==false) ok=false;
    }
    if(!existnext){
        if(ok) tori=1;
        else tori=0;
    }
    return tori;
}



int main(void){
    cin>>N>>M;
    rep(i, M){
        ll a, b;
        cin>>a>>b;
        node[a-1].par.push_back(b-1);
        node[b-1].par.push_back(a-1);
    }
    Status fi;
    rep(i, N){
        fi.visited[i]=false;
    }
    cout<<dfs(0, fi)<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <cassert>
#include <iostream>
#include <string>

int sub(const std::string& s)
{

	int n_red = std::count(s.cbegin(), s.cend(), '0');
	int n_blue = std::count(s.cbegin(), s.cend(), '1');
	assert(n_red + n_blue == s.size());
	return std::min(n_red, n_blue) * 2;
}

int main()
{
	std::string S;
	std::cin >> S;
	std::cout << sub(S) << std::endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
#include <numeric>
#include <cmath>

#define INF 1000000000000000000

using namespace std;
using sl = signed long;
using sll = signed long long;
using ll = long long;


// For debug
template <class T> void print_vecotor(vector<T> vec){
	for(auto v: vec){
		cout << v << " ";
	}
}

int main(int argc, char *argv[])
{
	int N;
	cin >> N;
	int ans = N*N;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main()
{
	int n,y;
	scanf("%d %d",&n,&y);
	int flag=1;
	int i=0,j=0,k=0;
	for(;i<=n;i++)
	{
		for(j=0;j<=n;j++)
		{
			k=n-i-j;
			if(k>=0&&i*10000+j*5000+k*1000==y)
			{
				flag=0;
				printf("%d %d %d",i,j,k);
				break;
			}
		}
		if(!flag)
		{
			break;
		}
	}
	if(flag)
	{
		printf("-1 -1 -1");
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main()
{
    string s;
    cin >> s;
    ll n=s.length();
    ll ans=INF;
    rep(i,n-2){
        ll x=s[i]-'0';
        ll y=s[i+1]-'0';
        ll z=s[i+2]-'0';
        ll v=100*x+10*y+z;
        ans=min(ans,abs(v-753));
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n,m,x,y;
    int t;
    int x1=-199,y1=999;
    cin>>n>>m>>x>>y;
    for(int i=0;i<n;i++){
        cin>>t;
        x1=max(x1,t);
    }
    for(int j=0;j<m;j++){
        cin>>t;
        y1=min(y1,t);
    }
    if(y1<x1) cout<<"War"<<endl;
    else {
        for(int i=x+1;i<=y;i++){
            if(i>x1&&i<=y1){
                cout<<"No War"<<endl;
                return 0;
            }
        }
        cout<<"War"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;


signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<int> A(X), B(Y), C(Z), D, E;
  rep(i, X) cin >> A[i];
  rep(i, Y) cin >> B[i];
  rep(i, Z) cin >> C[i];

  sort(A.begin(), A.end(), greater<int>());
  sort(B.begin(), B.end(), greater<int>());
  sort(C.begin(), C.end(), greater<int>());
  for(int i=0;i<min(K, X);i++){
    for(int j=0;j<min(K, Y);j++){
      D.push_back(A[i]+B[j]);
    }
  }
  sort(D.begin(), D.end(), greater<int>());

  for(int i=0;i<min(K, (int)D.size());i++){
    for(int j=0;j<min(K, Z);j++){
      E.push_back(D[i]+C[j]);
    }
  }
  sort(E.begin(), E.end(), greater<int>());
  for(int i=0;i<K;i++){
    cout << E[i] << endl;
  }
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
string S[14];

int dp[1<<14][14];

int table[14][14];

signed main(){
    while(cin>>N,N){
        rep(i,N)cin>>S[i];
        memset(table,0,sizeof(table));
        fill_n(*dp,(1<<14)*14,1001001001);
        rep(i,N)dp[1<<i][i]=S[i].size();

        rep(i,N){
            rep(j,N){
                if(S[i].find(S[j])!=string::npos)table[i][j]=-1;
                else{
                    for(int k=1;k<=(int)min(S[i].size(),S[j].size());k++){
                        if(S[i].substr(S[i].size()-k,k)==S[j].substr(0,k))table[i][j]=k;
                    }
                }
            }
        }

        reps(i,1,1<<N){
            rep(j,N)if(i>>j&1){
                rep(k,N)if(!(i>>k&1)){
                    if(table[j][k]==-1)chmin(dp[i|(1<<k)][j],dp[i][j]);
                    else chmin(dp[i|(1<<k)][k],dp[i][j]+S[k].size()-table[j][k]);
                }
            }
        }

        int mi=1001001001;
        rep(i,N)chmin(mi,dp[(1<<N)-1][i]);
        cout<<mi<<endl;
    }
    return 0;
}

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define N 200016

vi adj[N];
int p[N], c[N];

void dfs(int u, int p = 0)
{
    for (int v : adj[u]) {
        ctif(v == p);
        c[v] = c[u]^1;
        dfs(v, u);
    }
}

int main()
{
    canhazfast();

    int n;
    vi part[2];
    vi v[3];
    vi a, b;

    cin >> n;
    for (int i = 1; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    for (int i = 1; i <= n; ++i) v[i%3].pb(i);
    dfs(1);
    for (int i = 1; i <= n; ++i) part[c[i]].pb(i);
    if (part[0].size() > part[1].size()) swap(part[0], part[1]);
    for (int i : part[0]) a.pb(i);
    for (int i : part[1]) a.pb(i);
    if (v[0].size() < part[0].size()) {
        for (int i : v[1]) b.pb(i);
        for (int i : v[0]) b.pb(i);
    } else {
        for (int i : v[0]) b.pb(i);
        for (int i : v[1]) b.pb(i);
    }
    for (int i : v[2]) b.pb(i);
    for (int i = 0; i < n; ++i) p[a[i]] = b[i];
    for (int i = 1; i <= n; ++i) cout << p[i] << ' ';
    cout << '\n';

    return 0;
}


Measured memory_bytes: 21524
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    H, W = in_nn()
    s = [list(map(str, in_s())) for _ in range(H)]

    m = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    ans = 'Yes'
    for y in range(H):
        for x in range(W):
            if s[y][x] == '#':
                for px, py in m:
                    nx = x + px
                    ny = y + py
                    if 0 <= nx < W and 0 <= ny < H:
                        if s[ny][nx] == '#':
                            break
                else:
                    ans = 'No'
                    break

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  if (S[0] ==S[1] || S[1] == S[2] || S[2] == S[3]){
    cout << "Bad" << endl;
  }
  else{
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const ll inf = 1000000001;

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

    int x; cin>>x;
    
    for(int a = x; a <= inf; a++){
        bool flag = true;
        for(int j = 2; j < a; j++){
            if(a % j == 0){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << a << ln;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp> 
using namespace boost::multiprecision;
using namespace std;
typedef long long int ll;
vector <vector <ll>> dp;
ll solve(const vector <ll> &pre,ll s,ll e){
	if(s==e){
		return 0;
	}
	if(dp[s][e]!=-1){
		return dp[s][e];
	}
	ll ans = LONG_MAX;
	for(ll i=s;i<e;i++){
		if(s!=0)
			ans = min(ans,pre[e]-pre[s-1]+solve(pre,s,i)+solve(pre,i+1,e));
		else
			ans = min(ans,pre[e]+solve(pre,s,i)+solve(pre,i+1,e));
	}
	return dp[s][e]=ans;
}
int main() {
	ll n;
	cin>>n;
	vector <ll> a(n);
	vector <ll> pre(n,0);
	dp.assign(n,vector <ll> (n,-1));
	for(ll i=0;i<n;i++){
		cin>>a[i];
		if(i==0){
			pre[i]=a[i];
		}
		else{
			pre[i]=a[i]+pre[i-1];
		}
	}
	cout<<solve(pre,0,n-1)<<endl;
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[50][50][2][1<<10];
char m[50][50];
char ms[50][50][10];
struct st{
  int y,x,f,b;
  st(){}
  st(int y,int x,int f,int b):y(y),x(x),f(f),b(b){}
};
int main(){
  memset(m,'#',sizeof(m));
  memset(ms,'#',sizeof(ms));
  int w,h,s;
  int sy,sx,gy,gx;
  cin>>w>>h;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      cin>>m[i][j];
      if(m[i][j]=='%') sy=i,sx=j,m[i][j]='.';
      if(m[i][j]=='&') gy=i,gx=j,m[i][j]='.';
    }
  cin>>s;
  for(int k=0;k<s;k++)
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	cin>>ms[i][j][k];
  memset(dp,-1,sizeof(dp));
  queue<st> q;
  int ax[]={1,-1,0,0};
  int ay[]={0,0,1,-1};
  q.push(st(sy,sx,0,0));
  int ans=-1;
  while(!q.empty()){
    st p=q.front();q.pop();
    if(dp[p.y][p.x][p.f][p.b]<0) dp[p.y][p.x][p.f][p.b]=0;
    int ny,nx,nf,nb,nd=dp[p.y][p.x][p.f][p.b]+1;
    //cout<<p.y<<" "<<p.x<<" "<<p.f<<" "<<p.b<<":"<<nd-1<<endl;
    ny=p.y;nx=p.x;nf=p.f;nb=p.b;
    if(ny==gy&&nx==gx){
      ans=dp[ny][nx][nf][nb];
      break;
    }
    if(m[p.y][p.x]=='|'){
      ny=p.y;nx=p.x;nf=!p.f;nb=p.b;
      if(dp[ny][nx][nf][nb]<0){
	dp[ny][nx][nf][nb]=nd;
	q.push(st(ny,nx,nf,nb));
      }
    }
    if(isalpha(m[p.y][p.x])){
      int c=m[p.y][p.x]-'A';
      if(islower(m[p.y][p.x])) c+='A'-'a';
      ny=p.y;nx=p.x;nf=p.f;nb=p.b;
      if((nb>>c)&1) nb-=1<<c;
      else nb+=1<<c;
      if(ms[ny][nx][c]=='*') nf=!nf;
      if(dp[ny][nx][nf][nb]<0){
	dp[ny][nx][nf][nb]=nd;
	q.push(st(ny,nx,nf,nb));
      }
    }
    for(int k=0;k<4;k++){
      ny=p.y+ay[k];nx=p.x+ax[k];nf=p.f;nb=p.b;
      if(m[ny][nx]=='#') continue;
      int f=isupper(m[ny][nx])||m[ny][nx]=='^';
      for(int i=0;i<s;i++)
	(f+=(nb>>i&1)&&ms[ny][nx][i]=='*')%=2;
      if((f==nf||m[ny][nx]=='|')&&dp[ny][nx][nf][nb]<0){
	dp[ny][nx][nf][nb]=nd;
	q.push(st(ny,nx,nf,nb));
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 23660
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#ifndef STOPIT
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;
#else
#define debug 0;
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & h : v) { is >> h; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int h, n; std::cin >> h >> n;
  std::vector< int > a(n); std::cin >> a;
  a.insert(a.begin(), 0);
  std::vector< int > d(n + 1);
  std::adjacent_difference(all(a), d.begin());
  auto l = 0, r = h, x = 0, y = 0;
  std::vector< std::tuple< int, int, int, int > > record(n + 1);
  auto transpose = [&] {
    std::swap(l, r);
    std::swap(x, y);
    l = h - l, r = h - r;
  };
  auto decrease = [&] (auto d) {
    if (r <= d)
      { l = 0, r = 0, x = h, y = h; }
    else if (l <= d)
      { x += d - l; l = 0, r -= d; }
    else
      { l -= d, r -= d; }
  };
  auto write = [&] (auto i)
    { record.at(i) = std::make_tuple(l, r, x, y); };
  rep(i, 0, n + 1) {
    decrease(d.at(i));
    transpose();
    write(i);
  }
  auto cal = [&] (auto l, auto r, auto offset, auto passed){
    auto ret = 0;
    if (r - l <= offset)
      { cmx(ret, r - passed); }
    else if (0 <= offset)
      { cmx(ret, l + offset - passed); }
    else
      { cmx(ret, l - passed); }
    return ret;
  };
  int q; std::cin >> q;
  loop(q) {
    int t, start; std::cin >> t >> start;
    auto lwr = std::upper_bound(all(a), t) - a.begin() - 1;
    int l, r, x, y; std::tie(l, r, x, y) = record.at(lwr);
    auto passed = t - a.at(lwr);
    auto ret = lwr % 2 == 0
      ? cal(l, r, start - x, passed)
      : h - cal(l, r, h - start - x, passed);
    std::cout << ret << std::endl;
  }
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) { cin >> v[i]; }
  vector<int> a(n);

  rep(i, n) {
    a[v[i] - 1] = i + 1;
  }

  rep(i, n) {
    cout << a[i] << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main () {
  int D;
  cin >> D;
  if (D == 25) cout << "Christmas" << endl;
  if (D == 24) cout << "Christmas Eve" << endl;
  if (D == 23) cout << "Christmas Eve Eve" << endl;
  if (D == 22) cout << "Christmas Eve Eve Eve" << endl;
}

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

int main() {
  ll n, k;
  cin >> n >> k;
  n %= k;
  if (2*n > k) {cout << k-n << endl;}
  else {cout << n << endl;}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) ((c).rbegin(),(c).rend())
//#define sort(v,n) sort(v,v+n)
#define ll long long
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;

int main() {
	while (cin >> n, n) {
		int a[5001];
		ll s[5001];
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			if (i == 0) {
				s[0] = a[0];
			}
			else {
				s[i] = s[i - 1] + a[i];
			}
		}

		ll ans=-500000000;
		for (int i = 0; i < n; i++) {
			ans = max(ans, s[i]);
			for (int j = 0; j < i; j++) {
				if (s[i] - s[j] > s[i]) {
					ans = max(ans, s[i] - s[j]);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3020
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;

int main(){
  bool end_flag=false;
  long long int N;
  vector<long long int> A;
  cin >> N;
  A.resize(N);
  cin >> A[0];
  if(A[0] != 0){
    end_flag = true;
  }
  for(int i=1; i<N; ++i){
    cin >> A[i];
    if(A[i] - A[i-1] > 1){
      end_flag = true;
    }
  }

  if(end_flag){
    cout << -1 << endl;
    return 0;
  }

  long long int count = 0;
  for(int i=1; i<N; ++i){
    if(A[i] == A[i-1]+1){
      count+=1;
    }else{
      count+=A[i];
    }
  }

  cout << count << endl;
  return 0;
}

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

typedef struct node {
    int key;
    struct node *parent, *left, *right;
} Node;

Node *root;

void Insert(int key) {
    Node *x = root, *y = NULL, *z;    
    z = (Node *)malloc(sizeof(Node));
    z->left = NULL;
    z->right = NULL;
    z->parent = NULL;
    z->key = key;
    //cout << root << endl;
    while (x != NULL) {
        //cout << x << endl;
        y = x;
        if (z->key < x->key) x = x->left;
        else x = x->right;
    }
    //cout << "ok" << endl;
    z->parent = y;
    //cout << y << endl;

    if (y == NULL) root = z;
    else if (z->key < y->key) y->left = z;
    else y->right = z;
}

void mid_dfs(Node *x) {
    if (x->left != NULL) mid_dfs(x->left);
    cout << " " << x->key;
    if (x->right != NULL) mid_dfs(x->right);
}

void pre_dfs(Node *x) {
    cout << " " << x->key;
    if (x->left != NULL) pre_dfs(x->left);
    if (x->right != NULL) pre_dfs(x->right);
}

void print() {
    mid_dfs(root);
    cout << endl;
    pre_dfs(root);
    cout << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string ope;
        cin >> ope;

        if (ope == "insert") {
            int k;
            cin >> k;
            Insert(k);
        }
        else {
            print();
        }
    }
}



Measured memory_bytes: 26444
def main():
    h, w = map(int, input().split())
    if h % 3 == 0 or w % 3 == 0:
        print(0)
        exit()

    ans = h * w
    for _ in range(2):
        i = h // 3
        j = w // 2

        x = [(i - 1, h - i + 1), (i, h - i), (i + 1, h - i - 1)]
        y = [(j - 1, w - j + 1), (j, w - j), (j + 1, w - j - 1)]
        for (u, v) in x:
            # case1
            a, b = v // 2, v - v // 2
            s = [w * u, w * a, w * b]
            d = max(s) - min(s)
            ans = min(ans, d)
            for (s, t) in y:
                # case2
                s = [u * w, v * s, v * t]
                d = max(s) - min(s)
                ans = min(ans, d)

        w, h = h, w
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define pb push_back
#define ff first
#define ss second

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    vector<int>v(2*n);
    for(int i=0;i<2*n;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    int ans=0;
    for(int i=1;i<2*n;i+=2)
        ans+=v[i-1];
    cout<<ans<<"\n";
    return 0;
}
/**

**/


Measured memory_bytes: 256
X,=list(map(int,input().split()))
A=1
while((A+1) ** 5-A ** 5<10 ** 9):
  A+=1 
for j in range(10000):
  for i in range(-A,A+1):  
    if((i+j) ** 5 - i ** 5==X):
      print(i+j,i)
      exit()


Measured memory_bytes: 9184
a, b, c, d, e, f = map(int, input().split())

waters = []
sugars = []

for w in range(f // 100):
    for i in range(0, w+1, a):
        if (w - i) % b == 0:
            waters.append(w)
            break
for s in range(f):
    for i in range(0, s+1, c):
        if (s - i) % d == 0:
            sugars.append(s)
            break

answ = a
anss = 0

for w in waters:
    for s in sugars:
        if 100 * w + s > f:
            continue
        if s > e * w:
            continue
        if w == 0:
            continue
        if s / w > anss / answ:
            answ = w
            anss = s
print(answ*100+anss, anss)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

int main(){
	int n,ma,mb;
	cin>>n>>ma>>mb;
	vvi med(n,vi(3));
	for(auto&l:med)for(auto&i:l)cin>>i;
	
	vector<vvi> dp(n+1,vvi(401,vi(401,10000)));
	dp[0][0][0]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=10*(i-1);j++){
			for(int k=0;k<=10*(i-1);k++){
				if(dp[i-1][j][k]!=10000){
					dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]);
					dp[i][j+med[i-1][0]][k+med[i-1][1]]=
						min(dp[i][j+med[i-1][0]][k+med[i-1][1]],
							dp[i-1][j][k]+med[i-1][2]);
				}
			}
		}
	}
	int ans=10000;
	for(int i=1;i*max(ma,mb)<=n*10+1 && i<dp[n].size();i++){
		ans=min(ans,dp[n][ma*i][mb*i]);
	}
	if(ans==10000) ans=-1;
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 27264
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map(String::toLong)
    val sortedList = (1..N).map { readLine()!!.split(" ").map(String::toLong) }.sortedBy { it[0] }
    var sum = 0L
    for (pair in sortedList) {
        sum += pair[1]
        if (sum >= K) {
            println(pair[0])
            break
        }
    }
}


Measured memory_bytes: 84460
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int l = s.size();
  if(l == 2 && s[0] == s[1]){
    cout << 1 << " " << 2 << endl;
    return 0;
  }
  for(int i = 0; i < l-2; ++i){
    if(s[i] == s[i+1] || s[i] == s[i+2]){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define lli long long int  
#define ll  long long 
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(),v.rend() //reverse
#define vl   vector<lli>
#define mii unordered_map<ll,ll>
#define pb push_back
double pi = 2*acos(0.0); const int INF = 1e9 + 5;
ull power(ll a,ll b){ ll res=1;while(b){if(b&1)res=res*a;b=b/2; a=(a*a); }return res;}
 //bool sortinrev(const pair<int,int> &a,   const pair<int,int> &b) {  if(a.first==b.first) return a.second>b.second;  return (a.first < b.first);} 
              
 

 void Pitch(){
  lli n,k;
  cin>>n>>k;
  vl v(n);
  for(int i=0;i<n;i++)
  {
  	cin>>v[i];

  }
  vl dp(n,INF); 
   dp[0]=0; 
  for(int i=0;i<n;i++)
  {
  	for(int j=i+1;j<=i+k;j++)
  	{
  		if(j<n)
  		{
  			dp[j]=min(dp[j],dp[i]+abs(v[i]-v[j]));
  		}
  	}
  }
  cout<<dp[n-1]<<endl;


 	
 }
    
       
       	 
          
                
       
 signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	lli tst;
       tst=1; 
       //cin>>tst;
       while(tst--) Pitch();
       return 0;
      } 

Measured memory_bytes: 4768
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
	ll n,ans=0;
	cin>>n;
	vector<ll> a(n);
	for(ll i=0;i<n;i++)
		cin>>a[i];
	sort(a.begin(),a.end());
	ll x=ceil(n/2.0);
		cout<<a[x]-a[x-1];
	// cout<<ans;
    return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}

Measured memory_bytes: 3992
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int[]> numbers = new List<int[]>();
            while (true)
            {
                int[] data = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if (data[0] == 0 && data[1] == 0) break;                    
                else numbers.Add(data);
            }

            int[] comb = new int[numbers.Count];
            for (int i = 0; i < numbers.Count; i++)
            {
                int n = numbers[i][0];
                int x = numbers[i][1];
                int x1, x2, x3;
                for (int k = 0; k < n-2; k++)
                {
                    x1 = k + 1;
                    for (int l = 0; l < n-1; l++)
                    {
                        x2 = x1 + l + 1;
                        x3 = x - (x1 + x2);
                        if (x2 < x3 && x3 <= n)
                        {
                            comb[i] += 1;
                        }
                    }
                }
            }
            foreach(int item in comb)
            Console.WriteLine(item);

        }
    }
}


Measured memory_bytes: 18396
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    int ans = max(0, min(b, d) - max(a, c));
    cout << ans << endl;

    return 0;
}


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

int main(){
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int tmp;
    cin >> tmp;
    cout << a[tmp - 1] << endl;
}

Measured memory_bytes: 3568
<?php
$N = intval(trim(fgets(STDIN)));
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));
$B = array_map("intval", explode(" ", trim(fgets(STDIN))));
$dp = array_fill(0, 1<<$N, array_fill(0,51,PHP_INT_MAX));
$dp[0][0] = 0;
for($bit = 0, $NN = 1<<$N; $bit < $NN; ++$bit){
    $con = 0;
    $x = $bit;
    while ($x) {  
        $x &= $x-1;  
        ++$con;  
    }
     
    $ords = [];
    $iter = $con - 1;
    for($i = 0; $i < $N; ++$i)
        if(!($bit & (1<<$i)))
            $ords[$i] = ++$iter;
    for($s = 0; $s <= 50; ++$s){
        if($dp[$bit][$s] == PHP_INT_MAX)continue;
        foreach($ords as $p0 => $p1){
            $ns = ($p0-$con) & 1 ? $B[$p0] : $A[$p0];
            if($ns >= $s){
                $dp[$bit | (1<<$p0)][$ns] = min($dp[$bit|(1<<$p0)][$ns], $dp[$bit][$s] + abs($p1 - $con));
            }
        }
    }
}
$min = min($dp[(1<<$N)-1]);
if($min == PHP_INT_MAX){
    echo -1;
}else{
    echo $min;
}


Measured memory_bytes: 682488
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long

signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n)cin >> a[i];
  sort(a.begin(),a.end());
  int m;
  cin >> m;
  vector<int> b(m);
  rep(i,m)cin >> b[i];
  sort(b.begin(),b.end());
  int id = 0;
  rep(i,n) {
      if(b[id]==a[i])id++;
      if(id>=m) {
          cout << "YES" << endl;
          return 0;
      }
  }
  cout << "NO" << endl;
}



Measured memory_bytes: 6420
import sys

n = input()
x = list(map(int,input().split()))
ans = sys.maxsize

# i = min(x)
# while i <= max(x):
for i in range(min(x),max(x)+1,1):
    tmp = sum(map(lambda p: (p-i)**2,x))
    if ans > tmp:
        ans = tmp
    # i += 1
print(ans)

Measured memory_bytes: 9084
function Main(input) {
  const lines = input.split("\n");
  const [a, b, k] = lines[0].split(' ').map(v => v*1);
  const aDelta = a - k;
  const aRest = aDelta < 0 ? 0 : aDelta;
  let bRest = b + (aDelta < 0 ? aDelta : 0);
  bRest = bRest < 0 ? 0 : bRest;
  
  console.log(aRest + ' ' + bRest);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        "\n"
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
  int n,k;
  cin>>n>>k;
  ll sum=0;
  ll min=0;
  	for(int i=0;i<k;i++)
  	min+=i;
  ll max=0;
	  for(int i=n;i>n-k;i--)
  	   max+=i;
  	sum=max-min+1;
  	k++;
  while(k<=n+1)
  {
  	
    
	  min+=k-1; 	
      max+=n-k+1;
  	sum+=max-min+1;
  	   sum%=mod;
   k++;
   } 
  
cout<<sum<<endl;

}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

int main(){
  int n;
  double h,m;
  string s;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    cin >> s;
    int st = s[0] == '0'?1:0;
    h = (atoi)(s.substr(st,s[0]=='0'?1:2).c_str());
    st = s[3] == '0'?4:3;
    m = (atoi)(s.substr(st,s[3]=='0'?1:2).c_str());
    h = h*30+m*0.5;
    m = m*6;
    double dif=fabs(h-m);
    if(fabs(h-m) > 180)dif = 360-dif;
    if(0<= dif&& dif < 30)cout << "alert" << endl;
    else if(90 <= dif && dif <= 180)cout << "safe" << endl;
    else cout << "warning" << endl;  


  }

  return 0;
}



/*
時計の針は

いきなりうごくわけじゃあない
 */

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(num) scanf("%d",&num)
#define sff(num1,num2) scanf("%d %d",&num1,&num2)
#define sfff(num1,num2,num3) scanf("%d %d %d",&num1,&num2,&num3);
#define sl(num) scanf("%lld",&num)
#define sll(num1,num2) scanf("%lld %lld",&num1,&num2)
#define slll(num1,num2,num3) scanf("%lld %lld %lld",&num1,&num2,&num3);
#define rep(i,n) for(i=1;i<=n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define pb push_back
#define mpp make_pair
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define TIME cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<"s\n";
typedef long long int ll;
using namespace std;
int main()
{
    ll a,b,c,d,cnt=0;
    cin>>a>>b>>c>>d;
    a--;
    ll ans=b-a+1;
    ll x=b/c,y=a/c;
    cnt+=(x-y+1);
    x=b/d,y=a/d;
    cnt+=(x-y+1);
    ll l=(c/__gcd(c,d))*d;
    x=b/l,y=a/l;
    cnt-=(x-y+1);
    cout<<ans-cnt;

}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    bool isTakahashiTurn = true;
    while (a > 0 && c > 0) {
        if (isTakahashiTurn) {
            c -= b;
        } else {
            a -= d;
        }
        isTakahashiTurn = !isTakahashiTurn;
    }

    cout << (a > 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3656
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a+b==15){
    cout << "+" << endl;
  }else if(a*b==15){
    cout << "*" << endl;
  }else{
    cout << "x" << endl;
  }
  return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    map<ll, ll> M;
    REP(i, N){
        ll a;
        cin >> a;

        M[a]++;
        M[a+1]++;
        M[a-1]++;
    }

    ll ans = 0;
    for(auto iter = M.begin(); iter != M.end(); iter++){
        ans = max(ans, iter->second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9360