akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
    int n;
    cin >> n;
    if (n == 2)
        puts("-1");
    else if (n == 3) {
        cout << "aa." << endl;
        cout << "..a" << endl;
        cout << "..a" << endl;
    } else {
        int x = n / 4 - 1;
        int y = n - 4 * x;
        for (int i = 0; i < x; i++) {
            string padding_left = string(4 * i, '.');
            string padding_right = string(n - 4 * (i + 1), '.');
            cout << padding_left << "aabc" << padding_right << endl;
            cout << padding_left << "ddbc" << padding_right << endl;
            cout << padding_left << "bcaa" << padding_right << endl;
            cout << padding_left << "bcdd" << padding_right << endl;
        }
        string padding = string(n - y, '.');
        if (y == 4) {
            cout << padding << "aabc" << endl;
            cout << padding << "ddbc" << endl;
            cout << padding << "bcaa" << endl;
            cout << padding << "bcdd" << endl;
        }
        if (y == 5) {
            cout << padding << "aabba" << endl;
            cout << padding << "bcc.a" << endl;
            cout << padding << "b..cb" << endl;
            cout << padding << "a..cb" << endl;
            cout << padding << "abbaa" << endl;
        }
        if (y == 6) {
            cout << padding << "aabc.." << endl;
            cout << padding << "ddbc.." << endl;
            cout << padding << "..aabc" << endl;
            cout << padding << "..ddbc" << endl;
            cout << padding << "bc..aa" << endl;
            cout << padding << "bc..dd" << endl;
        }
        if (y == 7) {
            cout << padding << "aabbcc." << endl;
            cout << padding << "dd.dd.a" << endl;
            cout << padding << "..d..da" << endl;
            cout << padding << "..d..db" << endl;
            cout << padding << "dd.dd.b" << endl;
            cout << padding << "..d..dc" << endl;
            cout << padding << "..d..dc" << endl;
        }
    }
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  vector<int> v(3,0);
  for(int i=0;i<3;i++) cin>>v[i];
  sort(v.begin(),v.end());
  bool f=true;
  if(v[0]!=5||v[1]!=5||v[2]!=7) f=false;
  cout<<(f?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
# 2020/04/26
# AtCoder Beginner Contest 057 - B

# Input
n, m = map(int,input().split())

stds = list()
chkp = list()

for i in range(n):
    ab = list(map(int,input().split()))
    stds.append(ab)

for i in range(m):
    cd = list(map(int,input().split()))
    chkp.append(cd)

# Calc
for i in range(n):
    mindist = 10**9
    ans = -1
    for j in range(m):
        dist = abs(chkp[j][0] - stds[i][0]) + abs(chkp[j][1] - stds[i][1])
        if dist < mindist:
            mindist = dist
            ans = j + 1

    # Output
    print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

#define INF 0xc0c0c0c0
#define NINF 0x3f3f3f3f

#define FOR(i, a, b) for((i)=a; i<b; ++(i))
#define EFOR(i, a, b) for((i)=a; i>b; --(i))

#define MLC(n, type) (type*)malloc(n*sizeof(type))
#define CLC(n, type) (type*)calloc(n, sizeof(type))

#define MAXN 100000+1

bool bigger(const pair<int, pair<int, int> >a, const pair<int, pair<int, int> >b) {
	bool ret = false;
	return a.second.second<b.second.second;
}

void solver(int *city, int *years, int cityNum, int *prefectures, int prefecturesNum) {
	int i;
	vector<pair<int, pair<int, int> > >vec;

	FOR(i, 0, cityNum) {
		vec.push_back(make_pair(i+1, make_pair<int, int>(city[i], years[i])));
	}
	sort(vec.begin(), vec.end(), bigger);
	FOR(i, 0, cityNum) {
		prefectures[vec[i].second.first]++;
		//printf("%d %d %d\n", vec[i].first, vec[i].second.first, vec[i].second.second);
		city[vec[i].first] = vec[i].second.first;
		years[vec[i].first] = prefectures[vec[i].second.first];
	}
	FOR(i, 1, cityNum+1) {
		printf("%06d%06d\n", city[i], years[i]);
	}

	return;
}

int main() {
	int i,n,m;
	int p[MAXN] = {0}, y[MAXN] = {0};
	int b[MAXN] = {0};
	vector<pair<int, int> > a;

	scanf("%d %d", &n, &m);

	FOR(i, 0, m) {
		scanf("%d %d", &p[i], &y[i]);
	}

	solver(p, y, m, b, n);
	return 0;
}


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

signed main(){
    int N; cin>>N;
    vector<int> p(N);
    for(int i=0;i<N;i++){
        cin>>p[i];
    }
    int ans=0;
    for(int i=1;i<N-1;i++){
        if(p[i-1]<p[i] and p[i]<p[i+1] or p[i-1]>p[i] and p[i]>p[i+1]){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define forinc(i,a,b) for(int i=a;i<=b;i++)
#define fordec(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second
#define pii pair<int,int>

const int maxn=500,N=1e5;
int n,a[maxn][maxn],H,W,K,ans[maxn][maxn],dd[maxn];
int fre[maxn][maxn];
int cnt,mau=1;
pair<int,int> pos[N];
bool dk(pii A,pii B)
{
    if(A.se==B.se) return A.fi<B.fi;
    return A.se<B.se;
}
main()
{
    //freopen("atcoderA.inp","r",stdin);
    ios_base::sync_with_stdio(false);
    memset(ans,-1,sizeof ans);
    memset(dd,-1,sizeof dd);
    cin>>H>>W>>K;
    forinc(i,1,H)
    forinc(j,1,W)
    {
        char x;
        cin>>x;
        a[i][j]=(x=='#');
        if(a[i][j])
        {
            pos[++cnt]={i,j};
            fre[i][j]=1;
        }
        if(a[i][j]) dd[j]=1;
        //else dd[j]=0;
    }
    forinc(i,1,W) if(dd[i]!=1) dd[i]=0;
    sort(pos+1,pos+cnt+1,dk);
    forinc(k,1,cnt)
    {
        //  if(k==3) cout<<mau<<" ";
        int i=pos[k].fi,j=pos[k].se;
        int z=mau;
        mau++;
        ans[i][j]=z;
        fordec(p,i-1,1)
        {
            if(fre[p][j]) break;
            if(ans[p][j]==-1) ans[p][j]=z;
           // if(k==3) cout<<ans[p][j]<<" "<<"\n";
            else break;
        }
        forinc(p,i+1,H)
        {
            if(fre[p][j]) break;
            if(ans[p][j]==-1) ans[p][j]=z;
            else break;
        }
    }
    forinc(i,1,H) fordec(j,W-1,1) if(ans[i][j]==-1&&ans[i][j+1]!=-1) ans[i][j]=ans[i][j+1];
    forinc(i,1,H) forinc(j,2,W) if(ans[i][j]==-1&&ans[i][j-1]!=-1) ans[i][j]=ans[i][j-1];
    forinc(i,1,H)
    {
        forinc(j,1,W) cout<<ans[i][j]<<" ";
        cout<<"\n";
    }
}



Measured memory_bytes: 7296
#include <cstdio>
#include <vector>
#include <cstring>
#include <set>
#include <utility>
#include <cmath>
#include <algorithm>
#include <stack>
using namespace std;

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

int r, c, n;
vector<ii> res[4];
inline bool boundary(int x, int y)
{
    return x == 0 || y == 0 || x == r || y == c;
}
inline void push(int x, int y, int id)
{
    if (x == 0)
        res[0].push_back(ii(y, id));
    else if (y == c)
        res[1].push_back(ii(x, id));
    else if (x == r)
        res[2].push_back(ii(-y, id));
    else 
        res[3].push_back(ii(-x, id));
}
int main()
{
    scanf("%d %d %d", &r, &c, &n);
    for (int i = 1; i <= n; ++i)
    {
        int x, y, xx, yy;
        scanf("%d %d %d %d", &x, &y, &xx, &yy);
        if (boundary(x, y) && boundary(xx, yy))
        {
            push(x, y, i);
            push(xx, yy, i);
        }
    }
    for (int i = 0; i < 4; ++i)
        sort(res[i].begin(), res[i].end());
    stack<int> stk;
    for (int i = 0; i < 4; ++i)
    {
        for (int j = 0; j < res[i].size(); ++j)
        {
            int id = res[i][j].second;
            if (!stk.empty() && stk.top() == id)
                stk.pop();
            else
                stk.push(id);
        }
    }
    puts(stk.empty()?"YES":"NO");
}



Measured memory_bytes: 2520
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define n_l '\n'

#ifndef ONLINE_JUDGE
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl
#endif

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define forn(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef double db;
typedef vector<vi> vvi;
const ll mod=1000000007;
const ll N=200005; //check this
int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll powb(ll a,ll b) {ll res=1;a ; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    #ifndef ONLINE_JUDGE
    freopen("inputf.in", "r", stdin);
    freopen("outputf.in", "w", stdout);
    #endif

    int t=1;
    //cin>>t;
    while(t--){
    	int l,r,d;cin>>l>>r>>d;
    	int ans=0;
    	ans=r/d-(l-1)/d;
    	cout<<ans;
    }
}


Measured memory_bytes: 3596
line = Array.new
linef = Array.new
loop do
  num = gets.to_i
  if num == 0
    break
  end
  num.times do |i|
    data = gets.chomp!.split(/\s/)
    data.size.times do |j|
      data[j] = data[j].to_i
    end
    cnt = 0
    data.each do |k|
      cnt = cnt + k
    end
    data.push(cnt)
    line[i] = data
  end
  (num + 1).times do |l|
    cnt = 0
    num.times do |m|
      cnt = cnt + line[m][l]
    end
    linef[l] = cnt
  end
  num.times do |n|
    (num + 1).times do |o|
      if (num + 1) == (o + 1)
        printf("%5d\n",line[n][o])
      else
        printf("%5d",line[n][o])
      end
    end
  end
  (num + 1).times do |p|
    if (num + 1) == (p + 1)
      printf("%5d\n",linef[p])
    else
      printf("%5d",linef[p])
    end
  end
end

Measured memory_bytes: 6136
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }
    bool ok         = true;
    const int dx[4] = {-1, 1, 0, 0};
    const int dy[4] = {0, 0, -1, 1};
    auto inside     = [&](int y, int x) { return 0 <= y && y < h && 0 <= x && x < w; };
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (s[i][j] == '#') {
                int bl = 0;
                for (int k = 0; k < 4; ++k) {
                    int ny = i + dy[k];
                    int nx = j + dx[k];
                    if (inside(ny, nx) && s[ny][nx] == '#')
                        bl++;
                }
                if (bl == 0)
                    ok = false;
            }
        }
    }
    if (ok)
        cout << "Yes"
             << "\n";
    else
        cout << "No"
             << "\n";
    return 0;
}

Measured memory_bytes: 256
import math


class Vector2():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, v):
        return Vector2(self.x+v.x, self.y+v.y)

    def __sub__(self, v):
        return Vector2(self.x-v.x, self.y-v.y)

    def __mul__(self, v):
        return Vector2(self.x*v, self.y*v)

    def __truediv__(self, v):
        return Vector2(self.x/v, self.y/v)

    def __abs__(self):
        return math.sqrt(float(self.x*self.x+self.y*self.y))

    def dot(self, v):
        return self.x*v.x+self.y*v.y

    def cross(self, v):
        return self.x*v.y-self.y*v.x

    def norm(self):
        d = abs(self)
        return Vector2(self.x/d, self.y/d)


