akhauriyash/Code-Regression huggingface dataset:
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//INT_MAXなど
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/

signed main(){
  std::string S;
  cin >> S;

  std::string sub_str = "";
  int res = 0;
  for (auto c : S) {
    if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
      sub_str += c;
      res = max(res, (int) sub_str.size());
    } else {
      sub_str = "";
    }
  }
  cout << res << endl;

  return 0;
}

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

signed main() {
  int w, a, b; cin >> w >> a >> b;
  int ans;
  if(a+w < b) ans = b-(a+w);
  else if(b+w < a) ans = a-(b+w);
  else ans = 0;

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


Measured memory_bytes: 256
N, K = map(int, input().split())
cnt = 0

for i in range(1, N+1):
	if i >= K:
		cnt += 1
	else:
		for x in range(1, 100000):
			i = i * 2
			if i >= K:
				cnt += 1 / (2 ** x)
				break

ans = cnt / N
print(ans)

Measured memory_bytes: 2940
#include <stdio.h>

#define Max 500000
#define INFTY 1000000000

int L [Max/2 + 2], R[Max/2 + 2];

void  swap(int *x, int *y)
{
    int  buff;
	
	buff = *x;
	*x = *y;  
	*y = buff;
}

void printA(int A[Max], int N) {
	int i;

	for (i = 0; i < N - 1; i++)
		printf("%d ", A[i]);
	printf("%d\n", A[N - 1]);
}

int merge(int A[Max], int left, int mid, int right) {
	int i, j, k;
	int count = 0;

	int n1 = mid - left;
	int n2 = right - mid;

	// L[0...n1], R[0...n2] ?????????
	for (i = 0; i < n1; i++) L[i] = A[left + i];
	for (i = 0; i < n2; i++) R[i] = A[mid + i];

	L[n1] = INFTY;
	R[n2] = INFTY;
	i = 0;
	j = 0;

	for (k = left; k < right; k++) {
		count++;
		if (L[i] <= R[j])  A[k] = L[i++];
		else  A[k] = R[j++];
	}

	return count;
}

int mergeSort(int A[Max], int left, int right) {
	int count = 0;
	int mid;

	if (left + 1 < right) {
		mid = (left + right)/2;
		count += mergeSort(A, left, mid);
		count += mergeSort(A, mid, right);
		count += merge(A, left, mid, right);
	}

	return count;
}

int main( ) {
	int N, i, count;
	int A[Max];

	scanf("%d", &N);

	for (i = 0; i < N; i++) scanf("%d", &A[i]);

	count = mergeSort(A, 0, N);

	printA(A, N);

	printf("%d\n", count);

	return 0;
}

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

namespace CSharpSample01
{
   
    class Program
    {
        
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            var up = new int[N + 1];
            var down = new int[N + 1];

            string[] str1 = Console.ReadLine().Split(' ');
            for(int i = 1; i <= N; i++)
            {
                up[i] = int.Parse(str1[i - 1]);
            }

            string[] str2 = Console.ReadLine().Split(' ');
            down[0] = 0;
            int downall = 0;
            for(int i = 1; i <= N; i++)
            {
                int s = int.Parse(str2[i - 1]);
                down[i] = s;
                downall += s;
            }

            int max = -1;
            int upcost = 0;
            int downcost = downall;
            for(int i = 1; i <= N; i++)
            {
                upcost += up[i];
                downcost -= down[i - 1];
                int s = upcost + downcost;
                if (max < s) max = s;
            }

            Console.WriteLine(max);

        }
    }
}

Measured memory_bytes: 13140
<?php
  function waribiki($num){
    global $item, $n;
  
    if($num==0){
      return;
    }
  
    //echo implode(",", $item)."\n";
  
    $half = intval($item[0] / 2);
    for($i=0; $i<$n; $i++){
      if($item[$i]<$half){
        break;
      }
      $item[$i] = intval($item[$i]/2);
      $num--;
      if($num==0){
        break;
      }
    }
  
    if($num>0){
      rsort($item);
      waribiki($num);
    }
  }
  
  $tmp = explode(" ", trim(fgets(STDIN)));

  $n = $tmp[0];
  $m = $tmp[1];

  $item = explode(" ", trim(fgets(STDIN)));
//echo implode(",", $item)."\n";
  rsort($item);
//echo implode(",", $item)."\n";

  waribiki($m);
  
  $total = 0;
  for($i=0; $i<$n; $i++){
    $total += $item[$i];
  }

  echo $total."\n";
  
  
  ?>

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

using namespace std;
using ll=long long;


