akhauriyash/Code-Regression huggingface dataset:
n = int(input())
l = []
for i in range(n):
    x,y = map(int,input().split())
    l.append((x,y))

d = dict()
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        x1,y1 = l[i]
        x2,y2 = l[j]
        if d.__contains__((x2-x1,y2-y1)):
            d[(x2-x1,y2-y1)] += 1
        else:
            d[(x2-x1,y2-y1)] = 1

ll = list(d.values())
if ll == []:
    maxV = 0
else:
    maxV = max(list(d.values()))

print(n-maxV)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<double, double>P;
typedef tuple<ll, int, int>T;
#define PI 3.14159265358979
#define MOD (ll)1000000007

int main(){
  int N;
  cin>>N;
  vector<ll>A(N);
  rep(i,N){cin>>A[i];}
  ll dp[N][N][2];
  rep(i,N){rep(j,N){dp[i][j][0]=10000000000000ll;dp[i][j][1]=0ll;}}
  rep(i,N){dp[i][i][0]=0ll;dp[i][i][1]=A[i];}
  for(int k=1;k<N;k++){
    rep(i,N){
      int j=i+k;
      if(j>=N){break;}
      for(int x=i;x<j;x++){
        dp[i][j][0]=min(dp[i][j][0],dp[i][x][0]+dp[x+1][j][0]+dp[i][x][1]+dp[x+1][j][1]);
        dp[i][j][1]=dp[i][x][1]+dp[x+1][j][1];  
      }
    }
  }
  cout<<dp[0][N-1][0]; 
}

Measured memory_bytes: 2688
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

static const int N = 100;
static const int INFTY = (1<<21);

int n,M[N][N];
int d[N];