n = int(input())
for i in range(n):
    x0, y0, x1, y1, x2, y2, x3, y3 = map(int, input().split())
    v1 = Vector2(x1-x0, y1-y0).norm()
    v2 = Vector2(x3-x2, y3-y2).norm()
    d = v1.dot(v2)
    c = v1.cross(v2)
    if math.isclose(d, 0.0):
        print("1")
    elif math.isclose(c, 0.0):
        print("2")
    else:
        print("0")



Measured memory_bytes: 5700
#include<cstdio>
#include<algorithm>
#define MN 200001
#define lp p<<1
#define rp p<<1|1
using namespace std;

int read_p,read_ca;
inline int read(){
    read_p=0;read_ca=getchar();
    while(read_ca<'0'||read_ca>'9') read_ca=getchar();
    while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
    return read_p;
}
const int MOD=1e9+7;
inline void M(int &x){while(x>=MOD)x-=MOD;}
inline int _M(int x){M(x);return x;}
struct tree{int p,s,c;tree(){c=1;}}t[MN*20];
struct na{int l,r;}w[MN];
struct ma{int x,v;}a[MN];
bool operator < (ma a,ma b){return a.v<b.v;}
bool operator < (na a,na b){return a.l<b.l;}
int n,m,stl[MN][20],str[MN][20];
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
void hb(int p,int c){
	t[p].c=1LL*t[p].c*c%MOD;
	t[p].s=1LL*t[p].s*c%MOD;
}
void pd(int p){if (t[p].c!=1) hb(lp,t[p].c),hb(rp,t[p].c),t[p].c=1;}
void gx(int p){M(t[p].s=t[lp].s+t[rp].s);}
void add(int p,int l,int r,int k,int v){
	if (l==r){
		M(t[p].s+=v);
		return;
	}
	if (l!=r) pd(p);
	int mid=l+r>>1;
	if (k<=mid) add(lp,l,mid,k,v);else add(rp,mid+1,r,k,v);
	gx(p);
}
int ask(int p,int l,int r,int L,int R){
	if (l>=L&&r<=R) return t[p].s;
	pd(p);
	int mid=l+r>>1;
	if (R<=mid) return ask(lp,l,mid,L,R);else
	if (L>mid) return ask(rp,mid+1,r,L,R);else
	return _M(ask(lp,l,mid,L,R)+ask(rp,mid+1,r,L,R));
}
void cc(int p,int l,int r,int k){
	if (l>=k) hb(p,2);else{
		pd(p);
		int mid=l+r>>1;
		if (k>mid) cc(rp,mid+1,r,k);else cc(lp,l,mid,k),cc(rp,mid+1,r,k);
		gx(p);
	}
}
int main(){
	int i,j;
	n=read();
	for (i=1;i<=n;i++) a[i].x=read(),a[i].v=read();
	sort(a+1,a+1+n);
	for (i=1;i<=n;i++) for (stl[i][0]=a[i].x,j=1;j<20&&(i>>j);j++) stl[i][j]=min(stl[i][j-1],stl[i-(1<<(j-1))][j-1]);
	for (i=n;i>=1;i--) for (str[i][0]=a[i].x,j=1;j<20&&i+(1<<j)-1<=n;j++) str[i][j]=max(str[i][j-1],str[i+(1<<(j-1))][j-1]);
	
	for (i=1;i<=n;i++){
		int l=1,r=n;
		for (j=19;j>=0;j--) if (str[l][j]&&str[l][j]<a[i].x) l+=1<<j;
		for (j=19;j>=0;j--) if (stl[r][j]&&stl[r][j]>a[i].x) r-=1<<j;
		w[i].l=l;w[i].r=r;
	}
	
	sort(w+1,w+1+n);
	add(1,0,n,0,1);
	for (i=1;i<=n;i++){
		cc(1,0,n,w[i].r);
		//printf("%d %d:%d %d %d %d\n",w[i].l,w[i].r,ask(1,0,n,0,0),ask(1,0,n,1,1),ask(1,0,n,2,2),ask(1,0,n,3,3));
		add(1,0,n,w[i].r,ask(1,0,n,w[i].l-1,w[i].r-1));
		//printf("%d %d:%d %d %d %d\n",w[i].l,w[i].r,ask(1,0,n,0,0),ask(1,0,n,1,1),ask(1,0,n,2,2),ask(1,0,n,3,3));
	}
	printf("%d\n",ask(1,0,n,n,n));
}

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