void solve() {
    int n, T;
    cin >> n >> T;
    vector<pair<int, int>> a;
    vector<int> bs;
    for (int i = 0; i < n; i++) {
        int x,y;
        cin >> x >> y;
        if (x) a.emplace_back(x,y);
        else bs.emplace_back(y);
    }
#define fi first
#define se second
    sort(a.begin(), a.end(), [&](auto& u, auto& v){
        return (u.se+1)*1ll*v.fi < (v.se+1)*1ll*u.fi;
    });
    sort(bs.begin(), bs.end());
    n = a.size();

    const int L = 31; 
    vector<ll> dp(L, 1ll<<31);
    dp[0] = 1;
    for (int _ = 0; _ < n; _++) {
        int x,y;
        tie(x,y) = a[_];
        x++;y++;
        for (int i = L-1; i >= 0; i--) {
            dp[i+1] = min(dp[i+1], x * dp[i] + y);
        }
    }
    T++;
    int res = 0;
    for (int i = 0; i < L; i++) {
        int cnt = i;
        ll t = dp[i];
        if (t > T) continue;
        for (int y: bs) {
            y++;
            if (t + y <= T) {
                t += y;
                cnt++;
            } else break;
        }
        res = max(res, cnt);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

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

  int b[n-1];
  rep (i, n-1) cin >> b[i];

  int ans = b[0] + b[n-2];
  for (int i = 1; i <= n-2; i++) {
    ans += min(b[i], b[i-1]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
    int N;

    cin >> N;

    int i = 1;

    if(N%4 == 0){
        cout << "Yes" << endl;
        return 0;
    }

    if(N%7 == 0){
        cout << "Yes" << endl;
        return 0;
    }

    while(N > 3){
        N -= 4;
        if(N%7 == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

int main(){
  int N; cin>>N;
  ll A[N]; rep(i,N) cin>>A[i];
  ll a=A[0];
  for(int i=1;i<N;i++){
    if(i%2) a-=A[i];
    else a+=A[i];
  }
  ll ans[N]; 
  ans[0]=a/2;
  for(int i=1;i<N;i++){
    ans[i]=A[i-1]-ans[i-1];
  }
  rep(i,N) cout<<2*ans[i]<<" ";
  cout<<endl;
  return 0;
}


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

int main() {
    int h,w; cin >> h >> w;
    string s = "";
    for(int i = 0; i < w+2; i ++) s += '#';
    cout << s << endl;
    for(int i = 0; i < h; i ++) {
        string a; cin >> a;
        cout << '#' << a << '#' << endl;
    }
    cout << s << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    vi a(n);rep(i,n)cin>>a[i];
    sort(all(a));
    int cnt=0;
    for(int i=0;i<n-1;++i){
        for(int j=i+1;j<n;++j){
            cnt+=lower_bound(all(a),a[i]+a[j])-a.begin()-j-1;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N;
    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
    }
    static void solve()
    {
        input();
        Dictionary<int, int> dic = new Dictionary<int, int>();
        for(int i = 0; i < N; i++)
        {
            int v = cin.nextInt();
            if (dic.ContainsKey(v))
                dic[v]++;
            else
                dic.Add(v, 1);
        }
        int ans = 0;
        foreach(var x in dic)
        {
            if (x.Key > x.Value)
                ans += x.Value;
            else
                ans += x.Value - x.Key;
        }
        WriteLine(ans);
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 25696
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;

lli q, k;

const int h = 200005;
lli a[h], b[h], c[h], x[h], y[h];
vector<pair<lli, lli>> e[h];

int main()
{

    int n;
    cin >> n;
    rep(i, n - 1)
    {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--, b[i]--;
        e[a[i]].push_back(make_pair(b[i], c[i]));
        e[b[i]].push_back(make_pair(a[i], c[i]));
    }
    cin >> q >> k;
    rep(i, q)
    {
        cin >> x[i] >> y[i];
        x[i]--, y[i]--;
    }

    lli dist[h] = {};
    queue<pair<lli, lli>> que;
    k--;
    que.push(make_pair(k, 0));
    while (!que.empty()) {
        auto l = que.front().first;
        auto d = que.front().second;
        //cout << l << " " << d << endl;
        dist[l] = d;
        que.pop();
        for (auto s : e[l]) {
            if (dist[s.first] == 0 and s.first != k) {
                que.push(make_pair(s.first, d + s.second));
            }
        }
    }
    rep(i, q)
    {
        cout << dist[x[i]] + dist[y[i]] << endl;
    }
}


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

using namespace std;



int main()
{
    //freopen("in.txt","r",stdin);
    int n,i,j,ar[3][3],an,k,af[3][3];
    int ans=0;
    for(i=0;i< 3;i++)
    {
        for(j=0;j< 3;j++)
        {
            cin>>ar[i][j];
            af[i][j]=0;
        }
    }
    cin>>n;

    for(j=0;j<n;j++)
    {
        cin>>an;
        for(i=0;i< 3;i++)
        {
            for(k=0;k< 3;k++)
            {
                if(ar[i][k]==an)
                {
                    af[i][k]=1;
                }
            }
        }
    }

    for(i=0;i<3;i++)
    {
        if(af[i][0]==1 && af[i][1]==1 && af[i][2]==1)
            ans=1;
        if(af[0][i]==1 && af[1][i]==1 && af[2][i]==1)
            ans=1;
    }
    if(af[0][0]==1 && af[1][1]==1 && af[2][2]==1)
            ans=1;
    if(af[0][2]==1 && af[1][1]==1 && af[2][0]==1)
            ans=1;

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






    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>



#ifndef DEBUG 
#define fprintf (void)
#endif 

double absval(double x);

int main(void){

	int n,i,j,p;
	
	scanf("%d",&n);
	
	double vect[2][n];
	double d[n];
	double sum;
	double max=0;
	
	for(i=0;i<2;i++){
		for(j=0;j<n;j++){
			scanf("%lf",&vect[i][j]);
		}
	}

	for(j=0;j<n;j++){
		d[j]=fabs(vect[0][j]-vect[1][j]);
	}
	
	for(p=1;p<4;p++){
		sum=0;
		for(j=0;j<n;j++){
			sum+=pow(d[j],p);
		}
		printf("%lf\n",pow(sum,1.0/p));
	}
	
	for(j=0;j<n;j++){
		if(d[j]>max){
			max=d[j];
			fprintf(stdout,"%lf",max);
		}
	}
	
	printf("%lf\n",max);
	
	return 0;
}

Measured memory_bytes: 2896
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

const int N=45;

int n;
char a[N][N];
ll f[N][N][N];

ll solve(int l,int r,int mid) {
	if (~f[l][r][mid]) return f[l][r][mid];
	if (l==r) return 1;
	if (mid==l||mid==r) return 0;
	ll ret=0;
	fo(j,l,mid-1)
		fo(k,mid+1,r) {
			if (a[j][k]=='0') continue;
			fo(p,j,mid-1)
				fo(q,mid+1,k) 
					ret+=solve(l,p,j)*solve(q,r,k)*solve(p+1,q-1,mid);
		}
	return f[l][r][mid]=ret;
} 

int main() {
	memset(f,-1,sizeof(f));
	scanf("%d",&n);n<<=1;
	fo(i,1,n) scanf("%s",a[i]+1);
	ll ans=0;
	fo(i,2,n) if (a[1][i]=='1') ans+=solve(2,n,i);
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    int X,N;
    cin >> X >> N;
    set<int> S;
    for(int i=0; i<N; i++){
        int p;
        cin >> p;
        S.insert(p);
    }
    int i=0;
    while(1){
        if (! S.count(X-i)){
            cout << X-i << endl;
            return 0;
        }
        if (! S.count(X+i)){
            cout << X+i << endl;
            return 0;
        }
        i++;
    }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,ans=0;
  int a[10005];
  cin>>N;
  for(int i=0;i<10001;i++){
    a[i]=0;
  }
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  for(int i=0;i<N-1;i++){
    if(a[i]==a[i+1] && a[i+1]+1==a[i+2]){
      a[i+1]=a[i+1]-1;
      ans++;
    }
    else if(a[i]==a[i+1]){
      a[i+1]=a[i+1]+1;
      ans++;
    }
    
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,a[100005];
int now,ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=2;i<=n;i++){
		if(a[i]<=a[i-1])now++;
		else {ans=max(ans,now);now=0;}
	}
	ans=max(ans,now);
	cout<<ans<<endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 1e18+1
const ll mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    string s,t;
    cin>>s>>t;
    if(SZ(t)-SZ(s)==1)
    {
        fr(i,0,SZ(s))
        {
            if(t[i]!=s[i])
            {
                cout<<"No\n";
                return;
            }
        }
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
    	solve();
    }
	return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

#define NUM_MAX (1000000)

int
main(void)
{
	bool a[NUM_MAX];

	for (int i = 0; i < NUM_MAX; i++) {
		a[i] = true;
	}
	for (int i = 2; i*i < NUM_MAX; i++) {
		if (a[i]) {
			for (int j= i*i; j < NUM_MAX; j += i) {
				a[j] = false;
			}
		}
	}
	
	char line[80];
	int n;

	while (fgets(line, sizeof line, stdin)) {
		if (sscanf(line, "%d", &n) == 1) {
			int s = 0;
			for (int i = 2; i <= n; i++) {
				if (a[i]) {
					s ++;
				}
			}

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

	return 0;
}

Measured memory_bytes: 2012
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll mod = 10e9+7;

#define vecint vector<int>
#define vecll vector<ll>

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl

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

int main(void) {
  ll n, m;
  cin >> n >> m;

  vecll l(m), r(m);
  rep(i,m){
    cin >> l[i] >> r[i];
  }

  sort(all(l));
  sort(all(r));

  if(r[0]-l[m-1]<0){
    prt(0);
  } else {
    prt(r[0]-l[m-1]+1);
  }
}


Measured memory_bytes: 1792
from itertools import product

N, A, B, C = map(int, input().split())
bl = [int(input()) for _ in range(N)]

def get_mp(q):
    assert len(q) == N
    res = 0
    assign = [[] for _ in range(4)]
    
    for i, j in enumerate(q):
        assign[j].append(bl[i])

    if any([l == [] for l in assign[:3]]):
        return 10**18
    
    for l, p in zip(assign, [A, B, C]):
        ext_sht = abs(sum(l) - p)
        syn = (len(l) - 1) * 10
        res += ext_sht + syn
    
    return res

res = []
for q in product(*([[0,1,2,3]]*N)):
    res.append(get_mp(q))
print(min(res))

Measured memory_bytes: 5156
let n, k = Scanf.scanf " %d %d" @@ fun a b -> a, b
let ans, xs, ys = Array.(ref max_int, make n 0, make n 0)
let xys = Array.init n @@ fun i -> Scanf.scanf " %d %d" @@ fun x y -> xs.(i) <- x; ys.(i) <- y; x, y
let _ = Array.(sort (-) xs; sort (-) ys);
  for i = 0 to n - 1 do let xi = xs.(i) in for j = i + 1 to n - 1 do let xj = xs.(j) in for l = 0 to n - 1 do let yi = ys.(l) in for m = l + 1 to n - 1 do let yj = ys.(m) in let c = ref 0 in if Array.iter (fun (x, y) -> if xi <= x && x <= xj && yi <= y && y <= yj then incr c) xys; !c >= k then ans := min !ans @@ (xj - xi) * (yj - yi) done done done done; Printf.printf "%d\n" !ans

Measured memory_bytes: 2560
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<random>
#include<unordered_set>
using namespace std;
typedef long long int llint;
#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
const llint mod=1000000007;
const llint big=1e17-10;
const long double pai=3.141592653589793238462643383279;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
vector<vector<int>> ko;
vector<int> oya;
void make_tree(int per,int ter){
	if(ter!=0){
	ko[ter].erase(find(ko[ter].begin(),ko[ter].end(),per));}
	for(auto it=ko[ter].begin();it!=ko[ter].end();it++){
		make_tree(ter,*it);
	}
}
//make_tree(-1,root);で木を作れる
int solve(int ter){
	int ans=0;
	for(int i=0;i<ko[ter].size();i++){
		ans^=(solve(ko[ter][i])+1);
	}
	return ans;
}
int main(void){
	int i,j,n;cin>>n;
	ko.res(n);
	oya.res(n);
	for(i=0;i<n-1;i++){
		int a,b;cin>>a>>b;a--;b--;
		ko[a].pub(b);
		ko[b].pub(a);
	}
	make_tree(-1,0);
	if(0==solve(0)){cout<<"Bob"<<endl;}
	else{cout<<"Alice"<<endl;}
	return 0;
}

Measured memory_bytes: 10752
n,q = (int(num) for num in input().split())
s = input()
list_ac = [0]*n
list_sum = [0]*n
for i in range(n-1):
    if s[i:i+2] == 'AC':
        list_ac[i] = 1
for i in range(1,n):
    list_sum[i] = list_sum[i-1] + list_ac[i-1]
    
for j in range(q):
    l,r = (int(num)-1 for num in input().split())
    print(list_sum[r]-list_sum[l])

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
#define guard(x) if( not ( x ) ) continue;
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename T>
struct Maybe {
   T x;
   bool valid;
   Maybe() : valid(false) {}
   Maybe(T x_) : x(x_), valid(true) {}
   operator T() const {
      assert( valid );
      return x;
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int n, a, b; scan(n, a, b);
      Int res = std::min(n * a, b);
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 256
from collections import defaultdict

base = ord('a')

d = defaultdict(int)

ans = 0

n = int(input())
for _ in range(n):
    s = input()
    lst = [0] * 26
    for c in s:
        idx = ord(c) - base
        lst[idx] += 1
    key = tuple(lst)
    ans += d[key]
    d[key] += 1

print(ans)


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

int main()
{
    stack<int> S1;
    stack<pair<int,int> > S2;
    string s;
    int i,sum=0;
    cin>>s;
    int len=s.length();
    for(i=0;i<len;i++){
        if(s[i]=='\\')S1.push(i);
        else if(s[i]=='/' && S1.size()>0){
            int j=S1.top();
            S1.pop();
            sum+=i-j;
            int a=i-j;
            while(S2.size()>0&&S2.top().first>j){
                a+=S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j,a));
        }
    }

    cout<<sum<<endl;
    vector<int> ans;
    while(S2.size()>0){
        ans.push_back(S2.top().second);
        S2.pop();
    }
    cout<<ans.size();
    reverse(ans.begin(),ans.end());
    for(i=0;i<ans.size();i++){
        cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3264
//============================================================================
// Name        : JOI.cpp
// Author      :2015 ho3
// Version     :???11:08
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<algorithm>
#include <queue>
using namespace std;

int N,Q;
long long X[200001]={};
int D[200001]={};
int L[200001]={};
const int INF=1000000001;
long long BX[300002];
long long BY[300002];
int N_MAX=18;

long long outBY(int n1){
	long long ans=0;
	int ps=0;
	for(int i=(1<<N_MAX);i>0;i=(i>>1)){
		if(n1>=i){
			ans+=BY[i+ps];
			n1-=i;
			ps+=i;
			if(n1==0)break;
		}
	}
	return ans;
}
long long outBX(int n1){
	long long ans=0;
	int ps=0;
	for(int i=(1<<N_MAX);i>0;i=(i>>1)){
		if(n1>=i){
			ans+=BX[i+ps];
			n1-=i;
			ps+=i;
			if(n1==0)break;
		}
	}
	return ans;

}
int inBX(int n1,int p){
	int ps=0;
	for(int i=(1<<N_MAX);i>0;i=(i>>1)){
		if(n1<=i)BX[i+ps]+=(long long)p;
		if(n1>=i){
			n1-=i;
			ps+=i;
			if(n1==0)break;
		}
	}
	return 0;
}
int inBY(int n1,int p){
	int flg=0;
	for(int i=1;i<1<<(N_MAX+1);i=i<<1){
		if((n1&i)==i){
			if(flg==0){
				flg=1;
				BY[n1]+=(long long)p;
			}
			n1-=i;
		}else if(flg==1){
			BY[n1+i]+=(long long)p;
		}
	}
	return 0;
}

int initBX(){
	for(int i=1;i<N+1;++i)inBX(i,1);
	return 0;
}
int searchD1(long long x1){
//	if(BX[1]+BY[1]>x1)return 0;
	if(BX[1<<N_MAX]+BY[1<<N_MAX]<x1)return N+1;
	int bs=0;
	for(int i=1<<(N_MAX-1);i>0;i=i>>1){
		if(BX[bs+i]+BY[bs+i]<=x1){
			x1-=(BX[bs+i]+BY[bs+i]);
			bs+=i;
		}
	}
	return bs;
}
int searchD2(long long x1){
//	if(BX[1]-BY[1]>x1)return 0;
	if(BX[1<<N_MAX]-BY[1<<N_MAX]<x1)return N+1;
	int bs=0;
	for(int i=(1<<(N_MAX-1));i>0;i=(i>>1)){
		if(BX[bs+i]-BY[bs+i]<=x1){
			x1-=(BX[bs+i]-BY[bs+i]);
			bs+=i;
		}
	}
	return bs;
}



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

	for(int i=0;i<Q;++i)cin>>X[i]>>D[i]>>L[i];

	initBX();

	int pos=0;
	for(int i=Q-1;i>-1;--i){
		if(D[i]==1){
			pos=searchD1(X[i]);
			if(pos>0){
				inBX(1,-L[i]);
				inBY(1,L[i]);
				if(pos<N){
					inBX(pos+1,L[i]);
					inBY(pos+1,-L[i]);
				}
			}
		}else{
			pos=searchD2(X[i]);
			if(pos<N){
				inBX(pos+1,L[i]);
				inBY(pos+1,L[i]);
			}
		}
	}
	for(int i=1;i<N+1;++i){
		cout<<outBY(i)<<endl;
	}



	return 0;
}

Measured memory_bytes: 9388
#3問目
import math
N = int(input())
a = list(map(int, input().split()))
averageCeil = math.ceil(sum(a) / N)
averageFloor = math.floor(sum(a) / N)
costCeil = 0
costFloor = 0
#コスト計算
for i in range(N):
    costCeil += (a[i] - averageCeil) ** 2
    costFloor += (a[i] - averageFloor) ** 2
print(min(costCeil,costFloor))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb              push_back
#define ll              long long int
#define scd(a)          scanf("%d",&a)
#define mp(a,b)         make_pair(a,b)
#define scl(w)          scanf("%I64d",&w)
#define scdd(a,b)       scanf("%d %d",&a,&b)
#define srt(a)          sort(a.begin(),a.end())
#define rsrt(a)         sort(a.rbegin(),a.rend())
#define scll(a,b)       scanf("%I64d %I64d",&a,&b)
///4direction ->        int del_x[]={-1,0,1,0},del_y[]={0,1,0,-1};
#define input(v,n)      for (int i=0;i<n;i++){int a;cin >> a;v.push_back(a);}
#define inputll(v,n)    for (ll i=0;i<n;i++){ll a;cin >> a;v.push_back(a);}
#define vii             vector < int >
#define vll             vector < ll >
#define pii             pair < int , int >
#define pll             pair < ll , ll >
#define show(x)         cout << #x << " : " << x << endl
#define mk              make_pair
#define inf             10000000000000016

#define maxn            10000006

using namespace std;

ll A[maxn] , B[maxn] , n;

int main()
{
      //scanf("%lld",&n);
      cin >> n;
      //show(n);

      A[1] = 1;

      for (ll i=2 ; i<=n;i++)A[i] = 1;

      //show(n);

      for (ll i = 2 ; i<=n;i++){
            if (!B[i]){
                  A[i] = 2;

                  for (ll j = i+i ; j<= n ; j+=i){
                        ll temp = j , cnt = 0;
                        while(temp%i==0){
                              cnt++;
                              temp/=i;
                        }

                        A[j]*=(cnt+1);
                        B[j]=1;
                  }
            }
      }

      for (ll i=2 ; i<=n;i++){
            if (B[i]==0)A[i] = 2;
      }

      ll ans = 0;
      for (ll i=1 ; i<=n;i++){
            ans+=(i*A[i]);

            //show(ans);
      }
      cout << ans << endl;


      return 0;
}



Measured memory_bytes: 159876
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;(a)<=i;--i)
template<class T> class segtree {
	int n = 1;
	vector<T> dat;
	T def;
	function<T(T, T)> f1;
	function<void(T&, T)> f2;
public:
	segtree() {}
	segtree(const int& _n, const function<T(T, T)>& _f1, const function<void(T&, T)>& _f2, const T _def = 0)
		: f1(_f1), f2(_f2), def(_def) {
		while (n < _n)n <<= 1;
		dat.resize(n << 1, def);
	}
	segtree(const vector<T>& _dat, const function<T(T, T)>& _f1, const function<void(T&, T)>& _f2, const T _def = 0)
		: f1(_f1), f2(_f2), def(_def) {
		int _n = _dat.size();
		while (n < _n)n <<= 1;
		dat.resize(n << 1, def);
		FOR(i, 0, _n)dat[i + n] = _dat[i];
		rFOR(i, 1, n)dat[i] = f1(dat[i << 1], dat[i << 1 | 1]);
	}
	void update(int i, T a) {
		i += n;
		f2(dat[i], a);
		while (1 < i) {
			i >>= 1;
			dat[i] = f1(dat[i << 1], dat[i << 1 | 1]);
		}
	}
	T value(int l, int r) {
		T ret = def;
		for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if (l & 1)ret = f1(ret, dat[l++]);
			if (r & 1)ret = f1(ret, dat[--r]);
		}
		return ret;
	}
	T operator[](int i) { return dat[i + n]; }
};

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int q; cin >> q;

	vector<int> a(n);
	FOR(i, 0, n)a[i] = 1 << (s[i] - 'a');
	segtree<int> seg(a,
		[](int a, int b) {return a | b; },
		[](int& a, int b) {a = b; });

	while (q--) {
		int t; cin >> t;
		if (t == 1) {
			int i; char c; cin >> i >> c;
			seg.update(i - 1, 1 << (c - 'a'));
		}
		else {
			int l, r; cin >> l >> r;
			int b = seg.value(l - 1, r);
			int ans = 0;
			FOR(i, 0, 26)if (b & (1 << i))++ans;
			cout << ans << "\n";
		}
	}
}

Measured memory_bytes: 6916
N = int(input())
A = [0]*N
for i in range(N):
  A[i] = int(input())
#print(A)
M = max(A)
ind = A.index(M)
#print(ind)
A.pop(ind)
m = max(A)
for i in range(N):
  #print(i)
  if i != ind:
    print(M)
  else:
    print(m)
    

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

#define pb      push_back
#define all(v)  v.begin(),v.end()
#define endl    "\n"
#define FAST    ios_base::sync_with_stdio(0);cin.tie(0);

typedef long long     ll;
typedef long double   ld;
typedef pair<int,int> ii;

const int    inf = 2e9;
const ll     INF = 4e17;
const int    mod = 1e9+7;
const double eps = 1e-9;

int main() {
	ll N, Y;
	scanf("%lld %lld", &N, &Y);
	for(ll x = 0; x <= 2000; x++) {
		for(ll y = 0; y <= 4000; y++) {
			ll z = (Y - 10000*x - 5000*y) / 1000;
			if(10000*x + 5000*y + 1000*z == Y && x+y+z == N && z >= 0) {
				printf("%lld %lld %lld\n", x, y, z);
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}



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

float p = 0;
int w, s;
int a, b, c, d, e, f;

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

	int na = f / 100 / a + 1;
	int nb = f / 100 / b + 1;
	int nc = f / c + 1;
	int nd = f / d + 1;
	for( int i = 0; i < na; i++ ) {
		for( int j = 0; j < nb; j++ ) {
			for( int k = 0; k < nc; k++ ) {
				for( int l = 0; l < nd; l++ ) {
					if( (k*c + l*d) > e * (i*a + j*b) ) {
						continue;
					}
					if( k*c + l*d + i*a*100 + j*b*100 > f ) {
						continue;
					}
					if( k*c + l*d + i*a*100 + j*b*100 == 0 ) {
						continue;
					}
					float pp = (k*c + l*d) * 100.0 / ( k*c + l*d + i*a*100 + j*b*100 );
					if( pp > p ) {
						p = pp;
						w = i*a*100 + j*b*100;
						s = k*c + l*d;
					}
				}
			}
		}
	}
	if( p == 0 ) {
		w = a*100;
	}
	cout << w + s << " " << s << endl;

	return 0;
}


Measured memory_bytes: 384
program main
  implicit none
  character(100000) :: s
  integer :: i, k, n, a = 0, b = 0

  read *, s
  n = len_trim(s)

  do i = 1, n
    read (s(i:i), *), k
    if (k /= mod(i, 2)) a = a + 1
    if (k /= mod(i+1, 2)) b = b + 1
  end do

  print '(i0)', min(a, b)
    
end



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

using namespace std;

namespace util {
    vector<int> read_int_vector() {
        int n;
        cin >> n;

        vector<int> v;
        for (int i = 0; i < n; i++) {
            int in;
            cin >> in;
            v.push_back(in);
        }
        return v;
    }
    void print_vector(vector<int> &v) {
        for (auto it = v.begin(); it != v.end(); it++) {
            cout << *it;
            if (it + 1 != v.end())
                cout << " ";
        }
        cout << endl;
    }
    void swap(vector<int>& v, size_t i, size_t j) {
        int tmp = v[i];
        v[i] = v[j];
        v[j] = tmp;
    }
}

namespace {
    int run_bubble_sort(vector<int>& v) {
        int count = 0;
        for (size_t i = 0; i < v.size(); i++) {
            for (size_t j = v.size() - 1; j > i; j--) {
                if (v[j] < v[j-1]) {
                    count++;
                    util::swap(v,j,j-1);
                }
            }
        }
        return count;
    }
}

int main() {
    vector<int> in = util::read_int_vector();
    int count = run_bubble_sort(in);
    util::print_vector(in);
    cout << count << endl;
    return 0;
}

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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  
  if (L > R) {
    cout << "Left" << endl;
  }
  else if (L == R) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int D;
    cin >> D;
    while(D--) cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <queue>
#include <utility>
using namespace std;

string s[55];
int h, w, a[55][55], v[55][55];

int main()
{
    cin >> h >> w;
    int b = 0;
    for (int i = 0; i < h; ++i)
        cin >> s[i];

    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            v[i][j] = -1;

    queue<pair<int, int>> q;

    q.push({0, 0});
    v[0][0] = 0;

    while (!q.empty())
    {
        auto t = q.front();
        q.pop();
        int dx[] = {-1, 0, 0, 1},
            dy[] = {0, 1, -1, 0};
        for (int k = 0; k < 4; ++k)
        {
            int xx = t.first + dx[k],
                yy = t.second + dy[k];
            if (0 <= xx && xx < w && 0 <= yy && yy < h && s[yy][xx] == '.' && v[yy][xx] == -1)
            {
                v[yy][xx] = v[t.second][t.first] + 1;
                q.push({xx, yy});
            }
        }
    }

    if (v[h - 1][w - 1] == -1)
        return cout << -1 << endl, 0;

    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
            b += (s[i][j] == '#');
    }

    cout << h * w - b - v[h - 1][w - 1] - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc172/tasks/abc172_a
#include <bits/stdc++.h>
using namespace std ;
int main() 
{
    long long n ;
    cin >> n ;
    cout << n + ( n * n ) + ( n * n * n ) << endl ;
}
/*  CODED BY:-
 ___________________________________
|                       ___         |
|  /\   /\  \ /  |  |  |___   |__|  |        
| /~~\ /~~\  |   |__|   ___|  |  |  |
|___________________________________|
 
*/

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

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

ll N;
string X;
ll g[400001];
ll f[400001];

ll calc(ll m){
    if(m == 0) return 0;
    ll ret = 0;
    for(auto &x : X){
        ret *= 2;
        ret += x - '0';
        ret %= m;
    }
    return ret;
}

int main(){
    cin >> N;
    cin >> X;
    vector<ll> ans;
    for(int i=1;i<=400000;i++){
        bitset<32> bt(i);
        g[i] = i % bt.count();
    }
    for(int i=1;i<=400000;i++){
        if(g[i] == 0){
            f[i] = 1;
            continue;
        }
        f[i] = f[g[i]] + 1;
    }
    bitset<200000> btX(X);
    ll x_count = btX.count();
    ll mod_p = x_count + 1;
    ll mod_m = x_count - 1;
    ll X_mod_p = calc(mod_p);
    ll X_mod_m = calc(mod_m);
    ll pp, mp;
    pp = mp = 1;
    for(int i=N-1;i>=0;i--){
        pp %= mod_p;
        if(mod_m != 0) mp %= mod_m;
        if(X[i] == '0'){
            ll t = pp + X_mod_p;
            t %= mod_p;
            ans.push_back(f[t] + 1);
        }else{
            if(mod_m == 0){
                ans.push_back(0);
                continue;
            }
            ll t = X_mod_m - mp;
            t += mod_m;
            t %= mod_m;
            ans.push_back(f[t] + 1);
        }
        pp *= 2;
        mp *= 2;
    }
    for(int i=N-1;i>=0;i--) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 11692
#include<iostream>
#include<string>
#include<set>

using namespace std;

int main(){

	int m;
	string train;
	string depa[8];
	set<string> pattern;

	cin>>m;

	for(int i=0;i<m;i++){
		cin>>train;
		if(!pattern.empty()) pattern.clear();
		pattern.insert(train);
		for(int j=0;j<train.size();j++){
			for(int k=0;k<8;k++) depa[k]=("");
			for(int k=0;k<j+1;k++){
				depa[0]+=train[k];
				depa[1]+=train[k];
				depa[2]+=train[j-k];
				depa[3]+=train[j-k];
			}
			for(int k=j+1;k<train.size();k++){
				depa[0]+=train[k];
				depa[1]+=train[train.size()-k+j];
				depa[2]+=train[k];
				depa[3]+=train[train.size()-k+j];
			}
			for(int k=j+1;k<train.size();k++){
				depa[4]+=train[k];
				depa[5]+=train[train.size()-k+j];
				depa[6]+=train[k];
				depa[7]+=train[train.size()-k+j];
			}
			for(int k=0;k<j+1;k++){
				depa[4]+=train[k];
				depa[5]+=train[k];
				depa[6]+=train[j-k];
				depa[7]+=train[j-k];
			}
			for(int k=0;k<8;k++){
				if(pattern.find(depa[k])==pattern.end()) pattern.insert(depa[k]);
			}
		}
		cout<<pattern.size()<<endl;
	}

}

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

int main(){
    int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
    int difx=x2-x1;
    int dify=y2-y1;
    
    cout << x2-dify << " " << y2+difx << " " << x1-dify << " " << y1+difx; 
}

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

int main() {
    pair<pair<string, int>, int> p[100];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int q;
        cin >> p[i].first.first >> q;
        p[i].first.second = -q;
        p[i].second = i+1;
    }

    sort(p, p+n);

    for (int i = 0; i < n; i++) {
        cout << p[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
t=input()

ans=0
for i in range(n):
	if s[i]==t[0]:
		j=0
		while j<n-i:
			if s[i+j]!=t[j]:
				break
			j+=1
		else:
			ans=n-i
			break
print(2*n-ans)
			

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

typedef long long ll;

const int M = 1e9+7;
ll h, w, a, b, ans;
ll fact[220000];

ll mpw(ll a, ll n) {
  if (n == 0) return 1;
  if (n % 2) return mpw(a, n-1) * a % M;
  return mpw(a * a % M, n/2);
}

ll cmb(ll n, ll r) {
  return fact[n] * mpw(fact[r], M-2) % M * mpw(fact[n-r], M-2) % M;
}

int main() {
  cin >> h >> w >> a >> b;
  
  fact[0] = 1;
  for (int i = 1; i < 220000; i++) {
    fact[i] = fact[i-1] * i % M;
  }
  
  ans = cmb(h+w-2, h-1);
  
  for (int k = 0; k <= b-1; k++) {
    ans += M - (cmb(h-a-1+k, k) * cmb(a-1+w-k-1, w-k-1)) % M;
    ans %= M;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2048
def frame(h,w):
    m,b,p = "#","\n","."
    return m*w+b + (m+p*(w-2)+m+b)*(h-2) + m*w+b

while 1:
    h,w=map(int,raw_input().split())
    if h==w==0:break
    print frame(h,w)

Measured memory_bytes: 4232
#include <iostream>
#include <string>
#include <array>
#include <algorithm>

using namespace std;

int main() {
    int n;
    float v[51];

    cin >> n;
    for(int i = 0; i < n; i ++){
        cin >> v[i];
    }
    sort(v,v+n);

    for(int i = 1; i < n; i ++){
        v[0] = (v[0] + v[1])/2;
        v[1] = 10000;
        sort(v,v+n);
    }
    cout << v[0];

    return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;

int main() {
  int N; cin >> N;
  set<int> s;
  int a; cin >> a;
  s.insert(a);    
  for ( int i = 1; i < N; i++ ) {
    cin >> a;
    set<int>::iterator ite;
    ite = s.find(a);
    if ( ite == s.end()) s.insert(a);
    else s.erase(a);
  }

  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 4864
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		HashSet<Integer>  paper= new HashSet<Integer>();
		for(int i = 0; i < N; i++) {
			int a = Integer.parseInt(sc.next());
			if(paper.contains(a)) {
				paper.remove((Integer)a);
			}else {
				paper.add(a);
			}
		}
		System.out.println(paper.size());

		sc.close();
	}

}


Measured memory_bytes: 46812
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

string s;
ll a[100005];

int main()
{
    cin>>s;
    for(ll i = 0; i < s.size(); i++)
    {
        a[i + 1] = s[i] - '0';
    }
    if(a[1] == 0 || a[s.size()] == 1)
    {
        printf("-1\n");
        return 0;
    }
    for(ll i = 1; i <= s.size(); i++)
    {
        if(a[i] != a[s.size() - i])
        {
            printf("-1\n");
            return 0;
        }
    }
    a[s.size()] = 1;
    ll now = 1;
    for(ll i = 2; i <= s.size(); i++)
    {
        if(a[i])
        {
            for(ll j = now; j < i; j++)
            {
                printf("%lld %lld\n", j, i);
            }
            now = i;
        }
    }
    return 0;
}


Measured memory_bytes: 2432
N=int(input())
Edges = list(map(int,input().split()))

Edges=sorted(Edges)
cnt =0
# for i in c:
#     e1=(i[1] + i[2])
#     e2=(i[0] + i[2])
#     e3=(i[0] + i[1])

#     if i[0] < e1 and i[1] < e2 and i[2] < e3:
#         cnt+=1


import bisect

for a in range(N-2):
    for b in range(a+1,N-1):
        ab = Edges[a] + Edges[b]

        idx = bisect.bisect_left(Edges,ab)

        cnt += max(0,idx-b-1)


print(cnt)

Measured memory_bytes: 3316
#MLE注意！0や1のケースに注意

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    h = list(map(int, input().split()))
    adj = [[] for _ in range(n)] #頂点数, 場合によって変える
    for _ in range(m):
        a,b = map(int, input().split())
        adj[a-1].append(b-1)
        adj[b-1].append(a-1)
    #-1まだ　0負け確　1良い
    check = [-1]*n
    for i in range(n):
        if check[i] == 0:
            continue
        if len(adj[i]) == 0:
            check[i] = 1
        else:
            for j in adj[i]:
                if h[i] < h[j]:
                    check[i] = 0
                    break
                elif h[i] == h[j]:
                    check[i] = 0
                    check[j] = 0
                    break
                else:
                    check[j] = 0
            if check[i] == -1:
                check[i] = 1
    res = 0
    for i in check:
        if i == 1:
            res += 1
    print(res)


if __name__ == '__main__':
    main()


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

N,Q = map(int,input().split())
path = [[] for i in range(N)]
ans = [0] * N
def dfs(v,p=-1):
    for to in path[v]:
        if to == p :
            continue
        ans[to] += ans[v]
        dfs(to,v)

for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    path[a].append(b)
    path[b].append(a)
for i in range(Q):
    P,X = map(int,input().split())
    ans[P-1] += X
dfs(0)
print(*ans)

Measured memory_bytes: 282924
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto hw = readln.split.to!(int[]);
    auto H = hw[0];
    auto W = hw[1];
    hw = readln.split.to!(int[]);
    auto h = hw[0];
    auto w = hw[1];

    writeln(H*W - h*W - w*H + h*w);
}

Measured memory_bytes: 256