void bfs(int s){
  queue<int> q;
  q.push(s);
  for(int i=0;i<n;i++) d[i] = INFTY;
  d[s] = 0;
  int u;
  while(!q.empty()){
    u = q.front();
    q.pop();
    for(int v=0;v<n;v++){
      if(M[u][v] == 0) continue;
      if(d[v] != INFTY) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for(int i=0;i<n;i++){
    cout << i+1 << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
  }
}

int main(){
  int u,k,v;

  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++) M[i][j] = 0;
  }

  for(int i=0;i<n;i++){
    cin >> u >> k;
    u--;
    for(int j=0;j<k;j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  bfs(0);
  return 0;
}



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

using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x,y;
    while(true)
    {   cin >> x >> y;
        if(!x && !y) break;
        else if(x > y) cout << y << " " << x <<endl;
        else cout << x << " " << y <<endl;
    }
    return 0;


}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <iomanip>
#include <math.h>
#include <algorithm>
#define hmm "\n"
#define test() int t; cin>>t; while(t--)
#define ll long long int
#define ull unsigned long long
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
void solve()
{
  ll k,x;
  cin>>k>>x;
  if(k*500>=x)
    cout<<"Yes\n";
  else
    cout<<"No\n";
    
}
int main()
{
    fastIO
    //test()
    solve();
}


Measured memory_bytes: 256
list = input().split(" ")
N = int(list[0])
K = int(list[1])
list_hp = input().split(" ")
list_hp = [int(i) for i in list_hp]
list_hp = sorted(list_hp)

if K < N:
    sum = 0
    for i in range(N-K):
        sum = sum + list_hp[i]
    print(sum)
else:
    print(0)

Measured memory_bytes: 87772
#include <iostream>

using namespace std;

int main()
{
    int n,i,j,s,count=0;
    cin >>n;
    for(int i=1;i<=n;i++){
        cin >> s;
        if(s!=i){
            count++;
        }
    }
    if(count==2){
        cout << "YES" << endl;
    }
    else if(count==0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


ll dp[310][310];
ll gas[310][310];

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

    rep(i, 310){
        rep(j, 310){
            dp[i][j] = inf;
            gas[i][j] = inf;
        }
        dp[i][i] = 0;
        gas[i][i] = 0;
    }

    int n, m, a, b, c;
    ll l;
    cin >> n >> m >> l;

    rep(i, m){
        cin >> a >> b >> c;
        dp[a][b] = c;
        dp[b][a] = c;
    }

    rep(k, n+1){
        rep(i, n+1){
            rep(j, n+1){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }

    rep(i, n+1){
        rep(j, n+1){
            if(dp[i][j] <= l) gas[i][j] = min(gas[i][j], 1LL);
        }
    }

    rep(k, n+1){
        rep(i, n+1){
            rep(j, n+1){
                gas[i][j] = min(gas[i][j], gas[i][k] + gas[k][j]);
            }
        }
    }

    int q, s, t;
    cin >> q;
    rep(i, q){
        cin >> s >> t;
        if(gas[s][t] >= 1e9){
            cout << -1 << endl;
        }else{
            cout << gas[s][t]-1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ii d[MAXn];
priority_queue<ll,vector<ll>,greater<ll> > pq;
bool color[MAXn];
int main(){
  IOS();
  ll n,k;
  cin >> n >> k;
  REP (i,n) {
    cin >> d[i].X >> d[i].Y;
    d[i].X--;
  }
  sort(d,d+n,[&](ii a,ii b){return a.Y > b.Y;});
  pary(d,d+n);

  ll sum = 0, cnt = 0;
  REP (i,k) {
    if (color[d[i].X]) {
      sum += d[i].Y;
      pq.emplace(d[i].Y);
    }
    else {
      color[d[i].X] = true;
      sum += 2*cnt+1;
      cnt++;
      sum += d[i].Y;
    }
  }

  ll ans = sum;
  for (ll i=k;i<n;i++) {
    if (!SZ(pq)) break;
    if (color[d[i].X]) continue;
    color[d[i].X] = true;
    sum -= pq.top();
    pq.pop();
    sum += 2*cnt+1;
    cnt++;
    sum += d[i].Y;
    ans = max(ans,sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2556
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n, x = 0, max = x;
		String s;
		
		n = sc.nextInt();
		s = sc.next();
		
		sc.close();
		
		for(int i = 0; i < n; ++i) {
			if(s.charAt(i) == 'I')++x;
			else if(s.charAt(i) == 'D')--x;
			max = Math.max(max,  x);
		}
		
		System.out.println(max);
	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,Y;
cin>>N>>Y;
  bool ans=false;
  bool bbb=false;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      if(10000*i+5000*j+1000*(N-i-j)==Y){
        ans=true;
        cout<<i<<" "<<j<<" "<<N-i-j<<endl;
        bbb=true;
        break;
      }
    }
    if(bbb) break;
  }
  if(!ans) cout<<"-1 -1 -1"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define l cout<<endl

const int mod=1e9 + 7;

using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;
	vector<int>vec(n+1,-1);
	for(int i=1;i<=n;i++) cin>>vec[i];
	vector<vector<int> >dp(n+1,vector<int>(k+1,0));
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		vector<int>sum(k+1);
		sum[0]=dp[i-1][0];
		for(int s=1;s<=k;s++) sum[s]=(sum[s-1]%mod+dp[i-1][s]%mod)%mod;
		for(int j=0;j<=k;j++)
		{
			if(j-vec[i]-1>=0) dp[i][j]=(sum[j]%mod-sum[j-vec[i]-1]%mod+mod)%mod;
			else dp[i][j]=sum[j]%mod;
		}
	}
	//cout<<mod;
	//l;
	cout<<dp[n][k];
	
	return 0;
}

Measured memory_bytes: 41468
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n,d;
    cin>>n>>d;
    lli ans=0;
    ans=n/(2*d+1);
    if(n%(2*d+1)!=0){ 
        ans++;
    }
    out(ans)
}

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

typedef long long ll;

string s1;
string s2;
ll n1;
ll n2;
ll memo[3001][3001];
char mm[3001][3001];
int mm1[3001][3001];

ll func(ll i,ll j)
{
	if(i == n1-1 && j==n2-1)
	{
		if(s1[i] == s2[j])
			{
				mm[i][j]=s1[i];
				mm1[i][j]=0;
				return 1;
			}
		else
			return 0;
	}
	if(i == n1-1)
	{
		if(s1[i] == s2[j])
			{
				mm[i][j]=s1[i];
				mm1[i][j]=0;
				return 1;
			}
		else
			return func(i,j+1);
	}
	if(j == n2-1)
	{
		if(s1[i] == s2[j])
			{
				mm[i][j]=s1[i];
				mm1[i][j]=0;
				return 1;
			}
		else
			return func(i+1,j);
	}
	// if(i == n1-1 || j == n2-1)
	// {
	// 	if(s1[i] == s2[j])
	// 		{
	// 			mm[i][j]=s1[i];
	// 			mm1[i][j]=0;
	// 			return 1;
	// 		}
	// 	else
	// 	{
	// 		if(i==n1-1)
	// 		{
	// 			while( j != n2-1)
	// 			{
	// 				if(s1[i] == s2[j])
	// 				{
	// 					mm[i][j]=s1[i];
	// 					mm1[i][j]=0;
	// 					return 1;
	// 				}
	// 				j++;
	// 			}
	// 			if(s1[i] == s2[j])
	// 			{
	// 				mm[i][j]=s1[i];
	// 				mm1[i][j]=0;	
	// 				return 1;
	// 			}
	// 			else
	// 				return 0;
	// 		}
	// 		else
	// 		{
	// 			while( i != n1-1)
	// 			{
	// 				if(s1[i] == s2[j])
	// 				{	
	// 					mm[i][j]=s1[i];
	// 					mm1[i][j]=0;
	// 					return 1;
	// 				}
	// 				i++;
	// 			}
	// 			if(s1[i] == s2[j])
	// 				{
	// 					mm[i][j]=s1[i];
	// 					mm1[i][j]=0;
	// 					return 1;
	// 				}
	// 			else
	// 				return 0;
	// 		}
	// 	}
	// }
	if(memo[i][j]!=-1)
		return memo[i][j];
	
	if(s1[i] == s2[j])
	{
		memo[i][j]=1+func(i+1,j+1);
		//mm[i][j]=make_pair(i+1,j+1);
		mm[i][j]=s1[i];
		mm1[i][j]=0;
		return memo[i][j];
	}
	else
	{
		ll tt=func(i+1,j);
		ll t1=func(i,j+1);
		memo[i][j]=max(tt,t1);
		if(tt>t1)
			mm1[i][j]=1;
		else
			mm1[i][j]=2;
		return memo[i][j];
	}
 }


int main() 
{
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef DEBUG
     		//freopen("input.txt", "rt", stdin);
 	#endif
	cin >> s1;
	cin >> s2;
	s1+='a';
	s2+='z';
	n1=s1.length();
	n2=s2.length();

	for(int i=0;i<3001;i++)
	{
		for(int j=0;j<3001;j++)
		{
			memo[i][j]=-1;
			mm[i][j]='1';
			mm1[i][j]=-1;
		}
	}
	
	ll vv = func(0,0);
	int i=0;
	int j=0;
	int count=0;
	while(mm1[i][j]!=-1)
	{
		if(mm1[i][j]==0)
		cout<<mm[i][j];
		if(mm1[i][j]==0)
		{
			i++;
			j++;
		}
		else if(mm1[i][j]==1)
		{
			i++;
		}
		else
		{
			j++;
		}
	}
	cout<<"\n";
 	return 0;	
}


Measured memory_bytes: 114944
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ins insert
#define sz(x) (long long)x.size()
typedef long long ll;
typedef long double ld;
const int N = 100005;
const ld pi = 3.141592653;
const ll MOD = 1000000007;

using namespace std;

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

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int T = 1;
        //cin>>T;
        while(T--)
        {
            ll i, p, n, ans=0;
            vector<int> spf(10000005);
            for(i=0; i<sz(spf); i++) spf[i]=i;
            for(i=2; i*i<sz(spf); i++)
            {
                if(spf[i]==i)
                {
                    for(p=i*i; p<sz(spf); p=p+i)
                    {
                        if(spf[p]==p) spf[p]=i;
                    }
                }
            }
            cin>>n;
            for(i=1; i<=n; i++)
            {
                map<ll, ll> m;
                ll x = i, p=1;
                while(x>1)
                {
                    if(m.find(spf[x])!=m.end()) m[spf[x]]++;
                    else m.ins({spf[x], 1});
                    x = x/spf[x];
                }
                for(auto &o: m) p=p*(o.se+1);
                ans = ans + i*p;
            }
            cout<<ans;
        }
        return 0;
}

Measured memory_bytes: 42224
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    
    
    double N, M;
    long long sum = 0;
    
    
    cin >> N >> M;
    vector<double> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum += A[i];
    }
    
    
    
    double miman = sum / (4 * M);
    
    int ans = M;
    for(int i = 0; i < N; i++){
        if(A[i] >= miman){
            --ans;
        }
    }
    
    if(ans <= 0){
        cout << "Yes" << endl;
        return 0;
    }

    else cout << "No" << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define MAX_V 10000
using namespace std;

/*?????§?????¢?????´?????????(Ford_Fulerson????????¨)???O(F|E|)*/

//????????¨????§???????(???????????????????????????)
struct edge{int to, cap, rev;};

vector<edge> G[MAX_V]; //??°???????????£??\?????????
bool used[MAX_V];      //DFS??§?????§??????????????????????????°

void init(){
  for(int i=0;i<MAX_V;i++) G[i].clear();
}

//from??????to??????????????????cap???????????°?????????????????????
void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,(int)G[to].size()});
  G[to].push_back((edge){from,0,(int)G[from].size()-1});  
}