N = int(input())
SUM,DIF = [],[]
for _ in range(N):
  x,y = map(int, input().split())
  SUM.append(x+y)
  DIF.append(x-y)
  
SUM.sort()
DIF.sort()

print(max(abs(SUM[0] - SUM[-1]), abs(DIF[0] - DIF[-1])))

Measured memory_bytes: 25820
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 1000000007
#define eps 1e-8
int n,m,tot=0,val[100100],rob[100100],hol[100100],tot1=0;
ll f[100100];
pii p[100100];

struct fenwick_tree{
	int a[100100];
	
	void modify(int x,int p)
	{
		for (int i=p;i<=tot;i+=lowbit(i)) a[i]=(a[i]+x)%maxd;
	}
	
	int query(int p)
	{
		int ans=0;
		for (int i=p;i;i-=lowbit(i)) ans=(ans+a[i])%maxd;
		return ans;
	}
}tr;

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

bool cmp(pii p,pii q) {return ((p.fir<q.fir) || ((p.fir==q.fir) && (p.sec>q.sec)));}

int main()
{
	n=read();m=read();
	rep(i,1,n) rob[i]=read();
	rep(i,1,m) hol[i]=read();
	rep(i,1,n)
	{
		if ((rob[i]<=hol[1]) || (rob[i]>=hol[m])) continue;
		int pos=lower_bound(hol+1,hol+1+m,rob[i])-hol;
		if (hol[pos]==rob[i]) continue;
		p[++tot1]=mp(rob[i]-hol[pos-1],hol[pos]-rob[i]);
		val[++tot]=hol[pos]-rob[i];
	}
	//rep(i,1,n) cout << p[i].fir << " " << p[i].sec << endl;
	sort(val+1,val+1+tot);
	tot=unique(val+1,val+1+tot)-val-1;
	rep(i,1,tot1) p[i].sec=lower_bound(val+1,val+1+tot,p[i].sec)-val;
	sort(p+1,p+1+tot1,cmp);
	tot1=unique(p+1,p+1+tot1)-p-1;
	//cout << endl;
	//rep(i,1,tot1) cout << p[i].fir << " " << p[i].sec << endl;
	rep(i,1,tot1)
	{
		f[i]=tr.query(p[i].sec-1)+1;
		tr.modify(f[i],p[i].sec);
	}
	//rep(i,1,tot1) cout << f[i] << " ";cout << endl;
	ll ans=1;
	rep(i,1,tot1) ans=(ans+f[i])%maxd;
	printf("%lld",ans);
	return 0;
}
		


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

