akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int h,w;
int ex,ey;
short dp[101][101][101][101];
char a[101][101];
short S[101][101];

short calc(int r1, int r2, int c1, int c2)
{
	if(r1>r2||c1>c2) return 0;
	int ans = S[r2][c2];
	if(r1>0&&c1>0) ans+=S[r1-1][c1-1];
	if(r1>0) ans-=S[r1-1][c2];
	if(c1>0) ans-=S[r2][c1-1];
	return ans;
}

bool valid(int u, int d, int l, int r)
{
	if(u>ex||d>h-1-ex||l>ey||r>w-1-ey) return false;
	return true;
}

void amax(short &x, short y)
{
	if(y>x) x=y;
}

void update(int u, int d, int l, int r)
{
	int val = dp[u][d][l][r];
	//cerr<<u<<' '<<d<<' '<<l<<' '<<r<<' '<<val<<'\n';
	if(valid(u+1,d,l,r))
	{
		int L = r; int R = w - l - 1;
		int U = d; int D = h - (u + 1) - 1;
		amax(dp[u+1][d][l][r], val + calc(max(U,ex-u-1),min(D,ex-u-1),max(L,ey-l),min(R,ey+r)));
	}
	if(valid(u,d+1,l,r))
	{
		int L = r; int R = w - l - 1;
		int U = d + 1; int D = h - (u) - 1;
		amax(dp[u][d+1][l][r], val + calc(max(U,ex+d+1),min(D,ex+d+1),max(L,ey-l),min(R,ey+r)));
	}
	if(valid(u,d,l+1,r))
	{
		int L = r; int R = w - (l+1) - 1;
		int U = d; int D = h - u - 1;
		amax(dp[u][d][l+1][r], val + calc(max(U,ex-u),min(D,ex+d),max(L,ey-l-1),min(R,ey-l-1)));
	}
	if(valid(u,d,l,r+1))
	{
		int L = r+1; int R = w - l - 1;
		int U = d; int D = h - u - 1;
		amax(dp[u][d][l][r+1], val + calc(max(U,ex-u),min(D,ex+d),max(L,ey+r+1),min(R,ey+r+1)));
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>h>>w;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='o') S[i][j]=1;
			if(i>0) S[i][j]+=S[i-1][j];
			if(j>0) S[i][j]+=S[i][j-1];
			if(i>0&&j>0) S[i][j]-=S[i-1][j-1];
			if(a[i][j]=='E') ex=i,ey=j;
		}
	}
	dp[0][0][0][0]=0;
	for(int sum = 0; sum <= h+w; sum++)
	{
		for(int u = 0; u <= min(ex,sum); u++)
		{
			for(int d = 0; d+u<=sum&&d<=h-1-ex; d++)
			{
				for(int l = 0; l<=ey&&d+u+l<=sum; l++)
				{
					int r = sum-u-d-l;
					if(r>=0&&r<=w-1-ey)
					{
						update(u,d,l,r);
					}
				}
			}
		}
	}
	cout<<dp[ex][h-1-ex][ey][w-1-ey]<<'\n';
}


Measured memory_bytes: 198912
#include<bits/stdc++.h>
#define fi first
#define se second
#define LL long long

using namespace std;
const int maxn = 2e5 + 5;
typedef pair<int, int> P;

int a[maxn];

int main() {
#ifdef TT
    freopen("xxx.in", "r", stdin);
#endif // TT
    int n, i, x;
    LL ans = 0;
    scanf("%d", &n);
    for(i = 0;i < n; i++) scanf("%d", &a[i]);
    for(i = n - 1, x = 0;i >= 0; i--) {
        if(a[i] > i || a[i] < x) return puts("-1"), 0;
        if(a[i] > x) {
            ans += a[i];
            x = a[i];
        }
        x = max(x - 1, 0);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f(i,a,b) for(i=a;i<=b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ll long long
#define mod (1000*1000*1000+7)
#define scan1(x) scanf("%lld",&x)
#define scan2(x,y) scanf("%lld %lld",&x,&y)
#define scan3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define print(x) printf("%lld\n",x)
#define ff first
#define ss second
using namespace std;
ll h,w,i,j;
vector<vector<ll>> dp(1001,vector<ll>(1001));
string s[1001];

int main(){
    
    scan2(h,w);
    f(i,1,h)
    cin>>s[i];
    
    dp[1][1]=1;
    f(i,2,h)
    if(s[i][0]=='.')
    dp[i][1]=dp[i-1][1];
    
    f(i,2,w)
    if(s[1][i-1]=='.')
    dp[1][i]=dp[1][i-1];
    
    f(i,2,h)
    f(j,2,w)
    if(s[i][j-1]=='.')
    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
    
    cout<<dp[h][w]<<"\n";
}

Measured memory_bytes: 9216
n = int(input())
d = []
for _ in range(n):
    d.append(int(input()))
count_0 = 1
d = sorted(d)
for i in range(n):
    if i == n-1: break
    if d[i] == d[i+1]: continue
    count_0 += 1

d = sorted(d,reverse=True)
count_1 = 1
for i in range(n):
    if i == n-1: break
    if d[i] == d[i+1]: continue
    count_1 += 1
print(max(count_0,count_1))

Measured memory_bytes: 3064
from itertools import product
N = int(input())
cnt = 0
for i in range(3, len(str(N))+1):
  for p in product(["7", "5", "3"], repeat = i):
    if "7" in p and "5" in p and "3" in p:
      p = int("".join(p))
      if p <= N:
        cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
  int i=0;
  int input=-1;//入力
  int max =-1,mid = -1,min = -1;


  while(cin >> input ){
    if( min < input){
       min = input;
    }

    if(min > mid){
      swap(min,mid);
    }

    if(mid>max){
      swap(mid,max);
    }

  }

cout <<  max<<"\n"
<< mid<<"\n"
<< min<<"\n";

  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;

int a[100001];

int mpow(int b, int e)
{
    int ret=1;
    for(int i=0; i<e; i++)
    {
        ret=ret*b%mod;
    }
    return ret;
}

int dp[100001];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
        dp[i] = INF;
    }
    dp[0] = 0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<min(n, i+k+1); j++)
        {
            dp[j] = min(dp[j], dp[i]+abs(a[j]-a[i]));
        }
    }
    cout << dp[n-1];
}
//TODO: 56
//come back to 50D, 55D


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  rep(i,n+1){
    if(10 <= i && i <= 99) ans++;
    if(1000 <= i && i <= 9999) ans ++;
    if(i == 100000) ans++;
  }
  cout << n-ans << endl;
}

