akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> cnt(5, 0);
    string word = "MARCH";
    REP(i, N){
    	string S;
    	cin >> S;
    	REP(j, 5){
    		if(S[0] == word[j]) cnt[j]++;
    	}
    }

    ll res = 0;
    REP(mask, (1ll << 5)){
    	ll tmp = 1;
    	ll sum = 0;
    	REP(j, 5){
    		if(mask >> j & 1){
    			sum++;
    			tmp *= cnt[j];
    		}
    	}
    	if(sum == 3) res += tmp;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstring>
using namespace std;
string s;
int n,i,j;
int main()
{
	cin>>s;
	n=s.size();
	for(i=0,j=s.size()-1;i++,j--;i<=s.size(),j>=s.size())
	{	
		if((s[i]=='b'&&s[j]!='d')||(s[i]=='p'&&s[j]!='q')||(s[i]=='d'&&s[j]!='b')||(s[i]=='q'&&s[j]!='p'))
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

string str;

int main()
{
	cin >> str;
	int len = str.size();
	
	int cntN = 0, cntS = 0, cntW = 0, cntE = 0;
	
	for(int i = 0; i < len; i++)
	{
		if(str[i] == 'N') cntN = 1;
		if(str[i] == 'S') cntS = 1;
		if(str[i] == 'W') cntW = 1;
		if(str[i] == 'E') cntE = 1;
	}
	
	if((cntN - cntS == 0) && (cntW - cntE == 0)) cout << "Yes" << endl;
	else cout << "No" << endl;
			
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int x[5];
    int m = 0;
    int sum = 0;

    for(int i = 0;i < 5;i++)cin >> x[i];
    for(int i = 0;i < 5;i++)m = max(m,10 - (x[i] - 1) % 10);
    for(int i = 0;i < 5;i++)sum += (x[i] + 9) / 10 * 10;

    cout << sum - m + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){

    char a, b;
    cin >> a >> b ;
    
    //*
    if(a == b){
        cout << "H" << endl;
    } else {
        cout << "D" << endl;
    }
    //*/
    
    //cout << a * 800 - a / 15 * 200 << endl;

    return 0; 
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;

string s;
string t;
int p[100005],q[100005];
void query(int a,int b,int c,int d){
    int k = b-a+1+(p[b]-p[a-1]);
    int t = d-c+1+(q[d]-q[c-1]);
    if(k%3==t%3){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}
int main(){
    int qq;
    cin >> s >> t >> qq;
    int ss = (int)s.size();
    int tt = (int)t.size();
    rep(i,ss){
        p[i+1]=p[i];
        if(s[i]=='A')p[i+1]++;
    }
    rep(i,tt){
        q[i+1]=q[i];
        if(t[i]=='A')q[i+1]++;
    }
    int a,b,c,d;
    rep(i,qq){
        cin >> a  >> b >> c >> d;
        query(a,b,c,d);
    }
    return 0;
}

Measured memory_bytes: 1792
import numpy as np
N = int(input())
B = np.array(list(map(int, input().split())))

B_index = np.argsort(B)
# print(B)
# print(B_index)
A = [-1] * (len(B)+1)
for i in B_index:
    if A[i] < 0:
        A[i] = B[i]
        if A[i+1] < 0:
            A[i+1] = B[i]
    else:
        if A[i+1] < 0:
            A[i+1] = B[i]
print(sum(A))

Measured memory_bytes: 12424
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

int main(){
    int H,W;cin>>H>>W;
    vector<vector<int>> a(H,vector<int>(W,0));
    REP(i,H){
        REP(j,W){
            cin>>a[i][j];
        }
    }
    int count = 0;
    string ans;
    REP(row,H){
        REP(column,W){
            if(row%2==0){
                //右にすすむ
                if(a[row][column]%2==0) continue;
                a[row][column]--;
                if(column == W-1){
                    if(row == H-1) break;
                    //右端
                    a[row+1][column]++;
                    ans += to_string(row+1)+" " + to_string(column+1) +" "
                            +to_string(row+2) +" "+ to_string(column+1) + '\n';
                    count++;
                }else{
                    a[row][column+1]++;
                    ans += to_string(row+1)+" " + to_string(column+1) +" "
                            +to_string(row+1) +" "+ to_string(column+2) + '\n';
                    count++;
                }
            }
            else{
                //左にすすむ
                int lcolumn = W - 1 - column;
                if(a[row][lcolumn]%2==0) continue;
                a[row][lcolumn]--;
                if(column == W -1){
                    if(row==H-1)break;
                    //左
                    a[row+1][lcolumn]++;
                    ans += to_string(row+1) +" "+ to_string(lcolumn+1) +" "
                            +to_string(row+2) +" " + to_string(lcolumn+1) + '\n';
                    count++;
                }else{
                    a[row][lcolumn-1]++;
                    ans += to_string(row+1) +" " + to_string(lcolumn+1) +" "
                            +to_string(row+1) +" " + to_string(lcolumn-1+1) + '\n';
                    count++;
                }
            }
            }
        }
    cout<<count<<endl;
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	int A,B,C,D;
    cin >> A >> B >> C >> D;
    int E = min(B,D)- max(A,C);
    if(E>0)
    	cout << E << endl;
    else
    	cout << 0 << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //StringTokenizer st = new StringTokenizer(br.readLine());
        //PrintWriter pw = new PrintWriter("TaskABeg144.out");
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < 1 || a > 9 || b < 1 || b > 9)
            System.out.println(-1);
        else{
            System.out.println(a*b);
        }
    }
}

Measured memory_bytes: 23508
use std::io::{self, BufRead};

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let xs: Vec<i32> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
  let ps: Vec<i32> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
  let k = xs[0];
  let n = xs[1];

  let mut max_dist = ps[0] + k - ps[n as usize - 1];
  for i in 1..n {
    let dist = ps[i as usize] - ps[i as usize - 1];
    if max_dist < dist {
      max_dist = dist;
    }
  }
  println!("{}", k - max_dist);
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> v(n);
    rep(i, n)
    {
        vector<int> t(m + 1);
        rep(j, m + 1)
        {
            cin >> t[j];
        }
        v[i] = t;
    }
    int ans = 1e9;
    for (int i = 0; i < (1 << n); i++)
    {
        int cost = 0;
        vector<int> skill(m);
        for (int j = 0; j < n; j++)
        {
            if (i & (1 << j))
            {
                cost += v[j][0];
                rep(k, m)
                {
                    skill[k] += v[j][k + 1];
                }
            }
        }
        bool flag = true;
        for (int k = 0; k < m; k++)
        {
            if (skill[k] < x)
            {
                flag = false;
            }
        }
        if (flag)
        {
            ans = min(ans, cost);
        }
    }
    if (ans == 1e9)
    {
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
from itertools import product

N, M = [int(x) for x in input().split()]
ROWS = [list(map(int, input().split())) for _ in range(N)]

# 綺麗さ・おいしさ・人気度のそれぞれの要素について、「正の方向に最大化する」 「負の方向
# に最大化する」 のどちらを選ぶか、ということを考えると分かりやすいです。要素は 3 つあるので、
# 2**3 = 8
# 通り全探索します。
# 例えば、綺麗さ・おいしさを正の方向に最大化、人気度を負の方向に最大化したい場合、𝑥𝑖 + 𝑦𝑖 −
# 𝑧𝑖 の大きい順にソートして、上から M 個のケーキを選ぶと良いです。

def calc(r, bools):
    result = []
    for i in range(3):
        val = r[i] if bools[i] else -r[i]
        result.append(val)
    return sum(result)

def main():
    ans = 0
    bools = product([True, False], repeat=3)
    for b in bools:
        results = sorted(ROWS, key=lambda r: calc(r, b), reverse=True)
        temp = [calc(r, b) for r in results[:M]]
        ans = max(ans, sum(temp))
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll inf=1e9+7;
int main()
{
	ll n,val,i,j,k,c,s=0;
	string ss;
	cin>>ss;
	if(ss[2]==ss[3] && ss[4]==ss[5])
	{
		cout<<"Yes\n";
	}
	else cout<<"No\n";
}

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

int main() {
  string S;
  cin >> S;
  
  int N = S.size();
  
  long long ans = 0;
  for (int bit = 0; bit < (1<<(N - 1)); bit++) {
    string str = "";
    str += S[0];
    for (int i = 0; i < N - 1; i++) {
      if (bit & (1<<i)) {
        ans += stoll(str);
        str = "";
      }
      str += S[i + 1];
    }
    ans += stoll(str);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int R = 0;
  int G = 0;
  cin >> R >> G;
  //(R+P)/2 = G より P = 2G-R(入力が整数よりPも整数)
  cout << 2*G-R << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[10010];
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		while(a[i]%2==0){
			a[i]/=2;
			sum++;
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{
	string code = "CODEFESTIVAL2016";
	string s;
	cin >> s;
	int count = 0;

	REP(i, 16){
		if (s[i] != code[i]) count++;
	}

	cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int H,W;
string s[60];
bool ans;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
bool vis[60][10];
pair<int,int>dfs(int x,int y)
{
	int nM=0,sumw=0;
	queue<pair<int,int> >P;
	P.push(make_pair(x,y));
	vis[x][y]=true;
	int XL=114514,XR=-114514;
	while(!P.empty())
	{
		int X=P.front().first,Y=P.front().second;
		P.pop();
		sumw++;
		nM+=Y;
		if(X==H-1||s[X+1][Y]!='.'&&s[X+1][Y]!=s[X][Y])XL=min(XL,Y),XR=max(XR,Y+1);
		for(int r=0;r<4;r++)
		{
			int tx=X+dx[r],ty=Y+dy[r];
			if(tx>=0&&ty>=0&&tx<H&&ty<W&&s[tx][ty]==s[X][Y]&&!vis[tx][ty])
			{
				vis[tx][ty]=true;
				P.push(make_pair(tx,ty));
			}
		}
		X--;
		if(X>=0&&s[X][Y]!=s[X+1][Y]&&s[X][Y]!='.'&&!vis[X][Y])
		{
			pair<int,int>p=dfs(X,Y);
			sumw+=p.first;
			nM+=p.second;
		}
	}
	ans&=2*XL*sumw<2*nM+sumw&&2*nM+sumw<2*XR*sumw;
	return make_pair(sumw,nM);
}
main()
{
	while(cin>>W>>H,H)
	{
		for(int i=0;i<H;i++)cin>>s[i];
		for(int i=0;i<H;i++)for(int j=0;j<W;j++)vis[i][j]=false;
		ans=true;
		for(int i=0;i<W;i++)if(s[H-1][i]!='.')
		{
			dfs(H-1,i);
			break;
		}
		cout<<(ans?"STABLE":"UNSTABLE")<<endl;
	}
}



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

void fnInput(vector<string>& rvsStr)
{
  int nStrSiz;
  cin >> nStrSiz;
  rvsStr.resize(nStrSiz);

  for (string& rsStr : rvsStr)
    cin >> rsStr;
}
  
int64_t fnAnagramCnt(const vector<string>& cnrvsStr)
{
  vector<string> vsSortStr(cnrvsStr);

  for (int i = 0; i < vsSortStr.size(); i++)
    sort(begin(vsSortStr[i]), end(vsSortStr[i]));

  int64_t nAnagramCnt = 0;
  map<string, int> mpSortStr;

  for (int i = 0; i < vsSortStr.size(); i++)
    if (mpSortStr[ vsSortStr[i] ] == 0)
      mpSortStr[ vsSortStr[i] ]++;
    else
    {
      nAnagramCnt += mpSortStr[ vsSortStr[i] ];
      mpSortStr[ vsSortStr[i] ]++;
    }

  return nAnagramCnt;
}
  
int main()
{
  vector<string> vsStr;

  fnInput(vsStr);
  cout << fnAnagramCnt(vsStr) << endl;

  return 0;
}

Measured memory_bytes: 23680
#include<stdio.h>
int main()
{
	long long int n, k;
	scanf("%lld %lld", &n, &k);
	long long int i;
	int a[200005];
	for (i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		a[i]--;
	}
	int b[200005];
	long long int l;
	int v[200005];
	for (i = 0; i < n; i++)
		v[i] = 0;
	b[0] = 0;
	v[0] = 1;
	l = 1;
	int now = a[0];
	long long int c[200005];
	c[0] = 0;
	while (v[now] == 0)
	{
		b[l] = now;
		c[now] = l;
		l++;
		v[now] = 1;
		now = a[now];
	}
	if (l > k)
	{
		printf("%d\n", b[k] + 1);
		return 0;
	}
	k -= l;
	k %= l - c[now];
	printf("%d\n", b[c[now] + k] + 1);
	return 0;
}

Measured memory_bytes: 5584
#include<stdio.h>

int main(){
    int A=0;
    int B=0;
    int pl=0;
    int mn=0;
    int mu=0;
    int kai=0;
    scanf("%d %d",&A,&B);
    pl=A+B;
    mn=A-B;
    mu=A*B;
        kai=pl;
    if(kai<mn){
        kai=mn;
    }
    if(kai<mu){
        kai=mu;
    }
    printf("%d\n",kai);

    return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

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

    ll N, T;
    cin >> N >> T;

    vector<Pll> p;
    rep (i, N) {
        ll c, t;
        cin >> c >> t;
        p.push_back(make_pair(t, c));
    }

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

    ll ans = INF;
    rep (i, N) {
        if (p[i].first <= T) {
            ans = min(ans, p[i].second);
        }
    }

    if (ans == INF) {
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

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

int N;
vector<int> A;
vector<set<int>> vs;

signed main() {
  cin >> N;
  A.resize(N);
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<N; i++) A[i]--;

  vs.resize(N);
  for(int i=0; i<N; i++) vs[A[i]].insert(i);

  if(vs[0].size()==0)  {
    cout <<"-1" << endl;
    return 0;
  }

  int ans = 0;
  int pos = -1;
  for(int a=0; a<N; a++){
    //if(vs[a].size()==0) {
    //  ans += N-pos-1;
    //  break;
    //}
    bool e=true;
    for (auto i : vs[a] ) {
      if(pos<i) {
        ans += i-pos-1;
        pos=i;
        e=false;
        break;
      }
    }
    if(e) {
      ans += N-pos-1;
      break;
    }
  }
  cout << ans << endl;  
}


Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >>N;
  
  int s=0;
  
  for(int i=0; i<N; i++){
    int l,r;
    cin >>l>>r;
    
    s +=r-l+1;
  }
  
  cout <<s<<endl;
    
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import heapq


N,M = map(int, input().split())
ABn = [list(map(int, input().split())) for _ in range(N)]
ABn = sorted(ABn)

heap_q = []
reword = 0
j = 0
for i in range(M):
  while j<N and ABn[j][0] <= i+1:
    heapq.heappush(heap_q,-ABn[j][1])
    j+=1
  if len(heap_q) > 0:
    reword += heapq.heappop(heap_q) * (-1)
print(reword)

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

const int maxn = 3030, mod = 1e9 + 7;
int n, m, dp[2][maxn][maxn];

inline int add(int a, int b){
	if(a + b >= mod)
		return a + b - mod;
	return a + b;
}

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

	dp[1][0][0] = 1;
	for(int i = 1; i <= n; i++){
		dp[0][i][0] = 1;
	}

	for(int i = 1; i <= m; i++){
		for(int j = 1; j <= n; j++){
			int &x = dp[0][j][i];

			if(j > 1){
				x = add(x, dp[0][j][i - 1]);
				x = add(x, dp[0][j - 1][i - 1]);
			}

			if(j < n){
				x = add(x, dp[0][j][i - 1]);
				x = add(x, dp[0][j + 1][i - 1]);
			}
		}

		//solve flagirane

		dp[1][0][i] = dp[0][1][i - 1];
		dp[1][1][i] = dp[0][1][i - 1];

		for(int j = 0; j <= n; j++){
			int &x = dp[1][j][i];

			if(j > 0){
				x = add(x, dp[1][j][i - 1]);
				x = add(x, dp[1][j - 1][i - 1]);
			}

			if(j < n){
				x = add(x, dp[1][j][i - 1]);
				x = add(x, dp[1][j + 1][i - 1]);
			}
		}
	}

	int sol = 0;
	for(int i = 0; i <= n; i++){
		sol = add(sol, dp[1][i][m]);
	}

//	for(int f = 0; f < 2; f++){
//		for(int i = 0; i <= m; i++){
//			for(int j = 0; j <= n; j++){
//				cout << dp[f][j][i] << ' ';
//			}
//			cout << endl;
//		}
//		cout << endl;
//	}

	cout << sol << endl;

	return 0;
}


Measured memory_bytes: 71936
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

struct edge
{
	int to;
	lint dis;
	edge(int t, lint d) : to(t), dis(d) {}
};

void execute()
{
	int N;
	lint a, b, c;
	int Q, K;
	lint x, y;
	int current;
	cin >> N;
	vector<lint> distance(N, -1);
	//vector<vector<lint>> gluph(N, vector<lint>(N, -1));
	vector<vector<edge>> gluph(N);
	queue<int> node;

	for (int i = 0; i < N - 1; i++)
	{
		cin >> a >> b >> c;
		gluph[a - 1].push_back(edge(b - 1, c));
		gluph[b - 1].push_back(edge(a - 1, c));
	}
	cin >> Q >> K;

	node.push(K - 1);
	distance[K - 1] = 0;

	for (; !node.empty();)
	{
		current = node.front();
		node.pop();

		for (auto g : gluph[current])
		{
			if (distance[g.to] == -1)
			{
				distance[g.to] = distance[current] + g.dis;
				node.push(g.to);
			}
		}
	}
	for (int i = 0; i < Q; i++)
	{
		cin >> x >> y;
		cout << (distance[x - 1] + distance[y - 1]) << endl;
	}
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> X(N);

  for(int i=0;i<N;i++){
    cin >> X.at(i);
  }
  sort(X.begin(), X.end());
  float min = INFINITY;
  for(int i=X.at(0); i<=X.at(N-1); i++){
    int cost = 0;
    for(int j=0; j<N; j++){
      cost += pow(i - X.at(j), 2);
    }
    if(cost < min) min = cost;
    else break;
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]

#[allow(unused_macros)]
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input!{
        cs: chars,
    }
    let mut ans = 0;
    for c in cs {
        match c {
            '1' => ans = ans + 1,
            _ => (),
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define INF 1e13
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N;
    cin >> N;
    vector<int> pos(N);
    REP(i,N) cin >> pos[i];
    ll ans = INF;
    FOR(i,1,101) {
        // 消費する体力の計算
        ll cost = 0;
        REP(j,N) cost += abs(pos[j]-i) * abs(pos[j]-i);
        chmin(ans,cost);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import deque

H, W = map(int, input().split())
grid = [[s for s in input()] for _ in range(H)]
done =[[True] * W for _ in range(H)]
done[0][0] = 0
d = [[-1] * W for _ in range(H)]
d[0][0] = 0
q = deque([(0, 0)])

cnt = 0
for i in range(H):
    for j in range(W):
        if grid[i][j] == ".":
            cnt += 1

while q:
    x, y = q.popleft()
    for i, j in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        x_n, y_n = x + i, y + j
        if (0 <= x_n and x_n <= H - 1 and 0 <= y_n and y_n <= W - 1
        and grid[x_n][y_n] == "." and done[x_n][y_n] is True):
            d[x_n][y_n] = d[x][y] + 1
            done[x_n][y_n] = 0
            q.append((x_n, y_n))

if d[H - 1][W - 1] != -1:
    print(cnt - d[H - 1][W - 1] - 1)
else:
    print(-1)

Measured memory_bytes: 9444
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>x(n);
  for(int i=0;i<n;i++){
    int a;cin>>a;
    while(a%2==0){
      a/=2;
      x.at(i)++;
    }
  }
  sort(x.begin(),x.end());
  cout<<x.at(0)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef pair <int,P> PP;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<vector<P> > graph(n);
    vector<int> col(n);
    rep (i, n - 1) {
        int a, b; cin >> a >> b; a--; b--;
        graph[a].emplace_back(b, i);
        graph[b].emplace_back(a, i);
    }
    vector<bool> used(n);
    vector<P> edges;
    priority_queue<int> que;
    que.push(0);
    while (!que.empty()) {
        auto p = que.top(); que.pop();
        int f = n + 1;
        vector<bool> used(n);
        for (auto i : graph[p]) if (col[i.second] != 0) used[col[i.second] - 1] = true;
        int c = 0;
        for (auto i : graph[p]) {
            if (col[i.second] == 0) {
                while (used[c]) c++;
                col[i.second] = c + 1;
                que.push(i.first);
                used[c] = true;
            }
        }
    }
    int m = 0; rep (i, n - 1) chmax(m, col[i]);
    cout << m << "\n";
    rep (i, n - 1) cout << col[i] << "\n";
    return 0;
}

Measured memory_bytes: 6912
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			int q = in.nextInt();
			if (q != 0) {
				int counter = 0;
				while (q != 1) {
					if (q % 2 == 0) {
						q /= 2;
					} else {
						q *= 3;
						q++;
					}
					counter++;
				}
				System.out.println(counter);
			}
		}
	}
}

Measured memory_bytes: 12000
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static int N;
    static String[] d357 = {"3", "5", "7"};
    static List<Integer> candidates = new ArrayList<>();

    static void getOneMoreAppend(int rem, String original) {
        if (rem == 0) {
            boolean ok = true;
            for (String d : d357) ok &= original.contains(d);
            int candidate = Integer.parseInt(original);
            if (ok && candidate <= N) candidates.add(candidate);
        } else {
            for (String d : d357) getOneMoreAppend(rem - 1, original + d);
        }
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            int digit = (int) Math.floor(Math.log10(N)) + 1;

            for (int i = 3; i <= digit; i++) {
                getOneMoreAppend(i, "");
            }

            out.println(candidates.size());
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 28892
#include<iostream>
#include<string>
#include<vector>
#define N 12

using namespace std;

void Island1(vector<string>&, int, int);
void Island2(vector<string>&, int, int);

int main(){
  int i, j, count;
  string s;
  vector<string> data;

  while(cin >> s){
    data.push_back(s);
    for(i=1; i<N; ++i){
      cin >> s;
      data.push_back(s);
    }

    for(i=0, count = 0; i<N; ++i){
      for(j=0; j<N; ++j){
	if(data[i][j] == '1'){
	  Island1(data, i, j);
	  ++count;
	}
      }
    }

    cout << count << endl;
    data.clear();
  }

  return 0;
}

void Island1(vector<string>& data, int i, int j){
  data[i][j] = '2';
  Island2(data, i-1, j);
  Island2(data, i+1, j);
  Island2(data, i, j-1);
  Island2(data, i, j+1);
}

void Island2(vector<string>& data, int i, int j){
  if(i > -1 && i < N && j > -1 && j < N && data[i][j] == '1')
    Island1(data, i, j);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<vector>
#include<deque>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll gcd(ll a2,ll b2){
	ll t;
	while(b2!=0){
		t=a2%b2;
		a2=b2;
		b2=t;
	}
	return a2;
}

int main() {

	ll q;
	cin>>q;

	deque<ll> dq;

	rep(i,q){
		ll a,b,c;
		cin>>a>>b;
		if(a==0){
			cin>>c;
			if(b==1)dq.push_back(c);
			else dq.push_front(c);
		}
		if(a==1)cout<<dq[b]<<endl;
		if(a==2){
			if(b==0)dq.pop_front();
			else dq.pop_back();
		}
	}

	return 0;
}



Measured memory_bytes: 6212
using System;

namespace ITP_2_D{
    public class Program{
        public static void Main(string[] args){
            string[] temp = Console.ReadLine().Split(' ');
            int W = int.Parse(temp[0]);
            int H = int.Parse(temp[1]);
            int x = int.Parse(temp[2]);
            int y = int.Parse(temp[3]);
            int r = int.Parse(temp[4]);
            bool result = true;

            /*????§???¢???????????\????????????????????????????¨?
                1:x-r???0???????°???????
                2:y-r???0???????°???????
                3:x+r???W????????§??????
                4:y+r???H????????§??????
            */
            if((x-r) < 0){
                result = false;
            }
            if((y-r) < 0){
                result = false;
            }
            if ((x+r) > W){
                result = false;
            }
            if((y+r) > H){
                result = false;
            }

            //???????????????
            if (result) {
                Console.WriteLine("Yes");
            }
            else{
                Console.WriteLine("No");
            }
        }
    }
}

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

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

    int value = 0;

    if(N >= 500){
        value += 1000 * (N / 500);
        N %= 500;
    }
    if(N > 0){
        value += 5 * (N / 5);
    }

    cout << value << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    while(cin>>s){
         bool t1=false,t2=false;
         for(auto&i:s){
               if(i=='C')t1=true;
               else if(t1&&i=='F')t2=true;
               if(t2)break;
     }
     if(t2)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
    }
}

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

using namespace std;

int main(){
	int a = 0, b = 0;
	cin >> a >> b;
	int val1 = 0, val2 = 1, ans = 0;
	bool out = 0;
	while(!out){
		for(int q = 1; q <= 999; q++){
			val1 = (q * (q + 1)) / 2;
			val2 = ((q + 1) * (q + 1 + 1)) / 2;
			if(val1 - a == val2 - b){
				out = 1;
				ans = val1 - a;
			}
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll n,m,q;cin>>n>>m>>q;
    vector<ll>v(0);
    rep(i,n){
        v.pb(0);
    }
    rep(i,m-1){
        v.pb(1);
    }
    vector<ll>a(q);
    vector<ll>b(q);
    vector<ll>c(q);
    vector<ll>d(q);
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    ll ans=0;
    do{
        ll cnt=0;
        vector<ll>x(0);
        ll now=1;
        rep(i,n+m-1){
            if(v[i]==1){
                now++;
            }else{
                x.pb(now);
            }
        }
        rep(i,q){
            if(x[b[i]-1]-x[a[i]-1]==c[i])cnt+=d[i];
        }
        ans=max(ans,cnt);
    }while(next_permutation(all(v)));
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#define _GLIBCXX_DEBAC
using namespace std;
	

int main() {
	int a, b;
	cin >> a >> b;
	int x;
	x = a - b * 2;
	if (x < 0) {
		cout << 0;
	}
	else {
		cout << x;
	}
		return 0;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
int top = -1;
vector<bool> finished, seen;
stack<int> hist;

void dfs(int cur, int pre) {
    seen[cur] = true;
    hist.push(cur);
    for (auto next: G[cur]) {
        if (next == pre) continue;
        if (finished[next]) continue;
        if (seen[next] && !finished[next]) {
            top = next;
            return;
        }
        dfs(next, cur);
        if (top != -1) return;
    }
    finished[cur] = true;
    hist.pop();
    return;
}

int main() {
    int N;
    cin >> N;
    G.resize(N);
    finished.assign(N, false);
    seen.assign(N, false);
    for (int i = 0; i < N; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    top = -1;
    dfs(0, -1);
    set<int> cycle;
    while(!hist.empty()) {
        int t = hist.top();
        cycle.insert(t);
        hist.pop();
        if (t == top) break;
    }
    int Q;
    cin >> Q;
    for (int _ = 0; _ < Q; _++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (cycle.count(a) && cycle.count(b)) cout << 2 << endl;
        else cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 19172
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int snuke[n];
    for(int i=0; i<n; i++) snuke[i] = 0;
    for(int i=0; i<k; i++)
    {
        int d;
        cin >> d;
        for(int j=0; j<d; j++)
        {
            int tmp;
            cin >> tmp;
            tmp--;
            snuke[tmp]++;
        }
    }
    int ans = 0;
    for(int i=0; i<n; i++)
    {
        if(snuke[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
/*
 * main.cpp
 *
 *  Created on: 2020/04/09
 *      Author: SkAaO
 */

#include <iostream>

using namespace std;

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

	long long L, L_pre_2 = 2, L_pre_1 = 1;

	if(N == 1){
		cout << L_pre_1 << endl;
		return 0;
	}

	for(int i = 2; i <= N; i++){
		L = L_pre_1 + L_pre_2;
		L_pre_2 = L_pre_1;
		L_pre_1 = L;
	}

	cout << L << endl;

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;

int main() {
    int n; cin >> n; string s; cin >> s;
    int a[n]; a[0] = 0;
    for(int i = 0;i < n;i++){
        a[i] = 0;
    }
    
    int sum = 0;
    for(int i = 1;i < n;i++){
        if(s[i-1] == 'W'){
            sum++;
            a[i] = sum;
        }else{
            a[i] = sum;
        }
    }
    
    sum = 0;
     for(int i = n-2;i >= 0;i--){
           if(s[i+1] == 'E'){
               sum++;
               a[i] += sum;
           }else{
               a[i] += sum;
           }
    }
    cout << (int)*min_element(a,a+sizeof(a)/sizeof(a[0]));
}



Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long long ll;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  int n,i;cin>>n;vint p(n);int ans=0;
  for(i=0;i<n;i++){cin>>p[i];}
  //caricurate
  for(i=0;i<n-2;i++){
   if(((p[i]<p[i+1])&&(p[i+1]<p[i+2]))||((p[i]>p[i+1])&&(p[i+1]>p[i+2])))
   {ans++;}
  }
  //output
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] $){
		Scanner sc =new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];

		for (int i = 0; i < n - 1; i++) {
			a[sc.nextInt() - 1]++;
		}

		for (int x : a) {
			System.out.println(x);
		}

		sc.close();
	}
}



Measured memory_bytes: 61808
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int N;
	cin >> N;
	string c;
	cin >> c;
	int W=0, R=0;
	rep(i,N){
		if(c[i]=='W') W++;
		else R++;
	}
	int mW=0, mR=0;
	rep(i,R){
		if(c[i]=='W') mW++;
	}
	rep(i,W){
		if(c[N-1-i]=='R') mR++;
	}
	cout << max(mW,mR) << endl;

	return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll k;std::cin >> k;
  string s;std::cin >> s;
  if(s.size()<=k) std::cout << s << '\n';
  else {
    string ans = "";
    for(int i=0;i<k;i++) ans += s[i];
    std::cout << ans + "..." << '\n';
  }
  return 0;
}


Measured memory_bytes: 3132
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return tuple(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, XY):
    c = defaultdict(list)
    for i in range(N):
        x, y = XY[i]
        for j in range(N):
            if i == j:
                continue
            a, b = XY[j]
            c[(x-a, y-b)].append((i, j))

    ans = 0
    for _, v in c.items():
        l = set()
        r = set()

        for x, y in v:
            l.add(x)
            r.add(y)

        g = (len(l) - len(l & r))
        ans = max(ans, len(l | r) - g)
        # print(v, len(l | r), g, l & r)
    return N - ans


def main():
    N = read_int()
    XY = [read_int_n() for _ in range(N)]
    print(slv(N, XY))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6088
#include <bits/stdc++.h>
using namespace std;
int check(vector<int>& w, int& k, int& mid){
    int temp = mid, c = 0;
    // cout << "temp: " << temp << endl;
    for(int i=0; i<w.size(); i++){
        if(w[i]>mid) return 0;
        if(temp-w[i]<0){
            temp = mid;
            c++;
            temp -= w[i];
        }else{
            temp -= w[i];
        }
        // cout << temp  << endl;
    }
    if(c>=k){
    	return 0;
    }
    return 1;
    
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k, sum=0;
    cin >> n >> k;
    vector<int> w(n);
    for(int i=0;i<n;i++){
        cin >> w[i];
        sum += w[i];
    }
    int l=0,r=sum, ans=0, mid;
    while(l<=r){
        mid = floor((l+r)/2);
        if(check(w,k,mid) ){
            r = mid-1;
            ans = mid;
        }else{
            l = mid+1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3344
import java.util.Scanner

object Main {
  def main(args: Array[String]):Unit = {
    val sc = new Scanner(System.in)

    val S = sc.next

    val numList = (0 to S.length - 3).map{i =>
      S.substring(i,i + 3).toInt
    }

    val min = numList.map(n => Math.abs(n - 753)).min

    println(min)



  }

}


Measured memory_bytes: 27340
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
}

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

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

    long long ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int n,m,h[100010],ma[100010],ans;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>h[i];
		ma[i]=0;
	}
	for(int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		ma[a]=max(ma[a],h[b]);
		ma[b]=max(ma[b],h[a]);
	}
	for(int i=1;i<=n;i++)
		ans+=h[i]>ma[i];
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 4404
def examC():
    N = I()
    xy = [LI() for _ in range(N)]
    ansC = []
    for course in itertools.permutations(xy):
        cur = float(0)
        for i in range(len(course) - 1):
            cur += ((course[i+1][0]-course[i][0])**2 + (course[i+1][1]-course[i][1])**2)**(1/2)
        ansC.append(cur)
#    print(ansC)
    ans = sum(ansC)/len(ansC)
    print(ans)

import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

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

typedef long long ll;
 
 
int N, M, a[110];
 
inline int read() {
	int out = 0;
	bool flag = false;
	register char cc = getchar();
	while (cc < '0' || cc > '9') {
		if (cc == '-') flag = true;
		cc = getchar();
	}
	while (cc >= '0' && cc <= '9') {
		out = (out << 3) + (out << 1) + (cc ^ 48);
		cc = getchar();
	}
	return flag ? -out : out;
} 
 
inline void write(int x) {
	if (x < 0) putchar('-'), x = -x;
	if (x == 0) putchar('0');
	else {
		int num = 0;
		char cc[20];
		while (x) cc[++num] = x % 10 + 48, x /= 10;
		while (num) putchar(cc[num--]);
	}
	putchar(' ');
}

int main() {
	N = read(), M = read();
	int sum = 0; 
	for (int i = 1; i <= N; i++) sum += (a[i] = read());
	sort(a + 1, a + N + 1);
	for (int i = 1; i <= M; i++) if (a[N - i + 1] * 4 * M < sum) return puts("No") & 0;
	return puts("Yes") & 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	if (N / 10 == 0 && M / 10 == 0) {
		cout << N * M << endl;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(int i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
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; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
int main(){
  int h,w;  cin >> h >> w;
  string s[h];
  int d[h][w];
  rep(i,0,h){
    cin >> s[i];
  }
  rep(i,0,h)rep(j,0,w){
    if(s[i][j]!='#') d[i][j] = inf;
    else d[i][j] = 0;
  }
  rep(i,0,h)rep(j,0,w){
    if(d[i][j]!=inf){
      int k=j;
      while(d[i][k+1]>d[i][k]+1 && k+1<w){
        d[i][k+1] = d[i][k] + 1;
        k++;
      }
    }
  }
  rep(i,0,h)rep(j,0,w){
    if(d[i][j]!=inf){
      int k=j;
      while(d[i][k-1]>d[i][k]+1 && k-1>=0){
        d[i][k-1] = d[i][k] + 1;
        k--;
      }
    }
  }
  rep(i,0,h)rep(j,0,w){
    if(d[i][j]!=inf){
      int k=i;
      while(d[k+1][j]>d[k][j]+1 && k+1<h){
        d[k+1][j] = d[k][j] + 1;
        k++;
      }
    }
  }
  rep(i,0,h)rep(j,0,w){
    if(d[i][j]!=inf){
      int k=i;
      while(d[k-1][j]>d[k][j]+1 && k-1>=0){
        d[k-1][j] = d[k][j] + 1;
        k--;
      }
    }
  }
  int ma = 0;
  rep(i,0,h)rep(j,0,w){
    chmax(ma, d[i][j]);
  }
  cout << ma << endl;
  return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <random>
#include <iomanip>
#include <functional>
#include <list>
using namespace std;

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

	int max_x = -100;
	int min_x = 100;
	for (int i = 0; i < N; i++)
	{
		int x;
		cin >> x;
		max_x = max(max_x, x);
		min_x = min(min_x, x);
	}

	int max_y = -100;
	int min_y = 100;
	for (int i = 0; i < M; i++)
	{
		int y;
		cin >> y;
		max_y = max(max_y, y);
		min_y = min(min_y, y);
	}

	for (int Z = -100; Z <= 100; Z++)
	{
		if (!(Z > X && Z <= Y))
			continue;

		if (!(Z > max_x))
			continue;

		if (!(Z <= min_y))
			continue;

		cout << "No War";
		return 0;
	}

	cout << "War";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int a[n],b[n];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		if(b[i]<a[n-1])
		printf("%d\n",a[n-1]);
		if(b[i]==a[n-1])
		printf("%d\n",a[n-2]);
	}
	return 0;
}

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

int n, a;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0)
        {
            cout << "DENIED";
            return 0;
        }
    }
    cout << "APPROVED";
}

Measured memory_bytes: 256