bool s(vector<ll> a,vector<ll> b){
        ll sa = 0,sb = 0;
        for(ll p:a) sa += p;
        for(ll p:b) sb += p;
        return sa > sb;
}        


int main() {
        int n,m;
        ll ans = 0;
        cin >> n >> m;
        vector<vector<ll>> xyz(n,vector<ll>(3,0));
        rep(i,n){
                 ll a,b,c;
                cin >> a >> b >> c;
                xyz.at(i).at(0) = a;
                xyz.at(i).at(1) = b;
                xyz.at(i).at(2) = c;
        }
        
        
        
        rep(i,pow(2,3)){
                vector<vector<ll>> now = xyz;
                rep(j,3){
                         if(i >> j & 1 ){
                                         rep(k,n){
                                                  now.at(k).at(j) *= -1;
                                }
                        }
                }
                sort(now.begin(),now.end(),s);
                //rep(i,n) cout << now.at(i).at(0) << " "<< now.at(i).at(1) << " "<< now.at(i).at(2) << endl;
                ll p = 0;
                rep(j,m){
                         p += now.at(j).at(0) + now.at(j).at(1) + now.at(j).at(2);
                }
                ans = max(ans,p);      
        }
        
        cout << ans  << endl;
        
        return 0;
}



Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();
		String rs = String.valueOf(s);
		StringBuffer sb = new StringBuffer(rs);
		String asdf = sb.reverse().toString();
		char[] asdf2 = asdf.toCharArray();
		int wa = 0;
		int num = rs.length();
		for (int i = 0; i < num; i++) {
			if (s[i] != asdf2[i]) {
				wa++;
			}
		}
		if(wa%2==0) {
			wa=wa/2;
		}
		System.out.println(wa);
	}
}


Measured memory_bytes: 23764
#include<algorithm>
#include<cstdio>
#include<functional>
#include<iostream>
#include<cfloat>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<time.h>
#include<vector>
using namespace std;
int main()
{
	int x,y,a;
	cin >> x >> y;
	a=x*y;
	if (a%2==0) cout << "Even" << endl;
	else        cout << "Odd" << endl;
	system("pause");
	return 0;
}

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

int main() {

 int A1,A2,A3;
 cin >> A1 >> A2 >> A3;

 if (A1 + A2 + A3 >= 22) {
 cout << "bust" << endl;
 }

 if (A1 + A2 + A3 <= 21) {
 cout << "win" << endl;
 }

 }


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main(){
        double x1,y1,x2,y2;
        cin >> x1 >> y1 >> x2 >> y2; 
        cout << setprecision(20);
        cout << pow( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ,0.5) << endl;

return 0;
}

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

int main(){
  string a;
  int ans = 0;
  cin >> a;
  int a_len = a.size();
  for(int i = 0; i < a_len; i++){
    if(a[i] == '1'){
      ans++;
    }else{
      continue;
    }
  }
  cout << ans << endl;
}


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

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2-(y2-y1) << " " << y2+(x2-x1) << " " << x1-(y2-y1) << " " << y1+(x2-x1) << endl;
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n); 0<=i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);