Measured memory_bytes: 256
n,m,l = map(int,input().split())
b = []
a = []
c = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    a1 = list(map(int,input().split()))
    a.append(a1)
for k in range(m):
    b1 = list(map(int,input().split()))
    b.append(b1)


for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
for c in c:
    print(*c)


Measured memory_bytes: 7064
fun main(args: Array<String>){
    val s = readLine()!!

    var n = 'a'
    while(n <= 'z'){
        val list = mutableListOf<Int>()
        for(i in s.indices){
            if(s[i] == n){
                list.add(i)
            }
        }
        list.sort()
        for(i in 0 until list.size - 1){
            if(list[i+1] - list[i] <= 2){
                println("${list[i]+1} ${list[i+1]+1}")
                return
            }
        }
        n++
    }
    println("-1 -1")
}

Measured memory_bytes: 39204
#include<bits/stdc++.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MOD 1000000007
 
using namespace std;
 
bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
  	return left.first< right.first;
}
bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
  	return left.second < right.second;
}
 
void dfs(lli ed, lli num, vector<map<lli,lli>>& vec){
    lli n=1;
    for(auto e: vec[num]){
        if(n == ed)n++;
        if(e.second != -1)continue;
        vec[num][e.first] = n;
        vec[e.first][num] = n;   
        dfs(n, e.first, vec);
        n++;
    }
}
 
lli gcd(lli a, lli b){
    if(a < b)return gcd(b, a);
    lli temp;
    while((temp = a%b)){
        a=b;
        b=temp;
    }
    return b;
}

struct nCr{
  vector<lli> f, rf;
  lli count=0;
  nCr(lli num): f(num), rf(num){
      count = num;
      f[0] = 1;
      rep1(i, num) f[i] = (f[i - 1] * i) % MOD;
      rep0(i, num+1) rf[i] = inv(f[i]);
  }
    
  lli inv(lli x) {
      lli res = 1;
      lli k = MOD - 2;
      lli y = x;
      while (k) {
          if (k & 1) res = (res * y) % MOD;
          y = (y * y) % MOD;
          k /= 2;
      }
      return res;
  }
  lli C(lli n, lli k) {
      lli a = f[n];
      lli b = rf[n-k];
      lli c = rf[k];
   
      lli bc = (b * c) % MOD;
   
      return (a * bc) % MOD;
  }
};

struct UF{
    vector<int> par,size;

    UF(int N) : par(N), size(N, 1){
        rep0(i,N)par[i] = i;
    }