//?¢?????????????DFS??§??¢???
int dfs(int v,int t,int f){
  if(v == t)return f;
  used[v]=true;
  for(int i=0; i<G[v].size() ;i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to ,t , min(f,e.cap));
      if(d > 0){
	e.cap -= d;
	G[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

//s??????t???????????§???????±???????
int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s, t, INF);
    if(f == 0)return flow;
    flow += f;
  }
}

int main(){
  
  int H, W, C, M, Nw, Nc, Nm;
  
  while(1){
    
    cin>>H>>W>>C>>M>>Nw>>Nc>>Nm;
    if(H==-1) break;

    init();
    
    int s=0;
    int Hws=(H+W+C+M)*2+1, Hwt=Hws+1;
    int Hcs=Hwt+1, Hct=Hcs+1;
    int Hms=Hct+1, Hmt=Hms+1;
    int t=Hmt+1;

    for(int i=1;i<=H;i++){
      add_edge(s,i*2-1,1);
      add_edge(i*2-1,i*2,1);
      add_edge(i*2,Hws,1);
    }
    
    for(int i=1;i<=W;i++){
      int n;
      cin>>n;
      add_edge((H+i)*2-1,(H+i)*2,1);
      add_edge((H+i)*2,Hcs,1);
      for(int j=0;j<n;j++){
	int a;
	cin>>a;
	add_edge(a*2,(H+i)*2-1,1);
      }
    }
    
    for(int i=1;i<=C;i++){
      int n;
      cin>>n;
      add_edge(Hwt,(H+W+i)*2-1,INF);
      add_edge((H+W+i)*2-1,(H+W+i)*2,1);
      add_edge((H+W+i)*2,Hms,1);
      for(int j=0;j<n;j++){
	int a;
	cin>>a;
	add_edge((H+a)*2,(H+W+i)*2-1,1);
      }
    }
    
    for(int i=1;i<=M;i++){
      int n;
      cin>>n;
      add_edge(Hct,(H+W+C+i)*2-1,INF);
      add_edge((H+W+C+i)*2-1,(H+W+C+i)*2,1);
      add_edge((H+W+C+i)*2,t,1);
      for(int j=0;j<n;j++){
	int a;
	cin>>a;
	add_edge((H+W+a)*2,(H+W+C+i)*2-1,1);
      }
    }

    add_edge(Hws,Hwt,Nw);
    add_edge(Hcs,Hct,Nc);
    add_edge(Hms,Hmt,Nm);
    add_edge(Hmt,t,INF);
    
    cout<<max_flow(s, t)<<endl;
  }
  
  return 0;
}

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

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