int main(void){
    long double A;
    long double B;
    cin >> A >> B;

    long double result = A*B;

    cout << (ll)result << endl;
    
    return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <string>
#include <tuple>
#include <cmath>
 
using namespace std;
typedef long long ll;

int N;
int T[100001];
int X[100001];
int Y[100001];

bool ok() {
    for (int i = 0; i < N; i ++) {
        int t = T[i + 1] - T[i];
        int dx = X[i + 1] - X[i];
        int dy = Y[i + 1] - Y[i];
        int dist = abs(dx) + abs(dy);
        int diff = t - dist;
        if (!(diff >= 0 && diff % 2 == 0)) {
            return false;
        }
    }
    return true;
}

signed main() {
    cin >> N;
    T[0] = 0;
    X[0] = 0;
    Y[0] = 0;
    for (int i = 0; i < N; i ++) {
        cin >> T[i + 1] >> X[i + 1] >> Y[i + 1];
    }
    cout << (ok() ? "Yes" : "No") << endl;
    return 0;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

int main()
{
  fastio;
  int a; cin >> a;
  cout << a + a * a + a * a * a;
  return 0;
}

Measured memory_bytes: 3640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int[] b = new int[n];
    for (int i=0;i<n;i++){
      a[i] = sc.nextInt();
    }
    for (int i=0;i<n;i++){
      b[i] = sc.nextInt();
    }
    sc.close();
    long total = 0;
    long m = 0;
    int pc = 0;
    int ans = 0;
    int d = 0;
    List<Integer> plist = new ArrayList<>();
    for (int i=0;i<n;i++){
      d = a[i] - b[i];
      total += d;
      if (d > 0){
        pc++;
        plist.add(d);
      }else if (d < 0){
        m += d;
        ans++;
      }
    }
    if (total < 0){
      System.out.println(-1);
    }else{
      Collections.sort(plist, Collections.reverseOrder());
      for (int i:plist){
        if (m>=0) break;
        m += i;
        ans++;
      }
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 75252
#include <bits/stdc++.h>
#define PI 3.14159
using namespace std;


int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	
	int tmp;
	for(int i=0; i<m; ++i) {
		scanf("%d", &tmp);
		
		n -= tmp;
	}
	
	if(n < 0)
		printf("-1\n");
	else
		printf("%d\n", n);
	
	return 0;
}


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

int main() {
  const int N_MAX = 1000000000;
  const int N_MIN = -1000000000;

  int N;
  cin >> N;

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

  string ans = "";

  while (N != 0) {
#ifdef DEBUG
    cout << "N=" << N << ", N/2=" << N / 2 << "," << N % 2 << ", ans=" << ans
         << endl;
#endif
    ans += N % 2 == 0 ? "0" : "1";
    N = (N - abs(N % 2)) / -2;  // 1bit shift
  }

  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
dp = [0] * 31
ans = []

for i in a:
    num = format(i, 'b').zfill(31)
    for j in range(31):
        if num[j] == '1':
            dp[j] += 1

for i in a:
    x = 0
    num = format(i , 'b').zfill(31)
    for j in range(31):
        if int(dp[j] - int(num[j])) % 2 == 0:
            continue
        elif int(dp[j] - int(num[j])) % 2 == 1:
            x += 2 ** (30 - j)
    ans.append(x)

for i in ans:
    print(i, end=' ')

Measured memory_bytes: 101640
#include <iostream>
#include <vector>
#include <algorithm>

int main(void) {
    int N;
    int sum = 0;
    std::vector<int> W;

    std::cin >> N;
    for(int i = 0; i < N; i++) {
        int w;
        std::cin >> w;
        W.push_back(w);
        sum += w;
    }

    int csum = 0;
    int pos = 0;
    for(; pos < N; pos++) {
        csum += W[pos];
        sum -= W[pos];
        if(csum > sum)
            break;
    }

    int diff = csum - sum;
    int another = -(diff - W[pos] * 2);
    diff = diff > another ? another : diff;
    std::cout << diff << std::endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");

		int N = Integer.parseInt(Ws[0]);
		int M = Integer.parseInt(Ws[1]);

		String ans;
		if(N ==M){
			ans="Yes";
		}else{
			ans="No";
		}
		System.out.println(ans);



	}


}


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

const int INF = 1000000;
const int di[4] = {0, 1, 0, -1};
const int dj[4] = {1, 0, -1, 0};
int h, w;
char grid[1100][1100];
int d[1100][1100];
vector<P> st(0);

int bfs(){
  queue<P> que;
  for(P x : st){
    que.push(x);
    d[x.first][x.second] = 0;
  }
  int cnt = 0;
  while(que.size()){
    P p = que.front(); que.pop();
    rep(i, 4){
      int ni = p.first + di[i], nj = p.second + dj[i];
     // cerr << ni << " "<< nj << endl;
      if(0 <= ni && 0 <= nj && ni < h && nj < w && grid[ni][nj] != '#'){
        grid[ni][nj] = '#';
        //cerr << ni << " "<< nj << endl;
        que.push(P(ni, nj));
        d[ni][nj] = d[p.first][p.second] + 1;
      }
    }
    /*
    rep(i, h){
      rep(j, w){
        cerr << grid[i][j];
      }
      cerr << endl;
    }
    cerr << endl;
    */
  }
  int ret = -1;
  rep(i, h){
    rep(j, w){
      ret = max(ret, d[i][j]);
    }
  }
  return ret;
}
int main(){
  cin >> h >> w;
  rep(i, h){
    rep(j, w){
      cin >> grid[i][j];
      if(grid[i][j] == '#'){
        st.push_back(P(i, j));
      }
      d[i][j] = -1;
    }
  }
  cout << bfs() << endl;
  return 0;
}


Measured memory_bytes: 21736
N = int(input())
R = []

for i in range(N):
    s, p = input().split()
    temp = [i + 1, s, int(p)]
    R.append(temp)

R_sorted = sorted(R, key=lambda x: x[1])

st = 0

for i in range(1, N):
    if R_sorted[i - 1][1] != R_sorted[i][1]:
        R_sorted[st:i] = sorted(R_sorted[st:i], key=lambda x: x[2], reverse=True)
        st = i
    if i == N - 1:
        R_sorted[st:N] = sorted(R_sorted[st:N], key=lambda x: x[2], reverse=True)

for i in range(N):
    print(R_sorted[i][0])


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

namespace AtCoderCs
{
    class Program
    {
        static void Main()
        {

            var str = int.Parse(Console.ReadLine());
            int Result = (str / 500) * 1000 + ((str % 500) / 5) * 5;
            Console.WriteLine(Result);

        }

    }
}


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

using namespace std;

template <typename T>
void debug_out(T t) {
  cerr << t;
}

template <typename A, typename B>
void debug_out(pair<A, B> u) {
  cerr << "(" << u.first << " " << u.second << ")";
}

template <typename T>
void debug_out(vector<T> t) {
  int sz = t.size();
  for(int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if(i != sz - 1) cerr << ", ";
  }
}

template <typename T>
void debug_out(vector<vector<T>> t) {
  int sz = t.size();
  for(int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if(i != sz - 1) cerr << endl;
  }
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__), cerr << endl;
#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n, m;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  vector<set<int>> g(n);
  range(i, 0, m) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    g[u].insert(v);
    g[v].insert(u);
  }
  if(m & 1) {
    cout << -1;
    return 0;
  }
  vector<int> par(n, -1);
  vector<set<int>> to(n);
  vector<int> was(n);
  vector<int> dep(n);
  set<pair<int, int>> cur;
  function<void(int, int)> dfs = [&](int v, int p) {
    par[v] = p;
    was[v] = 1;
    if(~p) dep[v] = dep[p] + 1;
    for(int u : g[v]) {
      if(was[u]) continue;
      to[v].insert(u);
      dfs(u, v);
    }
  };
  dfs(0, -1);
  range(i, 0, n) cur.insert(make_pair(-dep[i], i));
  auto cut = [&](int u, int v) {
    g[u].erase(v);
    g[v].erase(u);
    if(u != par[v] && v != par[u]) return;
    if(v == par[u]) swap(u, v);
    par[v] = -1;
    to[u].erase(v);
    cur.erase(make_pair(-dep[v], v));
    dep[v] = 0;
  };
  auto link = [&](int v) {
    if(g[v].empty()) return;
    int u = *g[v].begin();
    par[v] = u;
    to[u].insert(v);
    dep[v] = dep[u] + 1;
    cur.insert(make_pair(-dep[v], v));
  };
  int cnt = 0;
  auto go = [&](int x, int y, int z) {
    cnt += 2;
    cout << y + 1 << " " << x + 1 << endl;
    cout << y + 1 << " " << z + 1 << endl;
  };
  while(cnt < m) {
    int u = cur.begin()->second;
    int v = par[u];
    assert(~v);
    int z = par[v];
    if(to[v].size() > 1) {
      for(int a : to[v]) if(a != u) {
        z = a;
        break;
      }
    }
    assert(~z);
    if(z == par[v]) {
      go(u, v, z);
      cut(u, v); cut(v, z);
      link(v); link(u);
    } else if(g[u].find(z) != g[u].end()) {
      go(u, z, v);
      cut(u, z);
      cut(z, v);
      link(z);
    } else {
      go(u, v, z);
      cut(u, v); cut(z, v);
      link(u); link(z);
    }
  }
  return 0;
}