    int root(int x){
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        size[rx] += size[ry];
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int getSize(int x){
        return size[x];
    }
};
int main(){
  lli n,k;
  cin >> k >> n;
  vector<lli> vec(n);
  rep0(i,n)cin >> vec[i];
  sort(all(vec));

  lli l = 0;
  rep1(i,n){
    if(l < ( vec[i%n] - vec[(i-1)] < 0 ?vec[i%n] - vec[(i-1)]+k : vec[i%n] - vec[(i-1)] )){
      l = (vec[i%n] - vec[(i-1)] < 0 ?vec[i%n] - vec[(i-1)]+k: vec[i%n] - vec[(i-1)]) ;
    }
  }
  cout << k-l;
}


Measured memory_bytes: 1792
//轩哥牛逼! 
#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset> 
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
//#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}
 
template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod 
	ll ans=1;
	while(n){
		if(n&1) ans=((ans%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
ll k;
map<ll,int> vis;
inline ll solve(){
    ll sum=0;
    int cnt=0;
    while(true){
        sum=(sum*10+7)%k;
        //cerr<<sum<<endl;
        cnt++;
        if(vis[sum]) return -1;
        vis[sum]=1;
        if(sum==0) return cnt;
    }
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
	read(k);
    write(solve());
	//===========================================================
	return 0;
}

Measured memory_bytes: 66092
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define Mod 1000000007
#define limit 1000008
using namespace std;
bool vis[limit],vis2[limit];
vector <int> prime;
int c[limit];
void p()
{
    for(int i=3; i*i<=limit; i+=2)
    {
        if(vis[i]==0)
            for(int j=i*i; j<limit; j+=i*2)
                vis[j]=1;
    }
    prime.pb(2);
    for(int i=3; i<limit; i+=2)
        if(vis[i]==0)
            prime.pb(i);
}
void solve(int t)
{
    int i,j,n,m,ck=0;
    scanf("%d",&n);
    int D[n+5];
    for(i=0; i<n; i++)
    {
        scanf("%d", &D[i]);
        c[D[i]]++;
    }
    m = D[0];
    for(i=1; i<n; i++)
    {
        m = __gcd(m,D[i]);
    }
    if(m>1)
    {
        cout <<"not coprime\n";
        return ;
    }
    bool par = true;
    for(int i = 2; i <= 1000000; i++)
    {
        int cnt = 0;
        for(int j = i; j <= 1000000; j += i)
        {
            cnt += c[j];
        }
        if(cnt > 1) par = 0;
    }
    if(par)
    {
       cout << "pairwise coprime" << endl;
       return ;
    }

        cout <<"setwise coprime\n";

    return;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    p();
    int t,tt=1;
 //   cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
  return 0;
}



Measured memory_bytes: 12568
// #include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
// #include <algorithm>
#define pb push_back
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f first
#define s second
// #define cerr if(0)cerr
using namespace std;
typedef long long LL;
typedef pair<int,LL> PILL;

const int N=1e5+10;
const LL I=1e9+7;
int n,a,b;
vector <int> V[N];
LL DP[N][2];

void dfs(int x, int p)
{
    // printf("x=%d, p=%d\n",x,p);
    DP[x][0]=DP[x][1]=1;
    for(auto s : V[x])
    {
        if(s==p)continue;
        dfs(s,x);
        DP[x][0]=(DP[x][0]*(DP[s][0]+DP[s][1]))%I;
        DP[x][1]=(DP[x][1]*DP[s][0])%I;
    }
}

LL maxi(LL x, LL y){if(y>x)return y;return x;}

int main()
{
  // boost;
  scanf("%d",&n);
  for(int i=1; i<n; i++)
  {
    scanf("%d",&a);
    scanf("%d",&b);
    V[a].pb(b);
    V[b].pb(a);
  }
  dfs(1,1);
  printf("%lld",(DP[1][0]+DP[1][1])%I);


  return 0;
}


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


class UnionFind:
    def __init__(self, N):
        self.Parent = [-1]*(N+1)
    #Aの親を探す。このときParent[A]は親の値からグループサイズに変わる。探索の最適化
    def root(self, A):
        if self.Parent[A] < 0: return A
        self.Parent[A] = self.root(self.Parent[A])
        return self.Parent[A]
    #Aが属しているグループのサイズを求める
    def size(self, A):
        return -self.Parent[self.root(A)]
    
    def connect(self,A,B):
        A = self.root(A)
        B = self.root(B)
        if A == B: return False
        
        if self.size(A) < self.size(B): A,B = B,A
        self.Parent[A] += self.Parent[B]
        self.Parent[B] = A
        return True



N,M = map(int,input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
Uni = UnionFind(N)
ans = [-1]*(M)
ans[M-1] = N*(N-1)//2 
for i in reversed(range(1,M)):
    ans[i-1] = ans[i]
    if Uni.root(AB[i][0]) != Uni.root(AB[i][1]):
        ans[i-1] -= Uni.size(AB[i][0])*Uni.size(AB[i][1])
    Uni.connect(AB[i][0], AB[i][1])
for i in range(M):
    print(ans[i])




Measured memory_bytes: 33388
#include <iostream>
    #include <vector>
    #include <algorithm>
     
    #define MAX 100000
     
    using namespace std;
     
    int main() {
        int n, v;
        scanf("%d", &n);
        vector< vector<int> > d(2, vector<int>(MAX + 1));
        for (int i = 0; i < n; ++i) {
            scanf("%d", &v);
            ++d.at(i % 2).at(v);
        }
        auto a = max_element(d.front().begin(), d.front().end()), b = max_element(d.back().begin(), d.back().end());
        if (a - d.front().begin() != b - d.back().begin()) printf("%d\n", n - *a - *b);
        else {
            int va = *a, vb = *b;
            *a = 0, *b = 0;
            a = max_element(d.front().begin(), d.front().end()), b = max_element(d.back().begin(), d.back().end());
            printf("%d\n", min(n - va - *b, n - vb - *a));
        }
        return 0;
    }

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

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

  vector<double> v(n);
  for(int i = 0; i < n; i++) cin >> v[i];

  stable_sort(v.begin(), v.end());

  double ans = v[0];

  for(int i = 1; i < n; i++) ans = (ans + v[i]) / 2.0;

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


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<pair<int, int>> nums(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> nums[i].first >> nums[i].second;
	}
	bool chk = false;
	for (int i = 0; i + 2 < n && !chk; ++i)
	{
		bool ok = true;
		for (int j = i; j <= i + 2; ++j)
		{
			ok &= (nums[j].first == nums[j].second);
		}
		chk |= ok;
	}
	cout << (chk ? "Yes\n" : "No\n");
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(){
    int l,c,sheet[101][101],suml,sumc;
    cin >>l>>c;
    for(int i=0;i<l;i++){
        suml=0;
        for(int j=0;j<c+1;j++){
            if(j<c){
            	cin >>sheet[i][j];
            	suml += sheet[i][j];
            }else
            	sheet[i][j]=suml;
        }
    }
    for(int i=0;i<c+1;i++){
        sumc = 0;
        for(int j=0;j<l+1;j++)
            if(j<l)
            	sumc+=sheet[j][i];
        	else
            	sheet[j][i]=sumc;
    }
    for(int i=0;i<l+1;i++)
        for(int j=0;j<c+1;j++){
            if(j==c)
                cout<<sheet[i][j]<<endl;
            else
                cout <<sheet[i][j]<<" ";
        }
        
}


Measured memory_bytes: 3136
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

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

    set<string> se;

    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        se.insert(s);
    }

    cout << (int) se.size() << endl;

    return 0;
}


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

typedef complex<double> P;
typedef pair<P,P> L;

const double EPS = 1e-8;
const double EPS6 = 1e-6;

bool equal(double a, double b){
  return fabs(a-b) < EPS;
}

double dot(P a, P b){ return real(conj(a)*b); }

P rotate(P p, double rad){
  double x = real(p) * cos(rad) - imag(p) * sin(rad);
  double y = real(p) * sin(rad) + imag(p) * cos(rad);
  return P(x,y);
}

P proj(P p, L l){
    return l.first + dot(p - l.first, l.second - l.first) / norm(l.second - l.first) * (l.second - l.first);
}

P reflect(P p, L l){
  return p + (proj(p,l) - p) * 2.0;
}

int n;
vector<P> in_v;

void rotate_convex(vector<P> &v, double rad){
  for(int i=0;i<n;i++){
    v[i] = rotate(v[i], rad);
    if(equal(real(v[i]), 0.0)) v[i] = P(0, imag(v[i]));
    if(equal(imag(v[i]), 0.0)) v[i] = P(real(v[i]), 0);
  }
}

void reflect_convex(vector<P> &v, L l){
  for(int i=0;i<n;i++){
    v[i] = reflect(v[i], l);
    if(equal(real(v[i]), 0.0)) v[i] = P(0, imag(v[i]));
    if(equal(imag(v[i]), 0.0)) v[i] = P(real(v[i]), 0);
  }
}

pair<double, double> calc_next(vector<P> &v, int pos){
  L l = L(v[pos], v[(pos+1)%n]);
  P p = (l.second - l.first) / abs(l.second - l.first) * EPS6; // ?????????1e-6???????????????
  double ar_be = max(arg(l.first+p), arg(l.second-p));
  double ar_en = min(arg(l.first+p), arg(l.second-p));

  //printf("ar_max = %.5f, ar_min = %.5f\n", ar_max*180.0/M_PI, ar_min*180.0/M_PI);

  // [-PI ~ PI] -> [0 ~ 2PI]
  if(equal(ar_be, 0.0)) ar_be = 0;
  else if(ar_be <= -EPS) ar_be += 2.0 * M_PI;
  if(equal(ar_en, 0.0)) ar_en = 0;
  else if(ar_en <= -EPS) ar_en += 2.0 * M_PI;

  if(ar_en < ar_be) swap(ar_be, ar_en);

  // 180?????\????????¨ar_be??¨ar_en??????????????£?????????
  if(ar_en - ar_be >= M_PI) {
    swap(ar_be, ar_en);
    if(ar_be >= M_PI) ar_be = 0; // ar_be <= 0 ([-PI ~ PI]?????´???)
  }

  return make_pair(ar_be, ar_en);
}

int dfs(int cnt, double begin, double end, vector<P> v, set<int> &visited){
  int res = 0;
  pair<double, double> next;
  double n_be, n_en;
  vector<P> n_v;

  if(cnt == n) {
    return 1;
  }

  for(int i=0;i<n;i++){
    if(visited.count(i)) continue;
    n_v = v;
    reflect_convex(n_v, L(v[i], v[(i+1)%n])); 
    next = calc_next(n_v, i);
    n_be = max(begin, next.first);
    n_en = min(end, next.second);
    if(n_be > n_en - EPS) {
      continue;
    }
    visited.insert(i);
    res += dfs(cnt+1, n_be, n_en, n_v, visited);
    visited.erase(i);
  }

  return res;
}

int solve(){
  int res = 0;  

  for(int i=0;i<n;i++){
    set<int> st;
    vector<P> v = in_v;
    st.insert(i);
    rotate_convex(v, -arg(v[i]));
    reflect_convex(v, L(v[i], v[(i+1)%n]));
    res += dfs(1, arg(v[i]), arg(v[(i+1)%n]), v, st);
  }

  return res;
}

int main(){
  double sx, sy, x, y;
  while(cin >> n && n){
    in_v.clear();
    cin >> sx >> sy;
    for(int i=0;i<n;i++){
      cin >> x >> y;
      in_v.push_back(P(x-sx, y-sy));
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 1340
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]
// Queue
type Queue<'a> = Queue of ('a list * 'a list)

[<RequireQualifiedAccess>]
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module Queue =
  let empty = Queue([], [])
  let ofList l = Queue(l, [])
  let singleton x = Queue([x], [])
  let private check (Queue(f, r)) =
    match (f, r) with
    | ([], _) -> Queue(List.rev r, [])
    | _ -> Queue(f, r)
  let snoc x (Queue(f, r)) = Queue(f, x::r) |> check
  let head (Queue(f, _)) = List.head f
  let tryHead (Queue(f, _)) = List.tryHead f
  let tail (Queue(f, r)) =
    match f with
    | [] -> failwith "queue is empty"
    | _::f -> Queue(f, r) |> check
  let tryUncons (Queue(f, r)) =
    match f with
    | [] -> None
    | x::f -> Some(x, Queue(f, r) |> check)
  let (|Cons|Nil|) q =
    match tryUncons q with
    | Some(h,t) -> Cons(h, t)
    | None -> Nil
// Queue

// start
let (H,W) = readInts() |> pair
let s =
  let s=Array2D.zeroCreate H W 
  for i in 0..(H-1) do
    readStr().ToCharArray() |> Array.iteri (fun j x -> s.[i,j]<-x='.')
  s

let sum =
  seq {
    for i in 0..(H-1) do
      for j in 0..(W-1) do
        yield s.[i,j]
  }
  |> Seq.sumBy (function | true -> 1 | false -> 0)

let route =
  let r = Array2D.create H W None
  let rec bfs = function
    | Queue.Nil -> ()
    | Queue.Cons ((y,x), que) ->
      let l = r.[y,x] |> Option.map inc
      [(y-1,x); (y+1,x); (y,x-1); (y,x+1)]
      |> List.fold (fun que (p,q) ->
        if
          0<=p&&p<H&&0<=q&&q<W
          && s.[p,q]
          && Option.isNone r.[p,q]
        then
          r.[p,q]<-l
          que |> Queue.snoc (p,q)
        else
          que
      ) que
      |> bfs

  r.[0,0] <- Some 0
  bfs (Queue.singleton (0,0))
  r.[H-1,W-1]

route
|> function
  | None -> -1
  | Some r -> sum - r - 1
|> printfn "%d"

Measured memory_bytes: 14428
#include <bits/stdc++.h>
#define INF 990000000
//
using namespace std;

int main() {
string s;
cin>>s;
string te="";
int flag=0;
for(int i=0;i<10;i++){
te+="hi";
if(te.compare(s)==0){
flag=1;
break;
}

}
if(flag==1)
cout <<"Yes"<<endl;
else
cout <<"No"<<endl;


}






Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long lo;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for((a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for((a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto it : a)
#define INF 200100
#define MOD 1000000007
#define M 1000000007
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
/*order statistic tree
typedef
tree<
  lo,
    null_type,
  less_equal<lo>,
  rb_tree_tag,
  // This policy updates nodes' metadata for order statistics.
  tree_order_statistics_node_update>
ordered_set;*/

/*#define gc getchar_unlocked
#define pc putchar_unlocked
inline void sprlo( lo a){
    lo i=0;
    char S[20];
    if(a==0)pc('0');
    if(a<0){
        pc('-');
        a*=-1;
    }
    while(a>0){
        S[i++]=a%10+'0';
        a=a/10;
    }
    --i;
    while(i>=0)
    pc(S[i--]);
    pc(' ');
}
inline void lprlo( lo a){
    lo i=0;
    char S[20];
    if(a==0)pc('0');
    while(a>0){
        S[i++]=a%10+'0';
        a=a/10;
    }
    --i;
    while(i>=0)
    pc(S[i--]);
    pc('\n');
}
inline lo uscan(){
    lo n=0;
    char c=gc();
    while(c<'0'||c>'9')c=gc();
    while(c<='9'&&c>='0'){
	    n=n*10+c-'0';
	    c=gc();
	}
    return n;
}*/
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
bool dig(lo n){
    lo x=0;
    while(n>0){
        if(n%10==9)return true;
        n/=10;
        x++;
    }
    return false;;
}
int main(){
    std::ios::sync_with_stdio(false);
	lo n;
	cin>>n;
	set<lo>ans;
	REP(0,n){
	lo x;
	cin>>x;
	if(ans.find(x)==ans.end())ans.insert(x);
	else ans.erase(x);
	}
	cout<<ans.size();
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
ll e[MAX_N];
ll o[MAX_N];

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin>>a[i];
    ll e_f=0, e_s=0, o_f=0, o_s=0, e_num=0, o_num=0;
    for(ll i=0;i<n;i++){
        if(i%2==0){
            e[a[i]]++;
            if(e[a[i]]>e_f){
                if(e_num!=a[i]) e_s=e_f;
                e_f=e[a[i]];
                e_num=a[i];
            }else if(e[a[i]]>e_s){
                e_s=e[a[i]];
            }
        }else{
            o[a[i]]++;
            if(o[a[i]]>o_f){
                if(o_num!=a[i]) o_s=o_f;
                o_f=o[a[i]];
                o_num=a[i];
            }else if(o[a[i]]>o_s){
                o_s=o[a[i]];
            }
        }
    }
    if(e_num!=o_num){
        cout<<n - e_f - o_f<<endl;
    }else{
        cout<<min(n - e_f - o_s, n - e_s - o_f)<<endl;
    }
}

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



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

    if(((a == b) + (b == c) + (c == a)) == 1) puts("Yes");
    else puts("No");
    return 0;
}

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

const int MOD = (int)1e9+7;

int main(){
	long long L,R;
	cin >> L >> R;

	if(R-L>2019){
		cout << 0 << endl;
		return 0;
	}

	long long ans=1e9;
	for(long long i=L;i<R;i++){
		for(long long j=i+1;j<=R;j++){
			long long xx=i*j;
			xx%=2019;
			ans=min(ans,xx);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import Data.List
import Debug.Trace

main :: IO ()
main = do
  _ <- readLn :: IO Int
  as <- (map read . words) <$> getLine :: IO [Int]
  print $ solve $ format as

format :: [Int] -> [(Int, Int)]
format as =
  map (\bs -> (head bs, length bs)) $ (group . sort) as

solve :: [(Int, Int)] -> Int
solve as = sum $ map (\(b, cnt) ->
 if b > cnt
 then cnt
 else
   if b == cnt
   then 0
   else cnt - b) as

mytrace a = trace (show a) a


Measured memory_bytes: 37500
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  string S; cin>>S;
  cout<<S.substr(0,4)<<" "<<S.substr(4,8)<<endl;
  }


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

bool solve(vector<int> A,int N)
{
	int ikeru = 0;
	for (int i = 0; i < N; ++i)
	{
		if(i > ikeru)
		{
			return false;
		}
		if (i + A[i] > ikeru)
		{
			ikeru = i + A[i];
		}
	}
	return true;
}


int main(int argc, char const *argv[])
{
	int N;
	cin >> N;
	vector<int> a(N);
	vector<int> A(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
		A[i] = a[i]/10; 
	}

	if (solve(A,N) == false)
	{
		cout << "no\n";
		return 0;
	}

	reverse(A.begin(),A.end());

	if (solve(A,N))
	{
		cout << "yes\n";
	}
	else
	{
		cout << "no\n";
	}

	
	return 0;
}


Measured memory_bytes: 6424
#include <iostream>
#include <map>

using namespace std;

long n, res;
map<long, long> map_a;

int main()
{
	long x;
	map<long, long>::iterator it;

	cin >> n;
	for (long i = 0; i < n; ++i)
	{
		cin >> x;
		map_a[x]+=1;
	}

	for (it = map_a.begin(); it != map_a.end(); ++it)
		if (it->first <= it->second)
			res += it->second - it->first;
		else
			res += it->second;

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int x,d, k;
   cin>>x>>k>>d;
   x=abs(x);
  if(x/d>=k){
    cout<<x-k*d<<endl;
  }
  else{    
    	k-=x/d;
    x-=(x/d)*d;
       if(k%2==0) cout<<abs(x)<<endl;
       else cout<<abs(x-d)<<endl;
  }
}

Measured memory_bytes: 3584
#include<stdio.h>
#include <string.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
int main(){
	char s[100002];
	int ans = 0;
	scanf("%s",s);
	FOR(i,1,strlen(s)) if(s[i-1] != s[i]) ans++;
	printf("%d",ans);
}

Measured memory_bytes: 256
n = int(input())
a = 11
p = [11]

def is_prime(x):
    if x%2==0:
        return False
        
    for i in range(3, x//2+1, 2):
        if x % i == 0:
            return False
    else:
        return True

while len(p) < n:
    a += 5
    if is_prime(a):
        p.append(a)

print(*p)


Measured memory_bytes: 63056
/**********************************************************************
   File abc107_b.cpp
   Author  harunaya
   Date   2020-06-27(Sat)
   note   
**********************************************************************/

#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>;

int main() {
  // Declare values
  int H, W; cin >> H >> W;
  vector<vector<char>> table(H, vector<char>(W));
  // input
  rep(i, H) {
    rep(j, W) {
      cin >> table.at(i).at(j); 
    }
  }

  // Checkpoint
  vector<bool> line(H, false);
  vector<bool> quene(W, false);

  rep(i, H) {
    rep(j, W) {
      if (table.at(i).at(j) == '#') {
        line.at(i) = true;
        quene.at(j) = true;
      }
    }
  }


  rep(i, H) {
    if (line.at(i)){
      rep(j, W) {
        if (quene.at(j)) {
          cout << table.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
  
  return 0; 
}

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int H, W, N;
    cin >> H >> W >> N;
    int ans = min((N+H-1)/H, (N+W-1)/W);
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e12+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int a,b,c,x,i,j,k,ans=0;cin>>a>>b>>c>>x;
	for(i=0;i<=a;i++){
		for(j=0;j<=b;j++){
			for(k=0;k<=c;k++){
				if(i*500+j*100+k*50==x){ans++;}
			}
		}
	}
	cout<<ans<<endl;
	RE;
}

Measured memory_bytes: 256
s = str(input())
K = int(input())
L = []
M = []
con = 0
for i in s:
  L.append(i)
L = list(set(L))
L.sort()
for j in range(len(s)):
    if s[j] == L[0]:
      for k in range(1,6):
        if j + k >=len(s):
          M.append(s[j:])
          break
        else:
          M.append(s[j:j+k])
if len(L) != 1:
  for l in range(len(s)):
    if s[l] == L[1]:
      for m in range(1,6):
        if l + m >= len(s):
          M.append(s[l:])
          break
        else:
          M.append(s[l:l+m]) 
if len(M) < K:
  for n in range(len(s)):
    if s[n] == L[2]:
      for o in range(1,6):
        if n + o >=len(s):
          M.append(s[n:])
          break
        else:
          M.append(s[n:n+o])
M = list(set(M))
M.sort()
print(M[K - 1])  
          

Measured memory_bytes: 10084
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
   ll n,q,ans=0;
   cin>>n;
   vll a(100001,0);
   rep(i,n){
       ll k;
       cin>>k;
       a.at(k)++;
       ans+=k;
   }
    
   cin>>q;
   rep(i,q){
       ll b,c,k;
       cin>>b>>c;
       if(a.at(b)>0){
           k=a.at(b);
           a.at(c)+=k;
           a.at(b)=0;
           ans=ans+c*k-k*b;
          
       }
        cout<<ans<<endl;
   }
  

}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;

int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n,k;
        cin >> n >> k;
        int a[n+1],dp[n+1]={0};
        for(int i=0; i<n; i++)cin >> a[i];
        dp[0]=0;
        dp[1]=abs(a[1]-a[0]);
        
        for(int i=2; i<n; i++){
            dp[i]=INT_MAX;
            for(int j=1; j<=k; j++)
            if((i-j)>=0)
            dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
        }
        cout << dp[n-1] << '\n';
}

Measured memory_bytes: 1792
#[R,G,B,N] = list(map(int,input().split()))
import collections
N = int(input())
xy = [tuple(map(int,input().split())) for i in range(N)]
xy.sort( key = lambda x: (x[0],x[1]))
l = []
for i in range(N):
    for j in range(i+1,N):
        (x_diff, y_diff) = [xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]]
        l.append((x_diff, y_diff))
dic = collections.Counter(l)
val = dic.values()
if len(val) == 0:
    print(1)
else:
    print(N - max(val))

Measured memory_bytes: 3572
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		long N = Long.parseLong(W);

		String S = in.readLine();

		int ans = 0;
		boolean[] left = new boolean['z'-'a'+1];
		boolean[] right = new boolean['z'-'a'+1];

		for(int k=1;k<N;k++){
			Arrays.fill(left, false);
			Arrays.fill(right, false);
			for(int i=0;i<N;i++){
				if(i<k){
					left['z'-S.charAt(i)]=true;
				}else{
					right['z'-S.charAt(i)]=true;
				}
			}
			int match=0;
			for(int i=0;i<left.length;i++){
				if(left[i]&&right[i]){
					match++;
				}
			}
			ans = Math.max(ans, match);
		}


		System.out.println(ans);
	}
}


Measured memory_bytes: 25040
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#define MAXN 5010
using namespace std;
const int MOD = 1e9 + 7;
long long dp[MAXN][MAXN],f[MAXN],t[MAXN];
int siz[MAXN];
vector<int> a[MAXN];
void dfs(int x,int fa){
    siz[x] = 1;
    dp[x][1] = 1;
    for(int i = 0;i < a[x].size();i++){
        int u = a[x][i];
        if(u == fa)
            continue;
        dfs(u,x);
        for(int j = 0;j <= siz[x]; ++j){
            t[j] = dp[x][j];
            dp[x][j] = 0;
        }
        for(int j = 0;j <= siz[x]; ++j)
            for(int k = 0;k <= siz[u]; ++k)
                (dp[x][j + k] += t[j] * dp[u][k] % MOD) %= MOD;
        siz[x] += siz[u];
    }
    for(int i = 0;i <= siz[x]; i += 2)
        dp[x][0] = (dp[x][0] - dp[x][i] * f[i] % MOD + MOD) % MOD;
}
int n,u,v;
int main(){
    scanf("%d",&n);
    for(int i = 1;i < n; ++i){
        scanf("%d%d",&u,&v);
        a[u].push_back(v);
        a[v].push_back(u);
    }   
    f[0] = 1;
    for(int i = 2;i <= n;i += 2)
        f[i] = f[i - 2] * (i - 1) % MOD;
    dfs(1,0);
    printf("%lld",MOD - dp[1][0]);
}

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

const int N = 100;

int a[N+5];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", a+i);
    int cnt = 0;
    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= n; ++j){
            for (int k = 1; k <= n; ++k){
                if (i != j && j != k && i != k && a[i] != a[j] && a[j] != a[k] && a[i] != a[k]){
                    if (a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i]) ++cnt;
                }
            }
        }
    }
    printf("%d\n", cnt / 6);
    return 0;
}

Measured memory_bytes: 3820
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k=0;
string s, t;


int main()
{
	cin >> n >> k;
	vector<int> x(n);
	rep(i, n)
	{
		cin >> a; x[a-1]++;
	}
	int64_t sum = 0;
	sort(all(x),greater<int>());
	for (int i = 0; i < k; i++)
		sum += x[i];
	cout << n - sum << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

using namespace std;

int main(){
    long long N, D, X[200001], Y[200001], cnt = 0;
    scanf("%lld %lld", &N, &D);
    for(int i = 0; i < N; i++){
        scanf("%lld %lld", &X[i], &Y[i]);
        if(X[i] * X[i] + Y[i] * Y[i] <= D * D){
            cnt++;
        }
    }

    printf("%lld\n", cnt);

    return 0;
}

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

uint64_t iter_lucas(uint64_t sum, int i, uint64_t a, uint64_t b, int n) {
  if (n == 0) return 2;
  if (n == 1) return 1;
  if (n == i) return sum;
  iter_lucas(a + b, i + 1, b, (a + b), n);
}

uint64_t lucas(int n) {
  return iter_lucas(0, 1, 2, 1, n);
}

int main(){
  int n;
  cin >> n;
  cout << lucas(n) << endl;
  
}


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

int main(void)
{
    int N, M;
    cin >> N >> M;
    vector<vector<pair<int, int>>> cities(N, vector<pair<int, int>>());
    for (int i = 0; i < M; i++) {
        int P, Y;
        cin >> P >> Y;
        cities[P-1].push_back(make_pair(Y, i));
    }
    for (int p = 0; p < N; p++) {
        sort(cities[p].begin(), cities[p].end());
    }
    vector<pair<int, int>> cities_id(M);
    for (int p = 0; p < N; p++) {
        int number = 0;
        for (auto city : cities[p]) {
            number++;
            cities_id[city.second] = make_pair(p+1, number);
        }
    }

    for (auto id : cities_id) {
        cout << setfill('0') << right << setw(6) << id.first;
        cout << setfill('0') << right << setw(6) << id.second << endl;
    }

    return 0;
}



Measured memory_bytes: 7808
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger

getInt = readInt <$> BS.getLine

checkNum :: Int -> String
checkNum d
  | n `elem` [2, 4, 5, 7, 9] = "hon"
  | n `elem` [0, 1, 6, 8] = "pon"
  | otherwise = "bon"
  where
    n = d `mod` 10

main = do
  n <- getInt
  putStrLn $ checkNum n


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

int main() {
    string S;
    cin >> S;
    if(S == "SUN") cout<<7<<endl;
    else if(S == "MON") cout<<6<<endl;
    else if(S == "TUE") cout<<5<<endl;
    else if(S == "WED") cout<<4<<endl;
    else if(S == "THU") cout<<3<<endl;
    else if(S == "FRI") cout<<2<<endl;
    else cout<<1<<endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int m;
    cin >> m;
    vi b(m);
    rep(i, m) cin >> b[i];
    vi c;
    int j = 0;
    rep(i, n) {
        while(j != m-1 and a[i] > b[j]) j++;
        if(a[i] == b[j]) c.emplace_back(a[i]);
    }
    j = 0;
    rep(i, n) {
        if(j == c.size() or a[i] != c[j]) cout << a[i] << '\n';
        else j++;
    }
}


Measured memory_bytes: 4732
def examA():
    N, R = LI()
    ans = R+100*max(0,(10-N))
    print(ans)
    return

def examB():
    N, K = LI()
    ans = 1
    while(N>=K):
        N //=K
        ans += 1
    print(ans)
    return

def examC():
    N = I()
    X = LI()
    ans = inf
    for i in range(101):
        cur = 0
        for x in X:
            cur += (i-x)**2
        ans = min(ans,cur)
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
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 LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Measured memory_bytes: 40688
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int x = sc.nextInt();
	int result = 0;;
	boolean is = true;
	if (x == 2 || x == 3) {
	    is = false;
	    result = x;
	    System.out.print(result);
	}
	while (is) {
	    if (x % 2 != 0) {
		for (int i=3; i<x; i++) {
		    if (x % i == 0) {
			break;
		    }
		    if (i == x-1) {
			is = false;
			result = x;
			System.out.print(result);
			is = false;
		    }
		}
	    }
	    x++;
	}
    }
}


Measured memory_bytes: 35756
import java.util.Scanner;

public class Main {

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

	    double l=gd();

        System.out.println(Math.pow(l/3, 3));
//        if (a<b) {
//        	System.out.print(Math.max(b-a-w, 0));
//        }else {
//        	System.out.print(Math.max(a-b-w, 0));
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35660