int memo[6][6][6][6];

int dfs(int a,int b,int c,int d){
    if(a==5&&b==5)return 0;
    int &ret=memo[a][b][c][d];
    if(ret!=-1)return ret;
    ret=0;
    if(c!=5){
        if(a!=5)ret|=dfs(min(5ll,c+a),d,a,b)==0;
        if(b!=5)ret|=dfs(min(5ll,c+b),d,a,b)==0;
    }
    if(d!=5){
        if(a!=5)ret|=dfs(c,min(5ll,d+a),a,b)==0;
        if(b!=5)ret|=dfs(c,min(5ll,d+b),a,b)==0;
    }
    return ret;
}

signed main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    memset(memo,-1,sizeof(memo));
    cout<<(dfs(a,b,c,d)?"ISONO":"NAKAJIMA")<<endl;
    return 0;
}

Measured memory_bytes: 3080
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();
        final int K = sc.nextInt();

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            final int A = sc.nextInt();
            if (!map.containsKey(A)) map.put(A, 0);
            map.put(A, map.get(A) + 1);
        }

        if (map.size() <= K) {
            System.out.println(0);
            return;
        }

        final int L = map.size() - K;
        int ans = map.values().stream().sorted().limit(L).mapToInt(Integer::valueOf).sum();
        System.out.println(ans);
    }
}


Measured memory_bytes: 99880
#include<cstdio>

const int N_MAX = 200'000;
int a[N_MAX+1];

int main() {
	int n;
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		scanf("%d", &a[i]);
	}
	a[n] = 0;
	long long count = 0;
	for(int i=n-1;i>=0;i--) {
		if(a[i+1]-1 > a[i] || a[i] > i) {
			count = -1;
			break;
		}
		if(a[i+1]-1 < a[i]) {
			count += a[i];
		}
	}
	printf("%lld\n", count);
	return 0;
}


Measured memory_bytes: 1024
import sys
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()


n=int(input())
a, b, c = [], [], []
for _ in range(n):
    x,y,z=get_ints()
    
    a.append(x)
    b.append(y)
    c.append(z)
li=[[-1 for i in range(3)]for j in range(n)]
li[0][0],li[0][1],li[0][2]=a[0],b[0],c[0]
for i in range(1,n):


        li[i][0] = max(a[i] + li[i-1][1] ,a[i] + li[i - 1][2])

        li[i][1] = max(b[i] + li[i - 1][0], b[i] +li[i - 1][2])

        li[i][2] = max(c[i] + li[i - 1][1], c[i] + li[i - 1][0])
print(max(li[n-1]))



Measured memory_bytes: 36188
//
// Created by Yoshiki Shino on 2018/07/01.
//

#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>
    using namespace std;
    typedef long long unsigned 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() {
        int N;
        cin >> N;

        if (N % 2 == 0) {
            cout << N << endl;
        } else {
            cout << N * 2 << endl;
        }

        return 0;
    }

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

#define null				""
#define all(dat)			dat.begin(), dat.end()
#define over(msg)			cout << msg << endl, exit(0);
#define loop(i, to)			for (int i = 0; i < to; ++i)
#define cont(i, to)			for (int i = 1; i <= to; ++i)
#define foreach(i, dat)		for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long			num;

using namespace std;

int n, h[100005], dp[100005];