Measured memory_bytes: 38784
import numpy as np
ABC  =list(map(int, input().split()))
orders = [[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0],  [2, 0, 1], [2, 1, 0]]
max_value = 0
for order in orders:
    a, b, c = order
    max_value = max(max_value,max((ABC[a] * 10 + ABC[b]) + ABC[c], ABC[a] + (ABC[b] * 10 + ABC[c])))
print(max_value)

Measured memory_bytes: 21364
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,x,n) for(int i=x;i<n;i++)
#define breps(i,x,n) for(int i=x;i>=n;i--)
#define exrep(x,vec) for(auto&& x : vec);
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

/**
* ------------- ここからコード -------------
*/

int main(void) {

	ll a, b, c, d, n, m;
	ll ans=0;
	string s, t, u;


	cin >> s;
	if (s.find("RRR") != string::npos) ans = 3;
	else if (s.find("RR") != string::npos) ans = 2;
	else if (s.find("R") != string::npos) ans = 1;



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


Measured memory_bytes: 3620
#include <stdio.h>
int main(){
    char S;
    int l;
    l=0;
    while(1){
        int a;
        a=scanf("%c",&S);
        if(a==EOF){
            break;
        }
        if(S=='x'){
            l=l+1;
        }
    }
    if(l<=7){
        printf("YES");
    }else{
        printf("NO");
    }
}

Measured memory_bytes: 128
input()
inputs = map(int, input().split(" "))

is_denied = False
for i in inputs:
  if i % 2 ==0 and ( i % 3 != 0 and i % 5 != 0):
      is_denied = True
      
if is_denied:
  print("DENIED")
else:
  print("APPROVED")




Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  if (s[s.length() - 1] == 's') cout << s + "es";
  else cout << s + 's';
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<bitset>
#include<cmath>
using namespace std;
#define INF 100000000

int change_to_int(vector<bool> v,int n){
  int c=0;
  for(int i=0;i<n;i++){
    if(v[i])c+=pow(2,i);
  }
  return c;
}

vector<bool> change_to_list(int k,int n){
  vector<bool> c(n);
  for(int i=0;i<n;i++){
    if(k%2==1){c[i]=true;}
    k=ceil(k/2);
  }
  return c;
}

int make_newint(vector<bool> a,vector<bool> b,int n){
  int c=0;
  for(int i=0;i<n;i++){
    if(a[i] or b[i])c+=pow(2,i);
  }
  return c;
}


int main(){
  int n,m;cin >> n >> m;
  vector<int> a(m);
  int x=pow(2,n);
  //m個の鍵それぞれが開けられるところ
  vector< vector<bool> > b(m,vector<bool>(n,false));
  vector< vector<bool> > y(x,vector<bool>(n));
  for(int i=0;i<x;i++){
    y[i]=change_to_list(i,n);
  }
  vector<int> dp(x,INF);
  for(int i=0;i<m;i++){
    int k;
    cin >> a[i] >> k;
    for(int j=0;j<k;j++){
      int h;cin >>h;
      b[i][h-1]=true;
    }
  }

  for(int i=0;i<m;i++){
    for(int j=0;j<x;j++){
      if(j==0){
        int k=change_to_int(b[i],n);
        dp[k]=min(dp[k],a[i]);
      }else if(dp[j]!=INF){
        int k=make_newint(y[j],b[i],n);
        dp[k]=min(dp[k],dp[j]+a[i]);
      }
    }
  }
  if(dp[x-1]==INF) cout << -1 << endl;
  else cout << dp[x-1] << endl;
}


Measured memory_bytes: 640
import sys


class Node(object):
    def __init__(self, key=None, parent=None):
        self.key = key
        self.parent = parent
        self.left = None
        self.right = None

    def __str__(self):
        return "Not implemented yet."

    def __repr__(self):
        return self.__str__()


def insert(key, node):
    if key < node.key:
        if node.left is None:
            left_node = Node(key, node)
            node.left = left_node
        else:
            insert(key, node.left)
    else:
        if node.right is None:
            right_node = Node(key, node)
            node.right = right_node
        else:
            insert(key, node.right)


def find(key, node):
    if key == node.key:
        return True
    elif key < node.key:
        if node.left is None:
            return False
        else:
            return find(key, node.left)
    else:
        if node.right is None:
            return False
        else:
            return find(key, node.right)


def print_preorder(node):
    print(" %d" % node.key, end="")
    if node.left is not None:
        print_preorder(node.left)
    if node.right is not None:
        print_preorder(node.right)


def print_inorder(node):
    if node.left is not None:
        print_inorder(node.left)
    print(" %d" % node.key, end="")
    if node.right is not None:
        print_inorder(node.right)


def main():
    lines = sys.stdin.readlines()
    root = Node()

    for order in lines[1:]:
        if order.startswith("insert"):
            _, key = order.strip().split(" ")
            key = int(key)
            if root.key is None:
                root.key = key
            else:
                insert(key, root)
        elif order.startswith("find"):
            _, key = order.strip().split(" ")
            fild_result = "yes" if find(int(key), root) else "no"
            print(fild_result)
        elif order.startswith("print"):
            print_inorder(root)
            print("")
            print_preorder(root)
            print("")

if __name__ == "__main__":
    main()

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

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0;i<n;i++) cin >> d.at(i);
  int t;
  t=(n*(n-1))/2;
  int q=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      q+=d.at(i)*d.at(j);
    }
  }
  cout << q << endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
