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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll k,s;

int main(){
    cin >> k >> s;
    ll ans = 0;
    rep(i,k+1){
        rep(j,k+1){
            ll z = s - i - j;
            if(z >= 0 && z <= k)ans++;
        }
    } 
    cout << ans << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef map<int, int> mii;

#define fastIO \
ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 

int main(){
	int n;
	cin >> n;
	vi l(n);
	for(int i=0;i<n;i++)	cin >> l[i];
	ll ans = 0;
	sort(l.begin(),l.end());
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			auto it = lower_bound(l.begin()+j,l.end(),l[i]+l[j]);
			int k = it - l.begin();
			if(k==n)	--k;
			if(k<n && l[k]>=l[i]+l[j])	--k;
			//cout << i << " " << j << " " << k << endl;
			ans += (k-j);
		}
	}
	cout << ans << endl;
	return 0;
}

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

/*
 * @title StronglyConnectedComponents
 */
class StronglyConnectedComponents{
public:
	int num,is_2sat,half,max_id,cnt;
	vector<vector<int>> edge;
	vector<int> label,order,low;
    stack<size_t> st;
	inline int rev(int i) { return i < half ? i + half : i - half; }
    inline void dfs(const int& from) {
        low[from]=order[from]=cnt++;
        st.push(from);
        for(int& to:edge[from]) {
            if(order[to]==-1) {
                dfs(to);
                low[from]=min(low[from],low[to]);
            }
            else {
                low[from]=min(low[from],order[to]);
            }
        }
        if (low[from] == order[from]) {
            while(st.size()) {
                int u = st.top();st.pop();
                order[u] = num;
                label[u] = max_id;
                if (u == from) break;
            }
            max_id++;
        }
    }
	StronglyConnectedComponents(const int n, bool is_2sat=0):num(n),max_id(0),cnt(0),is_2sat(is_2sat){
		if(is_2sat) num<<=1;
		edge.resize(num);
		label.resize(num);
        order.resize(num,-1);
        low.resize(num);
		half=num/2;
	}
	inline int operator[](int idx) {
		return label[idx];
	}
	inline void make_edge(const int from,const int to) {
		edge[from].push_back(to);
	}
    //xがflg_xならばyがflg_y
	inline void make_condition(int x, bool flg_x, int y, bool flg_y) {
		if (!flg_x) x = rev(x);
		if (!flg_y) y = rev(y);
		make_edge(x, y);
		make_edge(rev(y), rev(x));
	}
    //is_2sat=1のときに、2satを満たすかを返却する
	inline bool solve(void) {
        for (int i = 0; i < num; i++) if (order[i] == -1) dfs(i);
        for (int& id:label) id = max_id-1-id;
		if(!is_2sat) return true;
		for (int i = 0; i < num; ++i) if (label[i] == label[rev(i)]) return false;
		return true;
	}
    vector<vector<int>> topological_sort(void) {
        vector<vector<int>> ret(max_id);
        for(int i=0;i<num;++i) ret[label[i]].push_back(i);
        return ret;
    }
	int is_true(int i) {
		return label[i] > label[rev(i)];
	}
	void print(void) {
		for(auto id:label) cout << id << " ";
		cout << endl;
	}
};


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    StronglyConnectedComponents scc(N);
    while(M--) {
        int u,v; cin >> u >> v;
        scc.make_edge(u,v);
    }
    scc.solve();
    auto vv=scc.topological_sort();
    cout << vv.size() << "\n";
    for(auto& v:vv) {
        cout << v.size();
        for(auto& e:v) cout << " " << e;
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 59800
#include<iostream>
using namespace std;struct P{float x,y;int operator-=(P&a){x-=a.x;y-=a.y;}};P A,B,C,S,G;int X(P S){C.x=(B.y*S.x-B.x*S.y)/(A.x*B.y-A.y*B.x);C.y=(A.y*S.x-A.x*S.y)/(A.y*B.x-A.x*B.y);return C.x>0&C.y>0&C.x+C.y<1;}main(){for(cin>>A.x;cin>>A.x>>A.y>>B.x>>B.y>>C.x>>C.y>>S.x>>S.y>>G.x>>G.y;X(S)^X(G)?cout<<"OK\n":cout<<"NG\n"){A-=C;B-=C;S-=C;G-=C;}}

Measured memory_bytes: 936
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<double, double> P;
typedef pair<P, int> PI;
const LL MOD = 1000000007LL;
const double EPS = 1e-10;
double add(double a, double b) {
	if (abs(a + b) < EPS*(abs(a) + abs(b))) return 0;
	return a + b;
}
double det(P a, P b) {
	return add(a.first*b.second, -a.second*b.first);
}
double dot(P a, P b) {
	return add(a.first*b.first, a.second*b.second);
}
double abs(P a) {
	return sqrt(pow(a.first, 2) + pow(a.second, 2));
}
P operator-(const P a, const P b) {
	return P(add(a.first, -b.first), add(a.second, -b.second));
}
double prob[100];
int main() {
	int N;
	cin >> N;
	vector<PI> ps;
	for (int i = 0; i < N; i++) {
		double x, y;
		cin >> x >> y;
		ps.push_back(PI(P(x, y), i));
	}
	sort(ps.begin(), ps.end());
	int k = 0;
	vector<PI> qs(N * 2);
	for (int i = 0; i < N; i++) {
		while (k > 1 && det(qs[k - 1].first - qs[k - 2].first, ps[i].first - qs[k - 1].first) <= 0) k--;
		qs[k++] = ps[i];
	}
	for (int i = N - 2, t = k; i >= 0; i--) {
		while (k > t && det(qs[k - 1].first - qs[k - 2].first, ps[i].first - qs[k - 1].first) <= 0) k--;
		qs[k++] = ps[i];
	}
	qs.resize(k - 1);
	if (qs.size() == 2) {
		prob[qs[0].second] = 0.5;
		prob[qs[1].second] = 0.5;
	}
	else {
		double PI = acos(-1);
		for (int i = 0; i < qs.size(); i++) {
			P l = qs[(i - 1 + qs.size()) % qs.size()].first - qs[i].first;
			P r = qs[(i + 1) % qs.size()].first - qs[i].first;
			double theta = acos(-dot(l, r) / (abs(l)*abs(r)));
			prob[qs[i].second] = theta / (2 * PI);
		}
	}
	for (int i = 0; i < N; i++) cout << prob[i] << endl;
}

Measured memory_bytes: 512
#include<cstdio>
void sima(int x,int y);
char SIMA[14][14];
int main ()
{
    while(scanf("%s",SIMA[1]+1)!=EOF){
        int i,j,ans=0;
        for(i=2;i<13;i++){
            scanf("%s",SIMA[i]+1);
        }
        for(i=1;i<13;i++){
            for(j=1;j<13;j++){
                if(SIMA[j][i]=='1'){
                    ans++;
                    sima(j,i);
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}
void sima(int x,int y)
{
    if(SIMA[x][y]=='0' || SIMA[x][y]==0) return;
    else SIMA[x][y]='0';
    sima(x+1,y); sima(x,y+1); sima(x-1,y); sima(x,y-1);
}

Measured memory_bytes: 972
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(b-a==c-b)cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

int a,b,c;
int n = 0;
cin >> a >> b >> c;
if (a==b)
n++;
if (a==c)
n++;
if (b==c)
n++;
if(n == 1)
cout << "Yes" << endl;
else
cout << "No" << endl;


return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,l) for(int i=0;i<l;i++)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define in(x) scanf("%d",&x)
#define lin(x) scanf("%lld",&x)
#define out(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
typedef long long ll;
const int N=3e5;
typedef struct node{
	ll s,t,x;	
}NODE;
NODE stu[N];
bool cmp(NODE a,NODE b){
	return a.x<b.x;
}
set<pair<ll,ll> >s;
ll n,q,d[N],a[N],ans[N];
signed main(){
	lin(n),lin(q);
	rep(i,n){
		lin(stu[i].s),lin(stu[i].t),lin(stu[i].x);
	}
	sort(stu,stu+n,cmp);
	rep(i,q){
		lin(d[i]);
		s.insert({d[i],i});
		ans[i]=-1;
	}
	rep(i,n){
		set<pair<ll,ll> >::iterator it;
		it=s.lower_bound({stu[i].s-stu[i].x,0});
		while(it!=s.end()){
			if((it->first)>=(stu[i].t-stu[i].x))break;
			ans[it->second]=stu[i].x;
			s.erase(it++);
		}
	}
	rep(i,q){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 24192
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const int DEBUG = 0;

int main(void){
  int n;
  cin >> n;
  VL a(n);
  REP(i, 0, n) {
    cin >> a[i];
  }
  ll sum = 0;
  ll ma = 0;
  REP(i, 0, n) {
    ll quo = (a[i] - 1) / (ma + 1);
    sum += quo;
    a[i] -= quo * (ma + 1);
    if (quo >= 1) {
      a[i] = 1;
    }
    ma = max(ma, a[i]);
  }
  if (DEBUG) {
    REP(i, 0, n) {
      cerr << "a[" << i << "]=" << a[i] << endl;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  double[] a = new double[N];
  double sum = 0;
  for(int i = 0;i < N;i++){
    a[i] = sc.nextDouble();
    sum += a[i];
  }
  double avr = Math.round(sum/N);
  double ans = 0;
  for(int i = 0;i < N;i++){
    ans += (a[i]-avr)*(a[i]-avr);
  }
  System.out.println((int)ans);
}}

Measured memory_bytes: 23380
import numpy as np

x1,y1,x2,y2 = list(map(int,input().split()))

mat = np.array([[0,1],[-1,0]])
vec = [x2 - x1, y2 - y1]
rot_vec = -mat.dot(vec)
x4, y4 = rot_vec + np.array([x1,y1])
x3 = x4 + vec[0]
y3 = y4 + vec[1]

print(x3,y3,x4,y4)




Measured memory_bytes: 21628
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define f first
#define s second
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(...) cout << " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " << endl

using ld = long double;
using ll = long long;
using pii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vpii = vector <pii>;
using vpll = vector<pll>;
using vs = vector <string>;


int main(){
  fastio;

  int n;
  cin >> n;
  vi a(n);

  int gcd = 0;

  vll primes;
  const int nax = 1e6 + 5;
  bitset <nax> is_prime;

  is_prime.set();

  for(ll i=2;i<=nax;i++){
    if(is_prime[i]){
      primes.pb(i);
      for(ll j = i*i;j<=nax;j += i)
        is_prime[j] = false;
    }
  }
  
  for(int i=0;i<n;i++){
    cin >> a[i];
    gcd = __gcd(a[i],gcd);
  }

  if(gcd != 1){
    cout << "not coprime" << endl;
    return 0;
  }

  vi freq(nax,0);

  for(int i=0;i<n;i++){
    int k = 0;
    while(primes[k]*primes[k] <= a[i]){
      int cnt = 0;
      while(a[i] % primes[k] == 0)
        cnt++,a[i] /= primes[k];
      if(cnt)
        freq[primes[k]]++;
      k++;
    }
    if(a[i] != 1)
      freq[a[i]]++;
  }

  bool pairwise = true;

  for(int i=2;i<nax;i++)
    if(freq[i] > 1){
      pairwise = false;
      break;
    }

  if(pairwise)
    cout << "pairwise coprime" << endl;
  else
    cout << "setwise coprime" << endl;

  return 0;
}

Measured memory_bytes: 11976
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    string s;
    getline(cin,s);
    rep(i,s.size())cout<<'x';
    cout<<endl;
    return 0;
}







Measured memory_bytes: 256
import java.util.*;


public class Main {
	static int w;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
          int h=sc.nextInt();
          w=sc.nextInt();
          if(h==0&&w==0)break;
          mm();
          for(int  i=0;i<h-2;i++){
        	 System.out.print("#");
        	 for(int j=0;j<w-2;j++){
        	    	System.out.print(".");  	
            	}
        	 System.out.println("#"); 
           }
          mm();
          System.out.println();
          
        }
			
    }
    static void mm(){
    	for(int j=0;j<w;j++){
    		System.out.print("#");
    		
    	}
    	System.out.println();
    }
}

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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a,b;
  cin >> a >> b;
  if(a <= 9 && b <= 9) cout << a*b << endl;
  else cout << "-1 " << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

s, w = inm()
print("unsafe" if w >= s else "safe")

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

int main() {
  ll d,g;
  cin >> d >> g;
  
  vector<ll> p(d);
  vector<ll> c(d);
  
  for(ll i=0; i<d; i++){
    cin >> p[i] >> c[i];
  }
  
  ll ans = 1005;
  for(ll i=0; i < (1<<d); i++){
    ll bit[d] = {};
    ll j = i;
    ll k = 0;
    while(j>0){
      bit[k++] = j%2;
      j /= 2;
    }
    
    ll count = 0, rem = g;
    
    for(ll m=0; m<d; m++){
      count += bit[m] * p[m];
      rem -= bit[m] * (100 * (m+1) * p[m] + c[m]);
    }
    
    if(rem <= 0){
      ans = min(ans, count);
      continue;
    }
    
    ll m = d-1;
    while(rem > 0 && m >= 0){
      if(bit[m] == 0){
        if(rem <= (m+1) * 100 * (p[m]-1)){
          count += rem/((m+1)*100) + (rem % ((m+1)*100) > 0);
          rem = -1; 
          break;
        }else{
          count += p[m]-1;
          rem -= 100 * (p[m]-1) * (m+1);
        }
      }
      --m;
    }
    
    if(rem <= 0)
      ans = min(ans, count);
  }
  
  
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

const int MOD = 1000000007;


long long modPow(long long a, long long p){
    if(p == 0) return 1;
    auto res = modPow(a, p/2);
    res = (res*res)%MOD;
    if(p%2) res = (res*a)%MOD;
    return res;
}

int main(){
    const int maxSize = 2000001;
	vector<long long> inv(maxSize);
	vector<long long> fact(maxSize);
	vector<long long> factInv(maxSize);
	for(int i=0;i<2;i++) inv[i] = fact[i] = factInv[i] = 1;
	for(int i=2;i<maxSize;i++){
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		fact[i] = fact[i-1] * i % MOD;
		factInv[i] = factInv[i-1] * inv[i] % MOD;
	}
	auto comb = [&](int n, int r){
		if(n < r || r < 0) return 0LL;
		return fact[n] * factInv[n-r] % MOD * factInv[r] % MOD;
	};
    long long res = 0;
    int K; cin >> K;
    string S; cin >> S;
    const int N = S.size();
    for(int i=0;i<=K;i++){
        res += comb(i+N-1, N-1) * modPow(25, i) % MOD * modPow(26, K-i) % MOD;
        res %= MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 52140
#include <iostream>
#include <math.h>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstdlib>
#include <unordered_map>
#include <numeric>
#include <functional>
#include <limits.h>
#include <utility>
#include <stack>

using namespace std;

#define fs first
#define sc second

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

#define MAX_V 101000
vector<int> edge[MAX_V];

/**
 *
 * @param N 頂点数(0-indexed)
 * @return
 */
vector<int> topologicalSort(int N){
    stack<int> st;
    int h[MAX_V];
    fill(h, h+MAX_V, 0);
    for(int i = 0; i < N; i++){
        for(auto j: edge[i]){
            h[j]++;
        }
    }

    for(int i = 0; i < N; i++){
        if(h[i] == 0){
            st.push(i);
        }
    }

    vector<int> ans;
    while(st.size()){
        int i = st.top(); st.pop();
        ans.push_back(i);
        for(auto j: edge[i]){
            h[j]--;
            if(h[j] == 0){
                st.push(j);
            }
        }
    }
    return ans;
}


int main(){
    int dp[101000];

    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        edge[x].push_back(y);
    }
    fill(dp, dp+101000, 0);

    vector<int> sortedIndex = topologicalSort(N);
    for(int i = N-1; i >= 0; i--){
        int res = 0;
        for(auto j: edge[sortedIndex[i]]){
            res = max(res, dp[j] + 1);
        }
        dp[sortedIndex[i]] = res;
    }

    int res = 0;
    for(int i = 0; i < N; i++){
        res = max(res, dp[i]);
    }
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 7164
#include <iostream>
#define MAX_N 100000
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int64_t A[MAX_N + 2];
  int64_t SUM = 0;
  A[0] = 0;
  for (int i = 1; i < N + 1; i++) {
    cin >> A[i];
    SUM += abs(A[i - 1] - A[i]);
  }
  A[N + 1] = 0;
  SUM += abs(A[N]); // Last to Zero

  for (int i = 1; i < N + 1; i++) {
    int64_t Ans = SUM - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) +
                  abs(A[i - 1] - A[i + 1]);
    cout << Ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2048
program main
	implicit none
	integer :: i, temp, ans
	character(10) :: S
	read(*, *) S
	ans = 100000
	do i = 1, len_trim(S)-2
		read(S(i:i+2), *) temp
		ans = min(ans,abs(temp-753))
	end do
	write(*, *) ans
end program main

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x = 0, y = 0;
  string S;
  cin >> N >> S;
  for (char c : S) { 
    if (c == 'I') {
      y = max(y,++x);
    } else {
      x--;
    }
  }
  cout << y;
}

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

int main() {
  int H,W,h,w;
  cin>>H>>W>>h>>w;
  cout<<(H-h)*(W-w)<<endl;
}


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

# @profile
def calc_lcs(s, t):
  dp = [[0 for _ in range(len(t)+1)] for _ in range(len(s)+1)]
  # dp = numpy.zeros((len(s)+1, len(t)+1))
  for i, si in enumerate(s, 1):
    for j, tj in enumerate(t, 1):
      dp[i][j] = max((dp[i-1][j-1] + 1) if si==tj else 0, dp[i-1][j], dp[i][j-1])

  lcs = ''
  i, j = len(s), len(t)
  while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
      i -= 1
    elif dp[i][j] == dp[i][j-1]:
      j -= 1
    elif dp[i][j] == dp[i-1][j-1]+1:
      lcs = s[i-1] + lcs
      i -= 1
      j -= 1
  return lcs

def main():
  s = input().strip()
  t = input().strip()
  print(calc_lcs(s, t))


if __name__=='__main__':
  main()

Measured memory_bytes: 120412
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,k,r,s,p;
string t,y;
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k >> r >> s >> p >> t;
	int ans = 0;
	for(int i = 0;i < n;i++){
		if(i >= k){
			if(t[i-k] == t[i]){
				if(t[i] == 'r'){
					if(y[i-k] == 'p') y += 'r';
					else y += 'p',ans += p;
				}
				else if(t[i] == 'p'){
					if(y[i-k] == 's') y += 'p';
					else y += 's',ans += s;
				}
				else{
					if(y[i-k] == 'r') y += 's';
					else y += 'r',ans += r;
				}
			}
			else{
				if(t[i] == 'r') ans += p,y += 'p';
				else if(t[i] == 'p') ans += s,y += 's';
				else ans += r,y += 'r';
			}
		}
		else{
			if(t[i] == 'r') ans += p,y += 'p';
			else if(t[i] == 'p') ans += s,y += 's';
			else ans += r,y += 'r';
		}
	}
	cout << ans << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

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

}

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

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}



  








      

 
int main() {
    int n,m;
    cin >> n >> m;
    int k,a;
    map <int,int> cnt;
    rep (i,n){
      cin >> k;
      rep (j,k){
        cin >> a;
        cnt[a]++;
      }
    }
    int ans = 0;
    rep (i,m+1){
      if(cnt[i]==n){
        ans++;
      }
    }
  cout << ans << endl;
}

Measured memory_bytes: 3632
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = in.nextInt();
        long D = in.nextInt();
        int ans = 0;
        for (int n = 0; n < N; n++) {
            long X = in.nextInt();
            long Y = in.nextInt();
            if (X*X + Y*Y <= D*D)
                ans++;
        }
        out.println(ans);
        
        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 56364
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b;
	c=a+b;
	if(a%3==0||b%3==0||c%3==0) cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
from scipy.sparse.csgraph import floyd_warshall


N = int(input())
A = [[int(a) for a in input()] for _ in range(N)]
graph = np.array(A)
dist_mat = floyd_warshall(graph).astype(np.int64)
max_d = dist_mat.max()

B = np.where(dist_mat[0]%2 == 0)
C = np.where(dist_mat[0]%2 == 1)

bl = (graph[B][:, B] == 0).all() and (graph[C][:, C] == 0).all()



if bl:
    print(max_d + 1)
else:
    print(-1)

Measured memory_bytes: 38888
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
XYH = [tuple(map(int,input().split())) for _ in range(N)]

# 高さの降順にソートしておく
#  -> これをしないと 高さ 0 を基準に中心の高さを決めてしまう可能性があるので
XYH.sort(key=lambda x:x[2], reverse=True)

# 中心座標で全探索
for xi in range(101):
    for yi in range(101):
        flg = True
        x,y,h = XYH[0]
        # 中心の高さ
        hh0 = abs(xi-x) + abs(yi-y) + h
        for i in range(1,N):
            x,y,h = XYH[i]
            if h == 0:
                hhi = abs(xi-x) + abs(yi-y) + h
                if hh0 > hhi:
                    flg = False
                    break
            else:
                hhi = abs(xi-x) + abs(yi-y) + h
                if hh0 != hhi:
                    flg = False
                    break
        if flg:
            print(xi,yi,hh0)
            sys.exit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
struct edge{
	int to,next,w;
}e[20000002];
int n,m,head[300002],ans,cnt,sum,s;
inline void add(re int x,re int y,re int w){
	e[++cnt].to=y;
	e[cnt].next=head[x];
	head[x]=cnt;
	e[cnt].w=w;
}
struct node{
    int pos,dis;
    bool operator <(const node x)const{
        return dis>x.dis;
    }
}h[300002];
priority_queue <node> q;
bool v[300002];
inline int pos(re int x,re int y){
	return x*(sum+1)+y;
}
inline void dis(re int s){for(re int i=1;i<=pos(n,sum);++i)h[i].dis=1e18,h[i].pos=i;
    h[s].dis=0;
    q.push(h[s]);
    while(!q.empty()){
        while((h[q.top().pos].dis<q.top().dis)){q.pop();if(q.empty())break;
        }
        if(q.empty())break;
        node tmp=q.top();
        q.pop();
        for(re int i=head[tmp.pos];i;i=e[i].next){
            if((tmp.dis+e[i].w)<h[e[i].to].dis){
                h[e[i].to].dis=tmp.dis+e[i].w;
                q.push(h[e[i].to]);
            }
        }
     
    }
}
signed main(){
	n=read();m=read();s=read();
	sum=5000;
	for(re int i=1,x,y,a,b;i<=m;++i){
		x=read();y=read();a=read();b=read();
		for(re int j=a;j<=sum;++j)add(pos(x,j),pos(y,j-a),b),add(pos(y,j),pos(x,j-a),b);
	}
	for(re int x,y,i=1;i<=n;++i){
		x=read();y=read();
		for(re int j=0;j<=sum;++j){
		add(pos(i,j),pos(i,min(j+x,sum)),y);if(j)add(pos(i,j),pos(i,j-1),0);}
	}
	dis(pos(1,min(s,sum)));
	for(re int i=2;i<=n;++i)printf("%lld\n",h[pos(i,0)].dis);
}


Measured memory_bytes: 45588
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin>>N;
    long int s=0;
    for(int i=1;i<=N;i++)
    {
        if(i%3==0 || i%5==0)
        {
          
        }
        else
        {
            s=s+i;
        }
    }
    cout<<s<<endl;
}

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

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

int main(){
	LL N, X, M;
	cin >> N >> X >> M;
	vector<LL> A(M+2), sum(M+2);
	vector<LL> app(M+1);
	A[1]=X, sum[1]=X, app[X]=1;
	LL ans=0;
	LL dif=0;
	for(LL i=1; i<=M; i++){
		A[i+1]=A[i]*A[i]%M;
		sum[i+1]+=sum[i]+A[i+1];
		LL k=app[A[i+1]];
		if(k){
			ans+=sum[k-1];
			dif=i-k+1;
			LL num=(N-(k-1))/dif;
			LL res=(N-(k-1))%dif;
			ans+=num*(sum[i]-sum[k-1]);
			ans+=sum[k-1+res]-sum[k-1];
			break;
		}
		else app[A[i+1]]=i+1;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5548
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	const int MAX=100001;
	int node[MAX]={};
	int N,M;
	cin>>N>>M;
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		node[a]++;
		node[b]++;
	}
	for(int i=0;i<=N;i++){
		if(node[i]%2==1){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define tc() ll T;cin>>T;while(T--)

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    /*-----------------Code Begins Here------------------*/
    
    ll n; cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++) cin>>a[i];
    ll mini = a[0],maxi = a[0],i=0,ans=1000,flag=1;
    while(i<n){
        mini=200;
        maxi=100;
        while(i<n){
            if(a[i]<=mini){
                mini = a[i];
            }
            else break;
            if(i==n-1) flag=0;
            i++;
        }
        while(i<n){
            if(a[i]>=maxi){
                maxi = a[i];
            }
            else break;
            i++;
        }
        if(flag) ans+=(maxi-mini)*(ans/mini);
        //i++;
    }
    cout<<ans;
    
    /*------------------Code Ends Here-------------------*/
    
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
using namespace std;
long long n;
char s[4010];
long long cnt[4010][3];//0:R 1:G 2:B
long long ans;
long long f(char c) {
	if (c == 'R') return 0;
	if (c == 'G') return 1;
	return 2;
}
long long g(char a, char b) {
	return (3 - f(a) - f(b)) % 3;
}
int main() {
	scanf("%lld%s", &n, s + 1);
	for (long long i = n; i >= 1; i--) {
		cnt[i][0] = cnt[i + 1][0];
		cnt[i][1] = cnt[i + 1][1];
		cnt[i][2] = cnt[i + 1][2];
		cnt[i][f(s[i])]++;
	}
	for (long long i = 1; i < n - 1; i++) {
		for (long long j = i + 1; j < n; j++) {
			if (s[i] == s[j]) continue;
			ans += cnt[j + 1][g(s[i], s[j])];
			if (j + j - i <= n && f(s[j + j - i]) == g(s[i], s[j])) ans--;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
int main(){
  	string s1,s2,s3;
  	cin >> s1;
  	cin >> s2;
  	int a,b;
  	cin >> a >> b;
  	cin >> s3;
  	if(s3==s1)
      	printf("%d %d",a-1,b);
 
  	if(s3==s2)
      	printf("%d %d",a,b-1);
	return 0;
}

Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const ll MOD = 1e9+7;
//}}}

ll a[100000];
ll c[100000];
ll abc[100000];
ll modExp3[100001];
ll numABC;

int main(){
  string S;
  cin >> S;
  int N = S.size();
  rep(i, N){
    switch(S[i]){
      case 'A':
        a[i]++;
        break;
      case 'B':
        break;
      case 'C':
        c[i]++;
        break;
      case '?':
        abc[i]++;
        break;
    }
  }
  modExp3[0] = 1;
  rep(i, 1, N + 1){
    modExp3[i] = modExp3[i - 1] * 3;
    modExp3[i] %= MOD;
  }
  rep(i, 1, N){
    a[i] += a[i - 1];
    c[i] += c[i - 1];
    abc[i] += abc[i - 1];
  }
  numABC = abc[N - 1];
  ll ans = 0;
  rep(i, 1, N - 1){
    if(S[i] == 'B' || S[i] == '?'){
      int h = S[i] == '?';
      ans += a[i - 1] * (c[N - 1] - c[i]) * modExp3[numABC - h];
      ans += a[i - 1] * (abc[N - 1] - abc[i]) * modExp3[numABC - 1 - h];
      ans += abc[i - 1] * (c[N - 1] - c[i]) * modExp3[numABC - 1 - h];
      ans += abc[i - 1] * (abc[N - 1] - abc[i]) * modExp3[numABC - 2 - h];
      ans %= MOD;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ld a, b, c;
    cin >> a >> b >> c ;
    
    ld l = a + b + (ld)2.0*sqrt(a * b);
    ld r = c;
    
    cerr << l << " " << r << endl;
    if(l < r){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

template<class G>
class Fenwick_tree{
	vector<G> a;
public:
	Fenwick_tree(int n):a(n){}
	void add(int i,G val){
		for(i++;i<=a.size();i+=i&-i) a[i-1]+=val;
	}
	G sum(int l,int r)const{
		if(l==0){
			G res{};
			for(;r>0;r-=r&-r) res+=a[r-1];
			return res;
		}
		return sum(0,r)-sum(0,l);
	}
	int lower_bound(G val)const{
		if(val<=G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<val) val-=a[x+k-1], x+=k;
		return x;
	}
	int upper_bound(G val)const{
		if(val<G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<=val) val-=a[x+k-1], x+=k;
		return x;
	}
};

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

	vector<Fenwick_tree<int>> F(26,Fenwick_tree<int>(n));
	rep(i,n) F[s[i]-'a'].add(i,1);

	int q; scanf("%d",&q);
	rep(_,q){
		int type,a; scanf("%d%d",&type,&a); a--;
		if(type==1){
			char c; scanf(" %c",&c);
			char pre=s[a];
			s[a]=c;
			F[pre-'a'].add(a,-1);
			F[c-'a'].add(a,1);
		}
		else{
			int b; scanf("%d",&b);
			int ans=0;
			rep(c,26) if(F[c].sum(a,b)>0) ans++;
			printf("%d\n",ans);
		}
	}

	return 0;
}


Measured memory_bytes: 53636
#include<stdio.h>
#define Max 500000
#define term 1000000000

int Left[(Max/2)+2], Right[(Max/2)+2];
int c=0;


void merge(int e[], int n, int left, int mid, int right){
  int i,j,k;

  int x = (mid-left);
  int y = (right-mid);

  for ( i=0; i<x; i++ )
   Left[i] = e[left+i];
  for ( i=0; i<y; i++ )
   Right[i] = e[mid+i];

  Left[x]= Right[y] = term;
  i = j = 0;
  for ( k=left; k<right; k++){
    c++;
    if ( Left[i]<=Right[j] ){
      e[k] = Left[i++];
    } else {
      e[k] = Right[j++];
    }
  }
}

void mergeSort(int e[], int n, int left, int right ){
  int mid;
  if ( left+1<right ){
    mid=(left + right)/2;
    mergeSort(e, n, left, mid);
    mergeSort(e, n, mid, right);
    merge(e, n, left, mid, right);
  }
}

int main(){
  int e[Max], n, i;
  scanf("%d", &n);
  for ( i=0; i<n; i++) {
    scanf("%d", &e[i]);
    if (e[i]>=term ){
      return 1;
    }
  }
  mergeSort(e,n,0,n);

  for ( i=0; i<n; i++) {
    if ( i !=0 ) 
    printf(" ");

    printf("%d", e[i]);
    }
  printf("\n");

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


  return 0;
}




Measured memory_bytes: 5672
n,w=map(int,input().split())
W=[]
V=[]

for i in range(n):
	a,b=map(int,input().split())
	W.append(a)
	V.append(b)

def knap(n,w):
	dp=[[0]*(w+1) for i in range(n+1)]
	for i in range(n):
		for j in range(w+1):
			if j<W[i-1]:
				dp[i+1][j]=dp[i][j]
			else:
				dp[i+1][j]=max(dp[i][j],dp[i][j-W[i-1]]+V[i-1])
	return dp[n][w]

print(knap(n,w))


Measured memory_bytes: 119024
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { A: number, B: number } => {
  const [A, B] = lines[0].split(' ').map(line => +line)
  const obj = { A, B }
  debug(obj)
  return obj
}
// solver
export const solve = (lines: string[]): string => {
  const { A, B } = parseLines(lines)
  let plugs = 1
  let count = 0
  while (plugs < B) {
    plugs = plugs + A - 1
    count += 1
  }

  return `${count}`
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 11596
#include <iostream>
#include <complex>

using namespace std;
typedef complex<double> P;

double cr(P a,P b){return (conj(a)*b).imag();}

int main(){
  P a,b,c,d;
  char com;
  while(cin >> a.real() >> com >> a.imag() >> com >> b.real() >> com >> b.imag() >> com >> c.real() >> com >> c.imag() >> com >> d.real() >> com >> d.imag()){
    P e=a-b,f=b-c,g=c-d,h=d-a;
    double i=cr(e,f),j=cr(f,g),k=cr(g,h),l=cr(h,e);
    if((i>0&&j>0&&k>0&&l>0)||(i<0&&j<0&&k<0&&l<0))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <unordered_map>

using ll = long long;
int main() {
    using namespace std;
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;++i)cin >> a[i];
    vector<int> boxes(n);
    vector<int> out;
    for(int i = n;i >= 1;--i){
        int t = 0;
        for(int j = i;j <= n;j += i)t += boxes[j - 1];
        if(t % 2 != a[i - 1]){
            boxes[i - 1] = 1;
            out.push_back(i);
        }
    }
    cout << out.size() << endl;
    for(int i:out)cout << i << " ";
    cout << endl;
}

Measured memory_bytes: 3192
#include <iostream>
#include <set>
#include <vector>
using namespace std;

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

int main(void){
    int n;
    vector<string> v_w(100);
    set<string> s_w;
    bool flg = true;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n) {
        cin >> v_w[i];
        if (s_w.count(v_w[i]) > 0) {
            flg = false;
        }
        
        s_w.insert(v_w[i]);
    }
    REP (i, n - 1) {
        if (v_w[i].back() != v_w[i + 1].front()) {
            flg = false;
            break;
        }
    }
    
    cout << (flg? "Yes" : "No") << "\n";
    return 0;
}


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

int main() {
  long d;
  cin >> d;
  vector<long> c(26);
  vector<long> last(26);
  vector<vector<long>> s(d,vector<long>(26));
  vector<long> ans(d);
  for(long i=0;i<26;i++) cin >> c[i];
  for(long i=0;i<d;i++) for(long j=0;j<26;j++) cin >> s[i][j];

  for(long i=0;i<d;i++) {
    long a=-1,b=-9999999999;
    for(long j=0;j<26;j++) {
      if(b<(i+1-last[j])*(d-i)*c[j]+s[i][j]) a=j,b=(i+1-last[j])*(d-i)*c[j]+s[i][j];
    }
    ans[i]=a+1;
    last[a]=i+1;
  }

  for(long i=0;i<d;i++) cout << ans[i] << endl;
}

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

typedef long long LL;

int n, ans = 1e9;

int calc(int x) {
	int res = 0;
	while(x) {
		res += x%10;
		x /= 10;
	}
	return res;
}

int main() {
	cin>>n;
	for(int i = 1; i < n; i++) 
		ans = min(calc(i) + calc(n - i), ans);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
	"strings"
)

func permutation(n int, k int) int {
	v := 1
	if 0 < k && k <= n {
		for i := 0; i < k; i++ {
			v *= (n - i)
		}
	} else if k > n {
		v = 0
	}
	return v
}

func factorial(n int) int {
	return permutation(n, n-1)
}

func combination(n int, k int) int {
	return permutation(n, k) / factorial(k)
}

func sortString(w string) string {
	s := strings.Split(w, "")
	sort.Strings(s)
	return strings.Join(s, "")
}

func main() {
	// Code for C - Green Bin
	var N int
	fmt.Scanf("%d", &N)

	s := make(map[string]int, N)
	var S string
	for i := 0; i < N; i++ {
		fmt.Scanf("%s", &S)
		S = sortString(S)
		s[S]++
	}

	var ans int
	for _, v := range s {
		if v > 1 {
			ans += combination(v, 2)
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 12948
#include <bits/stdc++.h>
using i64 = long long;
using B = std::bitset<26000>;

int main() {
    constexpr int base = 13000;
    int h, w;
    std::cin >> h >> w;
    std::vector<std::vector<int>> a(h, std::vector<int>(w));
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) std::cin >> a[i][j];
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        int b;
        std::cin >> b;
        a[i][j] = abs(a[i][j] - b);
    }

    std::vector<std::vector<B>> dp(h, std::vector<B>(w));
    dp[0][0].set(a[0][0] + base);
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        if (!i && !j) continue;
        if (i) {
            dp[i][j] |= (dp[i - 1][j] << a[i][j]) | (dp[i - 1][j] >> a[i][j]);
        }
        if (j) {
            dp[i][j] |= (dp[i][j - 1] << a[i][j]) | (dp[i][j - 1] >> a[i][j]);
        }
    }

    int ret = base * 2;
    for (int i = 0; i < 26000; i++) {
        if (dp[h - 1][w - 1][i]) {
            ret = std::min(ret, abs(base - i));
        }
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 20992
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(ll i=0;i<(int)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(int)(n);i++)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<ll,ll> pint;
const long long INF = 1LL<<60;
const ll MOD = 1000000007;
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    else{
        return gcd(b,a%b);
    }
}
int main(){
    ll n,m;cin>>n>>m;
    vector<ll> h(n);rep(i,n)cin>>h[i];
    vector<ll> ans(n,1);
    rep(i,m){
        ll a,b;cin>>a>>b;
        if(h[a-1]<h[b-1]){
            ans[a-1]=0;
        }
        else if(h[a-1]==h[b-1]){
            ans[a-1]=0;
            ans[b-1]=0;
        }
        else if(h[b-1]<h[a-1]){
          ans[b-1]=0;
        }
    }
    ll res = 0;
    rep(i,n) res+=ans[i];
    cout<<res<<endl;
}


Measured memory_bytes: 4840
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N, M := sc.nextInt(), sc.nextInt()
	like := make([]int, M)
	for i := 0; i < N; i++ {
		k := sc.nextInt()
		for j := 0; j < k; j++ {
			like[sc.nextInt()-1]++
		}
	}
	ans := 0
	for _, v := range like {
		if v == N {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640