int main() {
	cin >> n;
	cont (i, n) {
		cin >> h[i];
		dp[i] = 2e9;
	}
	dp[1] = 0;
	cont (i, n) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 1024
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto a = ['a', 'i', 'u', 'e', 'o'];
  auto c = readln.chomp.to!char;
  if (a.count(c)) {
    writeln("vowel");
  } else {
    writeln("consonant");
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    int INF = -1e9;
    vector<int> dpk(N + 1, INF), A(M);
    for(int i = 0; i < M; i++) cin >> A[i];
    sort(A.begin(), A.end());
    vector<int> cost(M);
    for(int i = 0; i < M; i++){
        if(A[i] == 1) cost[i] = 2;
        else if(A[i] == 2 || A[i] == 3 || A[i] == 5) cost[i] = 5;
        else if(A[i] == 4) cost[i] = 4;
        else if(A[i] == 6 || A[i] == 9) cost[i] = 6;
        else if(A[i] == 7) cost[i] = 3;
        else cost[i] = 7;
    }
    dpk[0] = 0;
    for(int i = 1; i < N + 1; i++){
        for(int j = 0; j < M; j++){
            if(i - cost[j] >= 0) dpk[i] = max(dpk[i], dpk[i - cost[j]] + 1);
        }
    }
    int keta = dpk[N];
    vector<int> ke(keta);
    int i = 0;
    while(N > 0){
        for(int j = M - 1; j >= 0; j--){
            if(i == keta - 1){
                for(int j = M - 1; j >= 0; j--){
                    if(cost[j] == N){
                        ke[i] = A[j];
                        N -= cost[j];
                        i++;
                        break;
                    }
                }
            }
            else if(N - cost[j] >= 0 && dpk[N] == dpk[N - cost[j]] + 1){
                ke[i] = A[j];
                i++;
                N -= cost[j];
                break;
            }
        }
    }
    for(int i = 0; i < keta; i++){
        cout << ke[i];
    }
    cout << endl;
}

Measured memory_bytes: 3616
import sys
input = sys.stdin.readline

N = int(input())
S = input()

W_num = [0] * N
E_num = [0] * N

for i in range(1, N):
    k = N - (i - 1) - 2
    W_num[i] = W_num[i-1] + 1 if S[i-1] == 'W' else W_num[i-1]
    E_num[k] = E_num[k+1] + 1 if S[k+1] == 'E' else E_num[k+1]

print(min([W_num[i] + E_num[i] for i in range(N)]))


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

#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)


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

    vector<double> p(n + 1);

    for(int i = 1; i <= n; i++)
        cin >> p[i];

    vector<vector<double>> dp(n + 3, vector<double> (n + 3, 0));

    dp[0][0] = 1;
    for(int i = 1; i <= n; i++)
        dp[i][0] = dp[i - 1][0] * (1 - p[i]);

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
        }
    }

    double ans = 0;

    for(int i = 1; i <= n; i++) {
        if(i > n - i) {
            ans += dp[n][i];
        }
    }

    cout << setprecision(10) << fixed;
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 73740
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

struct Info{
	int x,y;
};

Info info[4];

int ans_count;

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= 3 && col >= 0 && col <= 3)return true;
	else{
		return false;
	}
}

void recursive(short table[4][4],int num){

	if(num == 9){
		ans_count++;
		return;
	}

	short new_table[4][4][4];

	for(int i = 0; i < 4; i++){
		for(int k = 0; k < 4; k++){
			for(int p = 0; p < 4; p++)new_table[i][p][k] = table[p][k];
		}
	}

	for(int i = 0; i < 4; i++){
		for(int k = 0; k < 4; k++){
			if(table[i][k] == 0){
				for(int p = 0; p < 4; p++)new_table[p][i][k] = num;
				if(rangeCheck(i+info[0].y,k+info[0].x) == true && table[i+info[0].y][k+info[0].x] == 0){
					new_table[0][i+info[0].y][k+info[0].x] = num;
					recursive(new_table[0],num+1);
				}
				if(rangeCheck(i+info[1].y,k+info[1].x)  == true && table[i+info[1].y][k+info[1].x] == 0){
					new_table[1][i+info[1].y][k+info[1].x] = num;
					recursive(new_table[1],num+1);
				}
				if(rangeCheck(i+info[2].y,k+info[2].x)  == true && table[i+info[2].y][k+info[2].x] == 0){
					new_table[2][i+info[2].y][k+info[2].x] = num;
					recursive(new_table[2],num+1);
				}
				if(rangeCheck(i+info[3].y,k+info[3].x)  == true && table[i+info[3].y][k+info[3].x] == 0){
					new_table[3][i+info[3].y][k+info[3].x] = num;
					recursive(new_table[3],num+1);
				}
			}
		}
	}

}


int main(){

	short table[4][4];

	while(true){
		scanf("%d",&info[0].x);
		if(info[0].x >= 5)break;

		scanf("%d %d %d %d %d %d %d",&info[0].y,&info[1].x,&info[1].y,&info[2].x,&info[2].y,&info[3].x,&info[3].y);

		ans_count = 0;

		for(int i = 0; i < 4; i++){
			for(int k = 0; k < 8; k++)table[i][k] = 0;
		}

		recursive(table,1);

		printf("%d\n",ans_count);
	}

	return 0;
}

Measured memory_bytes: 2600
#include <iostream>
#include <vector>


using namespace std;


void white_cells()
{
  int H, W, h, w;
  cin >> H >> W >> h >> w;

  cout << (H * W) - (h * W) - (H * w) + (h * w) << "\n";
}


int main()
{
  white_cells();
}

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

using namespace std;

const int N = 1e5 + 5, M = 1e6 + 6, OO = 0x3f3f3f3f;

string s;

int main()
{
	cin >> s;
	if(s[0] == '7' || s[1] == '7' || s[2] == '7')
		puts("Yes");
	else
		puts("No");
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  string expected = "CODEFESTIVAL2016";
  int ans = 0;
  for(int i=0;i<s.size();i++) {
    if(s[i] != expected[i]) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> c(100);
  int n, a, b;
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> c.at(i);
  }
  for(int i=0;i<n;i++) {
    for(int j=i+1;j<n;j++) {
      if(c.at(i) < c.at(j)) {
        b=c.at(i);
        c.at(i) = c.at(j);
        c.at(j) = b;
      }
    }
  }
  a=0;
  for(int i=0;i<n;i+=2) {
    a+=c.at(i)-c.at(i+1);
  }
  cout << a << endl;
  return 0;
}



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