double eps=1e-10;
double pi=3.1415926535897932;
double add(double a,double b){
  if(abs(a+b)<eps*(abs(a)+abs(b)))return 0;
  return a+b;
}
struct P{
  double x,y;
  P() {}
  P(double x,double y):x(x),y(y){
  }
  P operator + (P p){
    return P(add(x,p.x),add(y,p.y));
  }
  P operator - (P p){
    return P(add(x,-p.x),add(y,-p.y));
  }
  P operator * (double d){
    return P(x*d,y*d);
  }
  double dot(P p){
    return add(x*p.x,y*p.y);
  }
  double det(P p){
    return add(x*p.y,-y*p.x);
  }
};
bool on_seg(P p1,P p2,P q){
  return (p1-q).det(p2-q)==0&&(p1-q).dot(p2-q)<=0;
}
P intersection(P p1,P p2,P q1,P q2){
  return p1+(p2-p1)*((q2-q1).det(q1-p1)/(q2-q1).det(p2-p1));
}
bool cmp_x(const pair<P,int>& p,const pair<P,int>& q){
  P pp=p.first,qq=q.first;
  if(pp.x!=qq.x)return pp.x<qq.x;
  return pp.y<qq.y;
}
vector<pair<P,int>> convex_hull(pair<P,int>* ps,int n){
  sort(ps,ps+n,cmp_x);
  int k=0;
  vector<pair<P,int>> qs(n*2);
  for(int i=0;i<n;i++){
    while(k>1&&(qs[k-1].first-qs[k-2].first).det(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&&(qs[k-1].first-qs[k-2].first).det(ps[i].first-qs[k-1].first)<=0)k--;
    qs[k++]=ps[i];
  }
  qs.resize(k-1);
  return qs;
}
double nolum(P p){
  return pow(p.dot(p),0.5);
}
double kaku(P p,P q){
  double k=p.dot(q)/(nolum(p)*nolum(q));
  if(abs(abs(k)-1)<eps)k=k/k;
  return acos(k);
}
int main(){
  int n;
  double x[100],y[100];
  cin>>n;
  pair<P,int> ps[n];
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
    P o;
    o.x=x[i];
    o.y=y[i];
    ps[i]=make_pair(o,i);   
  }
  double ans[n];fill(ans,ans+n,0.0);
  vector<pair<P,int>> qs=convex_hull(ps,n);
  for(int i=0;i<qs.size();i++){
    int s=(i-1+qs.size())%qs.size(),t=(i+1)%qs.size();
    int num=qs[i].second;
    //cout<<num<<endl;
    //cout<<qs[s].first.x<<" "<<qs[i].first.x<<" "<<qs[t].first.x<<endl;
    //cout<<qs[s].first.y<<" "<<qs[i].first.y<<" "<<qs[t].first.y<<endl;
    double si=kaku(qs[s].first-qs[i].first,qs[t].first-qs[i].first);
    
    ans[num]=0.5-si/(2*pi);
  }
  for(int i=0;i<n;i++){
    cout<<fixed<<setprecision(9)<<ans[i]<<endl;
  }
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
const int N = 2e5 + 5;
vector<vector<int>>v;
int par[N];
void bfs(){
    queue<pair<int, ll>>q;
    bool vis[N] = {};
    q.push({1, par[1]});
    vis[1] = true;
    while(q.size()){
        int numb = q.front().first;
        ll cost = q.front().second;
        q.pop();
        for(int i = 0; i < v[numb].size(); i++){
            if(vis[v[numb][i]]) continue;
            vis[v[numb][i]] = true;
            par[v[numb][i]] += cost;
            q.push({v[numb][i], par[v[numb][i]]});
        }
    }
}
int main()
{
    Hello
    int n, q;
    cin >> n >> q;
    v.resize(n + 5);
    for(int i = 1, a, b; i < n; i++){
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i = 0, p, x; i < q; i++){
        cin >> p >> x;
        par[p] += x;
    }
    bfs();
    for(int i = 1; i <= n; i++) cout << par[i] << " ";
    return 0;
}


Measured memory_bytes: 19220
use std::fmt::Debug;
use std::str::FromStr;

pub struct TokenReader {
    reader: std::io::Stdin,
    tokens: Vec<String>,
    index: usize,
}

impl TokenReader {
    pub fn new() -> Self {
        Self {
            reader: std::io::stdin(),
            tokens: Vec::new(),
            index: 0,
        }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index += 1;
        self.tokens[self.index - 1].parse().unwrap()
    }

    pub fn vector<T>(&mut self) -> Vec<T>
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index = self.tokens.len();
        self.tokens.iter().map(|tok| tok.parse().unwrap()).collect()
    }

    pub fn load_next_line(&mut self) {
        let mut line = String::new();
        self.reader.read_line(&mut line).unwrap();

        self.tokens = line
            .split_whitespace()
            .map(String::from)
            .collect();
        self.index = 0;
    }
}

