akhauriyash/Code-Regression huggingface dataset:
//ALDS1_7_B Binary Trees
#include <stdio.h>
#include <string.h>
struct node{
    int parent,left,right;
}T[30]; 
int H[30],D[30];//H[]高度 D[]深度 
int setHeight(int u){
    int h1=0,h2=0;//2此?写成 int h1,h2;
    if(T[u].left!=-1)
        h1=setHeight(T[u].left)+1;
    if(T[u].right!=-1)
        h2=setHeight(T[u].right)+1;//1此?写成 h2=setHeight(T[u].right+1);
    return H[u]=h1>h2?h1:h2;
}
void setDepth(int u,int d){
    D[u]=d;
    if(T[u].left!=-1)setDepth(T[u].left,d+1);
    if(T[u].right!=-1)setDepth(T[u].right,d+1);
}
void print(int u){
    int deg=0;
    printf("node %d: parent = %d, ",u,T[u].parent);
    printf("sibling = ");
    if(T[u].parent==-1)printf("-1, ");//4 添上改行 就因?少了?句，??程序1个小? 
    else if(T[T[u].parent].left!=-1&&T[T[u].parent].left!=u)
        printf("%d, ",T[T[u].parent].left);
    else if(T[T[u].parent].right!=-1&&T[T[u].parent].right!=u)
        printf("%d, ",T[T[u].parent].right);
    else
        printf("-1, ");
    if(T[u].left!=-1)deg++;
    if(T[u].right!=-1)deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);
    if(T[u].parent==-1)printf("root\n");
    else if(T[u].left==-1&&T[u].right==-1)printf("leaf\n");
    else printf("internal node\n");
}
int main(){
    int n,i,root=0,v,l,r;
    memset(T,-1,sizeof(T));
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d%d",&v,&l,&r);
        if(l!=-1){T[v].left=l,T[l].parent=v;}
        if(r!=-1){T[v].right=r,T[r].parent=v;}
    }
    for(i=0;i<n;i++)
        if(T[i].parent==-1){
            root=i;
            break;
        }
    setHeight(root);
    setDepth(root,0);
    for(i=0;i<n;i++)
        print(i);
    return 0;
}

Measured memory_bytes: 1812
#######################################
n,l = map(int, input().split())

apples = [i+l for i in range(n)]

if (l-1) < 0:
  if (l+n-1) < 0:
    ret = sum(apples[:-1])
  else: #(l+n-1) >= 0:
    ret = sum(apples)
else: #(l-1) >= 0:
  ret = sum(apples[1:])

print(ret)

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 8
#define INF 1000000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int N, A, B, C;
int l[MAX_N];

int dfs(int cur, int a, int b, int c)
{
  if (cur == N) {
    if (min({a, b, c}) > 0) {
      return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    }
    else {
      return INF;
    }
  }
  int ret0 = dfs(cur + 1, a, b, c);
  int ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
  int ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
  int ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;
  return min({ret0, ret1, ret2, ret3});
}

void solve() { cout << dfs(0, 0, 0, 0) << endl; }

int main(void)
{
  cin >> N >> A >> B >> C;
  REP(i, N) cin >> l[i];
  sort(l, l + N);
  solve();
  return 0;
}


Measured memory_bytes: 888
n,q = map(int,input().split())
V = [[] for i in range(n+1)]
for i in range(n-1):
    a,b = map(int,input().split())
    V[a].append(b)
    V[b].append(a)
s = [0]*(n+1)
for j in range(q):
    p,x = map(int,input().split())
    s[p] += x
from collections import deque
q = deque([])
reach = [-1]*(n+1)
q.append(1)
reach[1] = 0
while q:
    x = q.popleft()
    for v in V[x]:
        if reach[v] == -1:
            reach[v] = 0
            s[v] += s[x]
            q.append(v)
for i in range(1,n+1):
    print(s[i],end="")
    print(" ",end="")
print("")