int main() {
  string s;
  cin >> s;
  long ans = 0;
  for(int i=0; i<s.length()/2; i++){
    if( s[i] != s[s.length()-i-1]){
      ans++;
    }
  }
   
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*
	dp[i][j] = max possible point accumulated in days i,i+1,....n if the task chosen on (i+1)th day was j

	dp[i][2] = max(dp[i+1][0], dp[i+1][1]) + a[2][i]
	dp[i][1] = max(dp[i+1][0], dp[i+1][2]) + a[1][i]
	dp[i][0] = max(dp[i+1][1], dp[i+1][2]) + a[0][i]

*/

#include <bits/stdc++.h>

using namespace std;

int main(){
	int n;
	vector<int> a[3], dp[3];
	cin>>n;
	a[0].assign(n, 0);
	a[1].assign(n, 0);
	a[2].assign(n, 0);
	dp[0].assign(n+1, 0);
	dp[1].assign(n+1, 0);
	dp[2].assign(n+1, 0);
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin>>a[j][i];
		}
	}
	for(int i=n-1;i>=0;i--){
		dp[0][i] = max(dp[1][i+1], dp[2][i+1]) + a[0][i];
		dp[1][i] = max(dp[0][i+1], dp[2][i+1]) + a[1][i];
		dp[2][i] = max(dp[0][i+1], dp[1][i+1]) + a[2][i];
	}
	cout<<max(dp[0][0], max(dp[1][0], dp[2][0]))<<"\n";
	return 0;
}

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

bool judge(int &N, vector<int> &Total) {
    for (auto x : Total) {
        if (x == N) return true;
    }
    return false;
}

int main() {
    int n, q;
    cin >> n;
    vector<int> A(n), Total;
    rep(i,n) cin >> A.at(i);
    for (int bit = 0; bit < (1<<n); bit++) {
        int sum = 0;
        for (int i = 0; i < n; i++) {
            if (bit & (1<<i)) sum += A.at(i);
        }
        Total.push_back(sum);
    }
    cin >> q;
    vector<int> m(q);
    rep(i,q) cin >> m.at(i);
    rep(i,q) {
        if (judge(m.at(i), Total)) cout << "yes" << '\n';
        else cout << "no" << '\n';
    }
}




Measured memory_bytes: 6976
import numpy as np
C= [[0] * 3 for i in range(3)]
for i in range(3):
  C[i]=list(map(int, input().split()))
C=np.array(C)
answer='Yes'
 
S=C.sum()
trace=np.diag(C).sum()
S_row0=C[0,:].sum()
S_row1=C[1,:].sum()
S_row2=C[2,:].sum()

S_col0=C[:,0].sum()
S_col1=C[:,1].sum()
S_col2=C[:,2].sum()

if S != 3*trace:
  answer = 'No'
elif S_row0-3*C[0,0] != trace-S_col0:
  answer = 'No'
elif S_row1-3*C[1,0] != trace-S_col0:
  answer = 'No'



print(answer)

Measured memory_bytes: 12444
// #pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
 #pragma GCC target("avx", "avx2")
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
// #define double ld
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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


signed main() {
    accell();
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i)
        cout << 'x';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
	double x[6];
	double y[6];
	int i,j,k,n;
	cin>>n;
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			cin>>x[j]>>y[j];
		}
		x[3]=2*(x[1]-x[0]);
		x[4]=2*(y[1]-y[0]);
		x[5]=x[0]*x[0]-x[1]*x[1]+y[0]*y[0]-y[1]*y[1];
		y[3]=2*(x[2]-x[0]);
		y[4]=2*(y[2]-y[0]);
		y[5]=x[0]*x[0]-x[2]*x[2]+y[0]*y[0]-y[2]*y[2];
		x[0]=(x[4]*y[5]-y[4]*x[5])/(x[3]*y[4]-y[3]*x[4]);
		y[0]=(x[5]*y[3]-y[5]*x[3])/(x[3]*y[4]-y[3]*x[4]);
		x[1]=(x[2]-x[0])*(x[2]-x[0])+(y[2]-y[0])*(y[2]-y[0]);
		x[1]=sqrt(x[1]);
		printf("%.3f %.3f %.3f\n",x[0],y[0],x[1]);
	}
	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
ll ncr(ll x, ll y) {
	ll ans = 1;
	for (ll i = 1; i <= y; ++i) {
		ans *= (x - y + i);
		ans /= i;
	}

	return ans;
}
int main()
{
    fio;
    string s1;
    cin>>s1;
    if(s1[1]=='R')
    {
        if(s1[0]=='R' && s1[2]=='R')
            cout<<"3\n";
        else if(s1[0]=='R' || s1[2]=='R')
        cout<<"2\n";
        else
            cout<<"1\n";
    }
    else
        {
        if(s1[0]=='R' || s1[2]=='R')
        cout<<"1\n";
        else
            cout<<"0\n";
    }
    return 0;
}



Measured memory_bytes: 3656
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#define INF 100000000000000
using namespace std;

typedef struct _BLOCK{
    long long n;
    long long x;
}BLOCK;

int main() {
    long long n,m,l;
    cin >> n >> m >> l;
    vector<vector<long long> > A(n, vector<long long>(m, 0));
    vector<vector<long long> > B(m, vector<long long>(l, 0));
    vector<vector<long long> > C(n, vector<long long>(l, 0));

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >>A.at(i).at(j);
        }
    }

    for(int i=0; i<m; i++){
        for(int j=0; j<l; j++){
            cin >> B.at(i).at(j);
        }
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<l; j++){
            for(int k=0; k<m; k++){
                C.at(i).at(j) += A.at(i).at(k)*B.at(k).at(j);
            }
        }
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<l-1; j++){
            cout << C.at(i).at(j) << " ";
        }
        cout << C.at(i).at(l-1) << endl;
    }
}