type Graph = Vec<Vec<usize>>;

fn dfs(graph: &Graph, node: usize, used: &mut Vec<bool>) {
    used[node] = true;
    for i in 0..graph[node].len() {
        if !used[graph[node][i]] {
            dfs(graph, graph[node][i], used);
        }
    }
}

fn solve(graph: &Graph) -> i32 {
    let mut used = vec![false; graph.len()];
    let mut comps = 0;

    for i in 0..graph.len() {
        if !used[i] {
            comps += 1;
            dfs(graph, i, &mut used);
        }
    }
    comps - 1
}

fn main() {
    let mut reader = TokenReader::new();
    let nodes = reader.next();
    let edges = reader.next();

    let mut graph = vec![vec![]; nodes];
    for _ in 0..edges {
        let a = reader.next::<usize>() - 1;
        let b = reader.next::<usize>() - 1;
        graph[a].push(b);
        graph[b].push(a);
    }

    let res = solve(&graph);
    println!("{}", res);
}


Measured memory_bytes: 9248
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    s = gete()
    t = gete()

    ans = 0
    for i in range(3):
        if s[i] == t[i]: ans += 1

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3436
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <utility>
#include <memory>
#include <sstream>
#include <complex>
#include <cassert>
#include <bitset>
#define rep(i, n) for(int i = 0; i < n; i++)
#define fi first
#define se second
//#include <Windows.h>
//#include "Library.h"
//#include "Math.h"
//#include "Othello.h"
using namespace std;
typedef long long int ll; typedef pair <int, int> P; typedef vector <int> vecint; typedef pair<int, P> P1; typedef pair<ll, P1> P2;
const int inf = 1000000000;
const ll INF = 9000000000000000000;
const double EPS = 10e-9;
int main()
{
	int a, b;
	cin >> a >> b;
	if ((a * b) % 2 == 1) cout << "Odd" << endl;
	else cout << "Even" << endl;
	return 0;
}

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

string a;
int main(void)
{
//    int a,b,c;
//    scanf("%d/%d/%d" ,&a ,&b ,&c);
//    printf("2018/%02d/%02d" ,b,c);

    cin >> a;
    a[3]='8';
    cout << a;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf (int)(1e8)
using namespace std;

using P = pair<int, int>;
struct dat {
  P p;
  int cost;
  dat(P _p = P(0, 0), int c = 0) : p(_p), cost(c) {}
};

int h, w;
P st, go;
vector<string> s;
vector<vector<int>> dist;
int d[4] = {0, 1, 0, -1};

int solve();
bool isvalid(P now) {
  return now.first >= 0 && now.first < h && now.second >= 0 && now.second < w &&
         s[now.first][now.second] == '.';
}

int main() {
  cin >> h >> w >> st.first >> st.second >> go.first >> go.second;
  --st.first, --st.second, --go.first, --go.second;
  dist.assign(h, vector<int>(w, inf));
  s.resize(h);
  for (auto& p : s) cin >> p;
  cout << solve() << endl;
  return 0;
}

int solve() {
  auto f = [](dat l, dat r) { return l.cost > r.cost; };
  priority_queue<dat, vector<dat>, decltype(f)> pq(f);
  pq.push(dat(st, 0));
  dist[st.first][st.second] = 0;
  while (pq.size()) {
    auto [p, c] = pq.top();
    int x = p.first, y = p.second;
    pq.pop();
    if (dist[x][y] != c) continue;

    for (int i = 0; i < 4; ++i) {
      int nx = x + d[i], ny = y + d[i ^ 1];
      if (!isvalid(P(nx, ny))) continue;
      if (dist[nx][ny] > c) {
        dist[nx][ny] = c;
        pq.push(dat(P(nx, ny), c));
      }
    }

    for (int i = -2; i <= 2; ++i)
      for (int j = -2; j <= 2; ++j) {
        int nx = x + i, ny = y + j;
        if (!isvalid(P(nx, ny))) continue;
        if (dist[nx][ny] > c + 1) {
          dist[nx][ny] = c + 1;
          pq.push(dat(P(nx, ny), c + 1));
        }
      }
  }
  if (dist[go.first][go.second] == inf) return -1;
  return dist[go.first][go.second];
}

Measured memory_bytes: 9528