Measured memory_bytes: 54836
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
int read(){
	register int x = 0;
	register char f = 1, ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = !f;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
	return f ? x : -x;
}
#define P 1000000007
int n, k, a[2005], s1, s2;
int main(){
	n = read(), k = read();
	for (register int i = 1; i <= n; ++i) a[i] = read();
	for (register int i = 1; i <= n; ++i)
		for (register int j = i + 1; j <= n; ++j)
			if (a[i] > a[j]) ++s1;
	s1 = 1ll * s1 * k % P;
	for (register int i = 1; i <= n; ++i)
		for (register int j = 1; j <= n; ++j)
			if (a[i] > a[j]) ++s2;
	s2 = (1ll * k * (k - 1) >> 1) % P * s2 % P;
	printf("%d\n", (s1 + s2) % P);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const int M=2e5+5;
int n,now,a[N],v[M],b[N],nex[M],head[N];
void addedges(int x,int y){
	nex[++now]=head[x];
	head[x]=now,v[now]=y;
}
long long dfs(int x,int fa){
	long long res=0,mx=0;
	if(b[x]==1)	return a[x];
	for(int i=head[x];i;i=nex[i])
		if(v[i]!=fa){
			long long k=dfs(v[i],x);
			res+=k,mx=max(mx,k);
		}
	int up=(a[x]*2-res);
	if(up<0||up>a[x]||a[x]<mx){
		puts("NO");
		exit(0);
	}
	return up;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)	scanf("%d",&a[i]);
	if(n==2){
		if(a[1]==a[2])	puts("YES");
		else	puts("NO");
		return 0;
	}
	for(int i=1,x,y;i<n;i++){
		scanf("%d%d",&x,&y);
		addedges(x,y),++b[x];
		addedges(y,x),++b[y];
	}
	for(int i=1;i<=n;i++)
		if(b[i]!=1){
			addedges(0,i);
			if(dfs(0,0)!=-1)	puts("YES");
			else	puts("NO");
			return 0;
		}
	return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    string s;
    ll k;
    cin >> s >> k;
    vector<string> t(0);
    rep0(i, s.size())rep1(j, k)if(i + j <= s.size())t.push_back(s.substr(i,j));
    sort(all(t));
    t.erase(unique(all(t)),t.end());
    pf(t[k - 1]);
    return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

#define MAXN 100000

int v[MAXN + 1], t[MAXN + 1];

int sef(int x) {
    if (t[x] == x) return x;
    else return t[x] = sef(t[x]);
}

int main() {
    int n, m;
    std::cin >> n >> m;

    for (int i = 1; i <= n; i++) {
        std::cin >> v[i];
        t[i] = i;
    }

    for (int i = 1; i <= m; i++) {
        int x, y;
        std::cin >> x >> y;

        t[sef(x)] = sef(y);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++)
        if (sef(i) == sef(v[i]))
            ans++;

    std::cout << ans;

    return 0;
}


Measured memory_bytes: 1024
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

s = gets.chomp.split("").map(&:to_i)
sum = s.inject(:+)

puts sum % 9 == 0 ? "Yes" : "No"


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

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

    vector<int> P(N-1);
    vector<vector<int>> children(N);
    rep(i,0,N-1){
        cin >> P[i];
        --P[i];
        children[P[i]].push_back(i+1);
    }

    vector<int> X(N);
    rep(i,0,N) cin >> X[i];

    vector<int> a(N,inf),b(N,inf);
    function<bool(int)> dfs=[&](int u){
        if(children[u].empty()){
            a[u]=X[u];
            b[u]=0;
            return true;
        }

        for(int v:children[u]) if(!dfs(v)) return false;

        vector<int> dp(X[u]+1,inf);
        if(a[children[u][0]]<=X[u]) dp[a[children[u][0]]]=min(dp[a[children[u][0]]],b[children[u][0]]);
        if(b[children[u][0]]<=X[u]) dp[b[children[u][0]]]=min(dp[b[children[u][0]]],a[children[u][0]]);
        rep(i,1,children[u].size()){
            int v=children[u][i];
            vector<int> next(X[u]+1,inf);
            rep(j,0,X[u]+1){
                if(dp[j]==inf) continue;
                if(j+a[v]<=X[u]) next[j+a[v]]=min(next[j+a[v]],dp[j]+b[v]);
                if(j+b[v]<=X[u]) next[j+b[v]]=min(next[j+b[v]],dp[j]+a[v]);
            }
            dp=next;
        }

        a[u]=X[u];
        rep(i,0,X[u]+1) b[u]=min(b[u],dp[i]);

        if(b[u]==inf) return false;
        return true;
    };

    if(dfs(0)) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

int main(){
  int a, b, c, d, e, f, g, h, i, j, n, m;
  int x=0;
  cin >> n >> m;
 
  for(i=n;i<=m;i++){
    
    a=i/10000;
    b=i/1000-10*a;
    d=(i%100)/10;
    e=i%10;
  
    if(a==e&&b==d){
      x++;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


ll n, ans=0;

void solve()
{
    cin >> n;
    for (ll i=1; i<=n; i++) {
        if (i%3==0||i%5==0) continue;
        else ans+=i;
    }nout(ans);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int a,b[200010],c;
long long sum;
int main(){
	scanf("%d",&a);
	for(int i=1;i<=a;i++){
		scanf("%d",&b[i]);
		b[i]-=i;
	}
	sort(b+1,b+a+1);
	if(a%2==0){
		for(int i=1;i<=a;i++){
			sum+=abs(b[i]-b[a/2]);
		}
		cout<<sum;
	}
	else{
		for(int i=1;i<=a;i++) {
			sum+=abs(b[i]-b[(a+1)/2]);
		}
		cout<<sum;
	}
}
	

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(){
    int n,i,j,b=0,e=0,f=1,t,r=0;
    char s[10000][11];
    char *p;
    scanf("%d",&n);
    for(i=n;i--;){
        t=0;
        scanf("%s",s[i]);
        b+=s[i][0]=='B';
        t+=s[i][0]=='B';
        for(j=2;s[i][j]!='\0';j++);
        e+=s[i][j-1]=='A';
        t+=s[i][j-1]=='A';
        if(t==1)f=0;
        do{
            p=strstr(s[i],"AB");
            if(p!=NULL){*p='C';r++;}
        }while(p!=NULL);
    }
    if(f&&e!=0)b=--e;
    r+=b<e?b:e;
    printf("%d",r);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

ll n, m;

int main()
{
   // freopen("test.in","r",stdin);

    cin >> n >> m;

    if (n == 1 && m == 1) {
        cout << 1;
        return 0;
    }

    if (n == 1 && m > 1) {
        cout << m - 2;
        return 0;
    }

    if (m == 1 && n > 1) {
        cout << n - 2;
        return 0;
    }

    cout << (n - 2) * (m - 2);


    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int values_num = sc.nextInt();
		int[] values = new int[values_num];
		for (int i = 0; i < values_num; i++) {
			values[i] = sc.nextInt();
		}
		int change_counter = bubbleSort(values);
		for(int i = 0; i < values.length; i++) {
			if(i != 0) System.out.print(" ");
			System.out.print(values[i]);
		}
		System.out.print("\n");
		System.out.println(change_counter);
	}
	public static int bubbleSort(int[] values) {
		int change_counter = 0;
		boolean hasRevers = true;
		while(hasRevers) {
			hasRevers = false;
			for (int i = values.length - 1; i > 0; i--) {
				if(values[i] < values[i-1]) {
					int tmp = values[i];
					values[i] = values[i-1];
					values[i-1] = tmp;
					hasRevers = true;
					change_counter++;
				}
			}
		}
		return change_counter;
	}
}


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

int main(){
	int n,k;
	cin >> n >> k;
	int arr[n];
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	vector<int> dp(n,INT_MAX);
	dp[0] = 0;
	// dp[1] = abs(arr[1]-arr[0]);
	// cout << dp[1] << endl;
	for(int i=1;i<n;i++){
		for(int j=1;j<=k;j++){
			if(i-j>=0)
				dp[i] = min(dp[i],abs(arr[i]-arr[i-j])+dp[i-j]);
		// cout << dp[i] << " ";
		}
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////

int main() {
	
	string S;
	cin >> S;
	if (S.size() >= 4 && S.substr(0, 4) == "YAKI") { cout << "Yes"; }
	else { cout << "No"; }

	system("PAUSE");
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
int n, m, c[26]; string s;
int main() {
	cin >> n >> m;
	for(int i = 0; i < n; i++) {
		cin >> s;
		c[s[0] - 65]++;
	}
	int ret = 0;
	while(true) {
		sort(c, c + 26, greater<int>());
		int z = *min_element(c, c + m);
		if(z == 0) break;
		for(int i = 0; i < m; i++) c[i]--;
		ret++;
	}
	cout << ret << endl;
	return 0;
}

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;


ll sum(ll n) {
  ll m=0;
  FOR(i,0,12){
    m+=n%10;
    n/=10;
  }
  return m;
}


ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}


ll lcm(ll a,ll b){
  ll n;
  n=a*b/gcd(a,b);
  return n;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/


signed main() {
  st S,T;
  	ci(S>>T);
  ll a=S.sz;
  bool B=true;
  
  FOR(i,0,a){
	ch c=S[0];
    FOR(j,0,a-1){
      S[j]=S[j+1];
    }
    S[a-1]=c;
    if(S==T){
      co("Yes")
      B=false;
      break;
    }
  }
  if(B){
    co("No")
  }
}

Measured memory_bytes: 256
H,W=map(int,input().split())
result = []
for i in range(H+2):
  if i == 0 or i == H+1:
    result.append(''.join(['#' for _ in range(W+2)])) 
  else:
    word = input()
    result.append('#'+word+'#')
[print(i) for i in result]

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    A=list(map(int,input().split()))
    ans=0
    left=0
    S,X=0,0
    for right in range(N):
        S+=A[right]
        X^=A[right]
        if S==X:
            continue
        else:
            ans+=(right-left)*(right-left+1)//2
            for left in range(left,right):
                S-=A[left]
                X^=A[left]
                if S==X:
                    left+=1
                    break
            ans-=(right-left)*(right-left+1)//2
    right+=1
    ans+=(right-left)*(right-left+1)//2
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 72688
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <string.h>
#include <iomanip>
#include <limits>
using namespace std;

const int MAX_N=10000;
string s;

int main(){
	cin >> s;
	
	cout << (s[0]=='9' or s[1]=='9'?"Yes":"No") << endl;
	return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, a[101010];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		a[i]--;
	}
	
	int ans = 0;
	for(int i = 1; i < n; i++){
		if(a[i] == i && a[i-1] == i-1){
			swap(a[i],a[i-1]);
			ans++;
		}
		if(i+1<n&&a[i] == i && a[i+1] == i+1){
			swap(a[i],a[i+1]);
			ans++;
		}
		if(a[i] == i || a[i-1] == i-1){
			swap(a[i],a[i-1]);
			ans++;
		}
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

int main(int argc, char *argv[]) {
  int N;
  cin >> N;
  for(int i = 0; i <= 25; i++) {
    for(int j = 0; j <= 15; j++) {
      if(4 * i + 7 * j == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
room=[[[0]*10 for i in range(0,3)]for j in range(0,4)]
N=int(input())
for i in range (N):
    a,b,c,d=input().split()
    a,b,c,d=[int(a),int(b),int(c),int(d)]
    room[a-1][b-1][c-1]=room[a-1][b-1][c-1]+d
for i in range(4):
    for j in range(3):
        result=" ".join([str(m) for m in room[i][j]])
        print("",result)
    if i==3:
        break
    print("####################")


Measured memory_bytes: 5604
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

int main(){
  int N;
  cin>>N;
  int x[N];
  for (int i=0;i<N;i++){
    cin>>x[i];
  }
  sort(x,x+N,greater<int>());
  int sougaku=0;
  for (int i=0;i<N;i++){
    if (i==0){
      sougaku+=x[i]/2;
    }
    else{
      sougaku+=x[i];
    }
  }
  cout<<sougaku;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
int main() {
    int h, n;
    cin >> h >> n;
    vector<int> dp(h+1, 1e9);
    dp[0] = 0;
    int i, j, a, b;
    rep(i, n) {
        cin >> a >> b;
        rep(j, h) {
            int end = min(j+a, h);
            dp[end] = min(dp[end], dp[j]+b);
        }
    }
    cout << dp[h] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,K;
    scanf("%lld%lld",&n,&K);
    vector<ll> a(n);
    for(ll& x: a)
        scanf("%lld", &x);
    const int MOD  = 1e9 + 7;   
    vector<vector<ll> > dp1(K+1, vector<ll> (n+1) );
    vector<vector<ll> > dp2(K+1, vector<ll> (n+1) );
    
    dp1[0][0] = 1;
    dp2[0][0] = 1;
    for(ll k = 0; k<= K; k++)
    {
        for(ll i = 1; i<=n; i++)
        {
            // for(int p  = 0; p<=min(a[i-1], k); p++)
            //     dp1[k][i]+= dp1[k-p][i-1];
                int x = k - min(a[i-1], k) -1;
                dp1[k][i] = (dp2[k][i-1] + (MOD - (x>=0 ? dp2[x][i-1] : 0) ))%MOD;
            
                dp2[k][i]= (dp1[k][i] + (k>0 ? dp2[k-1][i]  : 0) )%MOD;
        }
    }
    // for(int i = 0; i<=K; i++)
    // {
    //     for(int j = 1; j<=n; j++)
    //         cout<<dp1[i][j]<<" ";
    //     cout<<"\n";
    // }
    cout<<dp2[K][n]<<"\n";

}

Measured memory_bytes: 164352
N = int(input())
Dl = [list(map(int,input().split())) for i in range(N)]
a = 0


for x in Dl :
    if x[0] == x[1] :
        a+=1

    else :
        if a>= 3 :
            a =3
        else :
            a=0


print("Yes" if a >= 3 else "No") 


Measured memory_bytes: 9164
#![allow(non_snake_case)]
use proconio::input;

fn main() {
    input! {
        S:String,
        T:String,
    }

    // dp[i][j] : S[1..i+1]とT[1..j+1]のLCSの長さ
    // dp[0][j]やdp[i][0]は計算を簡単にするために0とする

    // dp[i][j]としてLCSそのものを持ってしまうと、配列の1マスに入れる文字列の長さは
    // 最大3000なので、配列全体で 3000 * 3000 * 3000となり、メモリオーバーになってしまう
    let mut dp: Vec<Vec<i32>> = Vec::with_capacity(S.len() + 1);
    for _ in 0..S.len() + 1 {
        let mut arr: Vec<i32> = Vec::new();
        arr.resize(T.len() + 1, 0);
        dp.push(arr);
    }

    for s in 1..S.len() + 1 {
        for t in 1..T.len() + 1 {
            dp[s][t] = if &S[s - 1..s] == &T[t - 1..t] {
                // つかう
                // dp[s-1][t-1] + 1
                dp[s - 1][t - 1] + 1
            } else {
                // つかえない
                // MAX(
                // dp[s-1][t]
                // dp[s][t-1]

                std::cmp::max(dp[s - 1][t], dp[s][t - 1])
            }
        }
    }

    // for s in 0..S.len() + 1 {
    //     for t in 0..T.len() + 1 {
    //         print!("{} ", dp[s][t]);
    //     }
    //     println!("");
    // }

    // dp配列を逆に辿って文字列を構成
    let mut rev_ans = String::new();
    let mut rest: i32 = dp[S.len()][T.len()];
    let mut s: i32 = S.len() as i32;
    let mut t: i32 = T.len() as i32;


    while rest > 0 {
        dbg!(&rev_ans);
        dbg!(rest);
        dbg!(s);
        dbg!(t);

        if &S[s as usize - 1..s as usize] == &T[t as usize - 1..t as usize] {
            rev_ans += &S[s as usize - 1..s as usize];
            rest -= 1;
            s -= 1;
            t -= 1;
        } else if s >= 1 && dp[s as usize][t as usize] == dp[s as usize - 1][t as usize] {
            s -= 1;
        } else {
            t -= 1;
        }
    }

    let ans: String = rev_ans.chars().rev().collect::<String>();
    println!("{}", ans);
}


Measured memory_bytes: 40516
import itertools
n,m=map(int,input().split())
es=[set() for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    es[a-1].add(b-1)
    es[b-1].add(a-1)
ans=0
for v in itertools.permutations(range(1,n)):
    u=0
    link=True
    for i in v:
        if i in es[u]:
            u=i
        else:
            link=False
            break
    if link:
        ans+=1
print(ans)

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

// a[i] := i行目で最も手前にある白石の座標
// b[i] := i列目で最も手前にある白石の座標
// となっているが、枠の外になったときだけ更新するようにすると、
// 同じiについて高々1回しか更新されない

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

    vector<int> a(N + 1), b(N + 1);
    for (int i = 1; i <= N; ++i) a[i] = b[i] = N;

    ll black = ll(N - 2) * (N - 2);

    int H = N, W = N;

    while (Q--) {
        int t, x;
        cin >> t >> x;
        if (t == 1) {
            if (x < W) {
                for (int i = x; i < W; ++i) {
                    b[i] = H;
                }
                W = x;
            }
            black -= b[x] - 2;
        } else {
            if (x < H) {
                for (int i = x; i < H; ++i) {
                    a[i] = W;
                }
                H = x;
            }
            black -= a[x] - 2;
        }
    }
    cout << black << endl;
    return 0;
}

Measured memory_bytes: 4760
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstring>
#include<algorithm>
using namespace std;

int main(){
  char s[100001];
  scanf("%s",s);
  int l = strlen(s);
  int black = 0,white = 0;
  for(int i=0;i<l;i++){
    if(i==0){
      if(s[i]=='B') black++;
      else white++;
    }else{
      if(s[i]!=s[i-1]){
        if(s[i]=='B') black++;
        else white++;
      }
    }
  }
  printf("%d\n",black+white-1);
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    bool f;
    if(s[0] == s[s.size() - 1]){
        if(s.size() % 2) f = false;
        else f = true;
    }else{
        if(s.size() % 2) f = true;
        else f = false;
    }
    if(f) cout << "First" << endl;
    else cout << "Second" << endl;

    return 0;
}

Measured memory_bytes: 512
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<set>
#include<vector>
using namespace std;
#define PI acos(-1.0)
#define pppp cout<<endl;
#define EPS 1e-8
#define LL long long
#define ULL unsigned long long     //1844674407370955161
#define INT_INF 0x3f3f3f3f      //1061109567
#define LL_INF 0x3f3f3f3f3f3f3f3f //4557430888798830399
// ios::sync_with_stdio(false);
// 那么cin, 就不能跟C的 scanf，sscanf, getchar, fgets之类的一起使用了。
const int dr[]= {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[]= {-1, 1, 0, 0, -1, 1, -1, 1};
int read()//输入外挂
{
    int ret=0, flag=0;
    char ch;
    if((ch=getchar())=='-')
        flag=1;
    else if(ch>='0'&&ch<='9')
        ret = ch - '0';
    while((ch=getchar())>='0'&&ch<='9')
        ret=ret*10+(ch-'0');
    return flag ? -ret : ret;
}
int main()
{
    LL n;
    scanf("%lld",&n);
    LL sum=0;
    sum=n/11*2;
    if(n%11<=6&&n%11!=0)
        sum++;
    else if(n%11>6)
        sum+=2;
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define fo(i,n) for(long long i=0;i<n;i++)
#define ll long long int
#define inf 999999999999999999
#define pb push_back
#define fi first
#define se second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define pi pair<ll,ll>
#define mp make_pair
#define MOD 1000000007
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
//freopen("explicit.in", "r", stdin);
//freopen("explicit.out", "w", stdout);
 
void SieveOfEratosthenes() 
{ 
    bool prime[10000001];
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=10000000; p++) 
    { 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (ll i=p*p; i<=10000000; i += p) {
                prime[i] = false; 
            }
        } 
    }  
} 
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
	if(b%a==0)
	   return a;
	return gcd(b%a,a);
}
ll nCrModpDP(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C));   
    C[0] = 1;
    for (ll i = 1; i <= n; i++) 
    {
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 
ll nCrModp(ll n, ll r, ll p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
   ll ni = n%p, ri = r%p; 
  
   return (nCrModp(n/p, r/p, p) * 
           nCrModpDP(ni, ri, p)) % p; 
} 
int32_t main() 
{
    fio
	ll j,i,n,t,l,w,ch,cw,dh,dw,y,r,c,h,k,m,maxi,d,x;
	cin>>h>>w;
	cin>>ch>>cw;
	cin>>dh>>dw;
	// cout<<ch<<cw<<dh<<dw<<endl;
	string g[h+1];
	char s[h+1][w+1];
	for(j=1;j<=h;j++)
	{
		cin>>g[j];
		for(i=0;i<w;i++)
		{
			s[j][i+1]=g[j][i];
		}
	}
	bool vis[h+2][w+2];
	ll dp[h+2][w+2];
	for(i=1;i<=h+1;i++)
	{
		for(j=1;j<=w+1;j++)
		{
			dp[i][j]=inf;
		}
	}
	memset(vis,false,sizeof(vis));

	priority_queue <pair<ll,pair<ll,ll>>> q;
	q.push({-0,{-ch,-cw}});
	dp[ch][cw]=0;
	ll ans=inf;
	while(!q.empty())
	{
		x=-q.top().second.first;
		y=-q.top().second.second;

		d=-q.top().first;
		// cout<<x<<y<<dp[x+1][y]<<endl;
		
		q.pop();
		if(x==dh && y==dw)
		{
           break;
		}
		if(vis[x][y])
			continue;
		vis[x][y]=true;
		for(i=-2;i<=2;i++)
			{
			for(j=-2;j<=2;j++)
				{
					if(i==0 && j==0)
						continue;
					if(x+i<1 || x+i>h || y+j<1 || y+j>w)
						continue;
					if(s[x+i][y+j]=='#')
						continue;
					r=1;
					if((abs(i)==1 && abs(j)==0) || (abs(i)==0 && abs(j)==1))
						r=0;
					if(dp[x][y]+r<dp[x+i][y+j])
						{
								dp[x+i][y+j]=dp[x][y]+r;
								q.push({-(dp[x][y]+r),{-(x+i),-(y+j)}});
						}
						

					}
			}
	}
	if(dp[dh][dw]==inf)
	{
		cout<<-1;
	}
	else
	cout<<dp[dh][dw];

// cout<<s[4][4]<<endl;
	
}




	

		

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

int main(){
    int N; cin >> N;
    int ans = 0;
    for (int i = 3; i <= N; i+=2)
    {
        int cnt = 0;
        for (int j = 1; j <= i; j+=2)
        {
            if(i%j==0) cnt++;
        }
        if(cnt==8) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstring>
#include <regex>
#include <sstream>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr ll INF = 1e18 + 10;
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;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    string s;
    cin >> s;
    vector<ll> countG(s.size() + 1, 0);
    vector<ll> countL(s.size() + 1, 0);
    for (size_t i = 0; i < s.size(); i++)
    {
        if (s[i] == '<')
        {
            countG[i + 1] = countG[i] + 1;
        }
        else
        {
            countG[i + 1] = 0;
        }
    }
    for (size_t i = s.size(); i > 0; i--)
    {
        if (s[i - 1] == '>')
        {
            countL[i - 1] = countL[i] + 1;
        }
        else
        {
            countL[i - 1] = 0;
        }
    }

    ll ans = 0;

    for (size_t i = 0; i < s.size() + 1; i++)
    {
        ans += max(countG[i], countL[i]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 11656
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define sec second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define pii pair<int,int>
#define sit set<int>:: iterator
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;


const int MAXN=510;

int x[MAXN],a[MAXN*MAXN],cnt[MAXN];
vector<pii > V;

int main(){
    int n;
    scanf("%d",&n);

    rep(i,0,n){
        scanf("%d",&x[i]);
        a[x[i]]=i+1;cnt[i+1]++;
        V.pb({x[i],i+1});
    }

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

    int last=0,j=0;

    rep(i,1,n*n+1){
        if(a[i]){
            if(cnt[a[i]]!=a[i]){
                printf("No\n");
                return 0;
            }
            continue;
        }
        while(j<n){
            if(cnt[V[j].sec]<V[j].sec){
                a[i]=V[j].sec;
                cnt[V[j].sec]++;
                break;
            }
            j++;
        }
        if(j==n){
            while(last<n){
                if(cnt[V[last].sec]<n&&V[last].fi<i){
                    a[i]=V[last].sec;
                    cnt[a[i]]++;
                    break;
                }
                last++;
            }
            if(last==n){
                printf("No\n");
                return 0;
            }
        }
    }

    printf("Yes\n");
    rep(i,1,n*n+1)
        printf("%d ",a[i]);
    printf("\n");

}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>


using namespace std;

bool isPrime(int N) {
    if (N <= 1) {
        return false;
    }

    for (int i = 2; i * i <= N; ++i) {
        if (N % i == 0) {
            return false;
        }
    }
    return true;
}

// vector<int> s = cumulativeSum(vs,N);
// [left, right) => s[right] - s[left]
vector<int> cumulativeSum(vector<int> vs, int N) {
    vector<int> rs(N + 1, 0);
    for (int i = 0; i < N; ++i) {
        rs[i + 1] = rs[i] + vs[i];
    }
    return rs;
}

int main() {

    int Q;
    cin >> Q;

    vector<int> V;

    int m = 100000;

    for (int i = 0; i <= m; ++i) {
        if (i % 2 == 0) {
            V.push_back(0);
            continue;
        }
        if (isPrime(i) && isPrime((i + 1) / 2)) {
            V.push_back(1);
        } else {
            V.push_back(0);
        }
    }

    vector<int> S = cumulativeSum(V, V.size());

    for (int i = 0; i < Q; ++i) {
        int l, r;
        cin >> l >> r;
        cout << S[r + 1] - S[l] << endl;
    }

    return 0;

}

Measured memory_bytes: 1528
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
graph = [[] for i in range(n+1)]
for a,b in ab:
  graph[a].append(b)
  graph[b].append(a)
l,s,c = 0,0,0
vis = [-1]*(n+1)
stack = []
for i in range(1,n+1):
  if vis[i] == -1:
    stack.append(i)
    flg = 0
    vis[i] = 1
    while stack:
      x = stack.pop()
      if not graph[x]:
        flg = 2
      for y in graph[x]:
        if vis[y] == -1:
          vis[y] = vis[x]+1
          stack.append(y)
        elif vis[y]%2 == vis[x]%2:
          flg = 1
    if flg == 0:
      s += 1
    if flg == 1:
      c += 1
    if flg == 2:
      l += 1
print(2*n*l-l**2+2*s*s+(s+c)**2-s**2)


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

void solve(long long n, vector<long long> a){
	vector<long long> b, c;
	for(int i = 0; i < n; ++i) {
		if(i % 2 == 0) {
			c.push_back(a[i]);
		} else {
			b.push_back(a[i]);
		}
	}
	if(n % 2 == 1) {
		swap(b, c);
	}
	reverse(b.begin(), b.end());
	vector<long long> d;
	d.insert(d.end(), b.begin(), b.end());
	d.insert(d.end(), c.begin(), c.end());
	for(int i = 0; i < d.size(); ++i) {
		cout << d[i] << (i == d.size() - 1 ? "\n": " ");
	}
}

int main(){	
	long long n;
	scanf("%lld",&n);
	vector<long long> a(n-1+1);
	for(int i = 0 ; i <= n-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(n, a);
	return 0;
}



Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 100005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
const int MOD = 998244353;
int N,ans;
struct Point {
	int x,y;
	Point(int _x = 0,int _y = 0) {
		x = _x;y = _y;
	}
	friend Point operator + (const Point &a,const Point &b) {
		return Point(a.x + b.x,a.y + b.y);
	}
	friend Point operator - (const Point &a,const Point &b) {
		return Point(a.x - b.x,a.y - b.y);
	}
	friend int operator * (const Point &a,const Point &b) {
		return a.x * b.y - a.y * b.x;
	}
	friend int dot(const Point &a,const Point &b) {
		return a.x * b.x + a.y * b.y;
	}
}P[205];
int inc(int a,int b) {
	return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
	return 1LL * a * b % MOD;
}
int fpow(int x,int c) {
	int res = 1,t = x;
	while(c) {
		if(c & 1) res = mul(res,t);
		t = mul(t,t);
		c >>= 1;
	}
	return res;
}
void Solve() {
	read(N);
	ans = fpow(2,N);ans = inc(ans,MOD - N - 1);
	for(int i = 1 ; i <= N ; ++i) {
		read(P[i].x);read(P[i].y);
	}
	for(int i = 1 ; i <= N ; ++i) {
		for(int j = 1 ; j <= N ; ++j) {
			if(i == j || P[i].x > P[j].x || (P[i].x == P[j].x && P[i].y > P[j].y)) continue;
			int cnt = 2;
			for(int k = 1 ; k <= N ; ++k) {
				if(k == i || k == j) continue;
				if((P[k] - P[i]) * (P[k] - P[j]) == 0) {
					if(P[k].x < P[j].x || (P[k].x == P[j].x && P[k].y < P[j].y)) goto fail;
					++cnt;
				}
			}
			ans = inc(ans,MOD - inc(fpow(2,cnt),MOD - cnt - 1));
			fail:;
		}
	}
	out(ans);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


Measured memory_bytes: 256
K,S=map(int,input().split())
ans=0

for i in range(K+1) :
    if S-i>2*K :
        continue
    elif S-i<0 :
        break
    elif 0<=S-i<=K :
        ans+=S-i+1
    else :
        ans+=2*K+i-S+1

print(ans) 

Measured memory_bytes: 9152
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n;
    long long ans = 1;
    long long const mod = 1e9+7;
    vector<int> a, b;
    cin >> n;
    a.assign(n+1, 0);
    b.assign(n+1, 0);
    b[0] = 3;
    for(int i=0;i<n;i++){
        cin >> a[i];
        ans *= b[a[i]]--;
        ans %= mod;
        b[a[i]+1]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	ll X, Y, Z, K;
	ll A[1010], B[1010], C[1010];
	cin >> X >> Y >> Z >> K;
	for (int i = 0; i < X; ++i)cin >> A[i];
	for (int i = 0; i < Y; ++i)cin >> B[i];
	for (int i = 0; i < Z; ++i)cin >> C[i];
	vector<ll>V;
	for (int i = 0; i < X; ++i) {
		for (int j = 0; j < Y; ++j) {
			V.push_back(A[i] + B[j]);
		}
	}
	sort(V.begin(), V.end(), greater<ll>());
	V.resize(K);
	vector<ll>v;
	for (int i = 0; i < K; ++i) {
		for (int j = 0; j < Z; ++j) {
			v.push_back(V[i] + C[j]);
		}
	}
	sort(v.begin(), v.end(), greater<ll>());
	for (int i = 0; i < K; ++i) {
		cout << v[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 42980
#include<bits/stdc++.h>
using namespace std;
int h[100010];
int dp[100010];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k;
    cin >> n >>  k;
    for (int i = 1; i <= n; ++i) {
        cin >> h[i];
        if (i == 1) {
            continue;
        }
        dp[i] = 2e9;
        for (int j = 1; j <= k; ++j) {
            if (i - j >= 1) {
                dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
            }
        }
   //   cout << i << " " << dp[i] << '\n';
    }
    cout << dp[n];
}

Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
//A - Good Integer
int main() {
  string n;
  cin >> n;
  if( n.at(0) == n.at(1) && n.at(1) == n.at(2) )
    cout << "Yes" << endl;
  else if( n.at(1) == n.at(2) && n.at(2) == n.at(3) )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

int A, B;

int main(int argc, char **argv) {
    std::cin >> A >> B;
    
    int ret = A + B;
    ret = std::max(ret, A - B);
    ret = std::max(ret, A * B);

    std::cout << ret << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/algorithm/string/join.hpp>
#include <boost/range/irange.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using boost::irange;
using boost::algorithm::join;

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
int N;
ll K;
vll A;
vll F;

// target以下が実現可能化
bool validate(ll target) {
  ll c = 0;
  REP(i, N) {
    ll tmp = A[i]*F[i];
    if (tmp <= target) continue;

    c += A[i] - target/F[i];
    if (c > K) return false;
  }

  return true;
}

// 実現不可能な最大値を返す
// [s, e) sは実現不可能, eは実現可能
ll binary_search(ll s, ll e) {
  if (e<=s+1) {
    return s;
  }

  ll m = (s+e)/2;
  if (validate(m)) {
    return binary_search(s, m);
  }

  return binary_search(m, e);
}

int main(int argc, char** argv) {
  cin >> N >> K;
  A.resize(N);
  F.resize(N);

  REP(i, N) {
    cin >> A[i];
  }
  REP(i, N) {
    cin >> F[i];
  }

  Sort(A);
  Sort(F); Reverse(F);

  cout << binary_search(-1, 1e12) + 1 << endl;

  return 0;
}


Measured memory_bytes: 3328