Measured memory_bytes: 3300
package main

import "fmt"

func main() {
	var n, cnt int
	fmt.Scan(&n)
	for num := 1; num <= n; num += 2 {
		num_divisors := 0
		for i := 1; i <= num; i++ {
			if num%i == 0 {
				num_divisors++
			}
		}
		if num_divisors == 8 {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
inline ll read(){
    ll f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//******head by yjjr******
const int maxn=5e5+6;
int a[maxn],b[maxn],c[maxn],n;ll ans=0,sum=0;
int main(){
    n=read();
    rep(i,1,n)c[i*2]=a[i]=read(),c[i*2-1]=b[i]=read();
    sort(c+1,c+1+2*n);
    rep(i,1,n)ans+=a[i],sum+=b[i];
    ans=min(ans,sum),sum=0;
    rep(i,1,n)sum+=c[i];
    rep(i,1,n){
        if(max(a[i],b[i])<c[n]){cout<<sum<<endl;return 0;}
        if(min(a[i],b[i])>c[n]){cout<<sum<<endl;return 0;}
        ll now=sum;
        now+=max(a[i],b[i])-c[n];
        now+=max(0,min(a[i],b[i])-c[n-1]);
        ans=min(ans,now);
    }
    cout<<ans<<endl;
    //puts("R");
    return 0;
}

Measured memory_bytes: 3328
function main()
    mi = typemax(Int)
    N = pread(Int)
    xs, ys = readvec((Int,Int), N)
    xy = []
    for i in 1:N
        push!(xy, (xs[i]+ys[i], xs[i]-ys[i]))
    end
    ans = max(maximum(x -> x[1],xy) - minimum(x -> x[1],xy), maximum(x -> x[2],xy) - minimum(x -> x[2],xy))
    println(ans)
end

import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str
isdelim(x::UInt8, xs::Set{UInt8}) = x in xs
const delimset = Set([0x0a, 0x20])

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        !isdelim(c, delims) && break
    end
    push!(out, c)
    eof(s) && return out
    while !eof(s)
        c = read(s, UInt8)
        isdelim(c, delims) && break
        push!(out, c)
    end
    return out
end

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

function readvec(tys::Tuple , len::Signed)::Tuple{map(x -> Vector{x},tys)...}
    rv = Tuple{map(x -> Vector{x},tys)...}(Vector{ty}(undef,len) for ty in tys)
    for i in 1:len
        for j in 1:length(tys)
            @inbounds rv[j][i] = pread(tys[j])
        end
    end
    rv
end

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i in 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

main()


Measured memory_bytes: 261672
/* Coached by rainboy */
#include <stdio.h>
#include <stdlib.h>

#define N 200000

int compare(const void *a, const void *b) {
	int ia = *(int *) a;
	int ib = *(int *) b;

	return ia - ib;
}

int main() {
	static int aa[N];
	int n, i, b;
	long long sadness;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &aa[i]);
		aa[i] -= (i + 1);
	}
	qsort(aa, n, sizeof *aa, compare);
	b = aa[(n - 1) / 2];
	sadness = 0;
	for (i = 0; i < n; i++)
		sadness += abs(aa[i] - b);
	printf("%lld\n", sadness);
	return 0;
}


Measured memory_bytes: 1788
N = int( input())
A, B = map( int, input().split())
P = list( map( int, input().split()))
X = Y = Z = 0
for i in range(N):
    if P[i] <= A:
        X += 1
    elif P[i] <= B:
        Y += 1
    else:
        Z += 1
print( min( [X,Y,Z]))

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

#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

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


#define PI 3.14159265358979323846

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    long double a,b,h,m;
    cin>>a>>b>>h>>m;

    long double d1 = 30*h + m/2.0L;
    long double d2 = m*6.0L;

    db2(d1,d2);ln;

    long double deg;
    if(fabsl(d1-d2) > 180.0L)deg=360.0L-fabsl(d1-d2);
    else deg = fabsl(d1-d2);

    db(deg);ln;

    long double rad = deg*PI/180.0L;
    long double cc = a*a+b*b-2.0L*a*b*(cos(rad));

    cout <<fixed<<setprecision(20)<<sqrtl(cc)<<endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 4176
import sys
sys.setrecursionlimit(10**7)

mod = 10**9 + 7
star = [[None] * 1001 for _ in range(1001)]

for i in range(1001):
    star[i][i] = 1
    star[i][1] = 1

def search(n, k):
    if star[n][k]:
        return star[n][k] % mod
    else:
        star[n][k] = (search(n-1, k-1) + k * search(n-1, k)) % mod
        return star[n][k]

n, k = map(int, input().split())
if n < k:
    print(0)
else:
    print(search(n,k))


Measured memory_bytes: 20768
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n,k = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	s = sum(a)
	t = Int[]
	q = 1
	r = floor(Int,sqrt(s))
	while q<=r
		if s%q==0
			push!(t,q)
			push!(t,div(s,q))
		end
		q += 1
	end
	if r*r==s
		push!(t,r)
	end
	m = 0
	for i in 1:length(t)
		b = zeros(Int,n)
		x = 0
		for j in 1:n
			b[j] = a[j]%t[i]
			x += b[j]
		end
		b = sort(b)
		h = div(x,t[i])
		y = sum(b[1:n-h])
		if y<=k
			m = max(m,t[i])
		end
	end
	println(m)
end

main()

Measured memory_bytes: 169380
#include <cstdio>
using namespace std;
int N, A[21], B[21], C[21], ans = 0;
int main() {
  scanf("%d", &N);
  for(int i = 1; i <= N; i++) scanf("%d", &A[i]);
  for(int i = 1; i <= N; i++) scanf("%d", &B[i]);
  for(int i = 1; i <= N-1; i++) scanf("%d", &C[i]);
  for(int i = 1; i <= N; i++) {
    if(A[i] == A[i-1]+1) ans += C[A[i-1]];
    ans += B[A[i]];
  }
  printf("%d", ans);
}

Measured memory_bytes: 128
// UNNECESSARY
// #include <chrono>//std::chrono::/system_clock/steady_clock/high_resolution_clock/duration
// #include <cstdio>//printf/scanf/fopen/fclose/fprintf/fscanf/snprintf/putc/puts/getc/gets
// #include <fstream>//ifstream/ofstream

// DATA STRUCTURES
#include <array>
#include <bitset>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>

// MISCELLANEOUS
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <cassert>
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
#include <iomanip>//setfill/setw/setprecision/fixed/scientific
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <new>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <utility>//pair

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

#ifndef REPST
#define REPST(i,n) for (size_t i = 0; i < n; ++i)
#endif

#ifndef READ
#define READ(x) std::cin >> x
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> plli;
typedef std::pair<ull, int> puli;
typedef std::pair<double, int> pdi;
typedef std::pair<ll, ll> pllll;
typedef std::pair<ull, ull> pulul;
typedef std::pair<double, double> pdd;
typedef std::tuple<int, int, int> ti3;
typedef std::tuple<int, int, int, int> ti4;

const bool debug = true;

// --------------------------------------------------------------------------------------

using namespace std;

int main(void)
{
    size_t n, t;
    cin >> n >> t;
    std::vector<ull> v(n);
    REP(i,n) {
        cin >> v[i];
    }
    ull ends = 0;
    ull total = 0;
    REP(i,n) {
        if (ends <= v[i]) {
            total += t;
            ends = v[i] + t;
        } else {
            total += (v[i] + t) - ends;
            ends = v[i] + t;
        }
    }
    cout << total << '\n';

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int val[105];
int main(){
  int a,b,c;
  scanf("%d %d %d", &a, &b, &c);
  val[a]=1;
  val[b]=1;
  val[c]=1;
  int res = 0;
  for (int i = 0; i < 105; i++) res += val[i];
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
//#define index xdeni
#define bug cout<<"bug "<<__LINE__<<endl
using namespace std;
const int inf=1e9+7;
//const int MAXN=;
int ans=0;
int Get(int p)
{
	if(p%4==0) return p;
	if(p%4==1) return 1;
	if(p%4==2) return p+1;
	if(p%4==3) return 0;
}
int a,b;
signed main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>a>>b;
	int x=Get(a-1);
	int y=Get(b);
	cout<<(x^y)<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String x = sc.next();

        if (x.equals("ABC")) {
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }
        
        sc.close();
    }

}

Measured memory_bytes: 35636
#include <iostream>
#include <math.h>
#include <string>

using namespace std;
int main()
{
    int n,a,r;
    cin>>n>>r;

    if(n < 10){
        a = 100*(10-n);
        a = a+r;
    }
    else{
        a = r;
    }
    cout<<a;

    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<(next<int>() > next<int>() ? "safe" : "unsafe")<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
    using ll = long long;
    ll num[15][15];
    ll ans=0;
    int n;
void run(int step,ll sum)
{
    if(step==n)
    {
        ans+=sum;
        return;
    }
    for(int i=step;i<n;i++)
        run(i+1,sum+num[step][i]);
    return;
}
int main()
{
    string s;
    cin>>s;
    n=s.size();
    for(int i=0;i<n;i++)
    {
        string t;
        for(int j=i;j<n;j++)
        {
            t.push_back(s[j]);
            num[i][j]=stoll(t);
        }
    }
    run(0,0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 764
from collections import deque
import sys
sys.setrecursionlimit(10**6)

def bfs(u):
    dist = [-1 for _ in range(n)]
    dist[u] = 0
    que = deque([])
    que.append(u)
    
    while que:
        v = que.popleft()
        for nv in G[v]:
            if dist[nv] != -1:
                continue
            dist[nv] = dist[v] + 1
            que.append(nv)

    for d in dist:
        if d == 0:
            continue
        ans[d-1] += 1
    return ans


n, x, y = map(int,input().split())
G = [[] for _ in range(n)]
for i in range(n-1):
    G[i].append(i+1)
    G[i+1].append(i)
G[x-1].append(y-1)
G[y-1].append(x-1)

ans = [0]*(n-1)
for i in range(n):
    bfs(i)

for i in ans:
    print(i//2)

Measured memory_bytes: 4212