akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
const int inf=1e9;

int to[N],ww[N],nxt[N],h[N],tt=1,n,m,s,t,x[N],y[N],cnt=0,dep[N],cur[N];
char ch[110];

void adde(int u,int v,int w) {
	to[++tt]=v,ww[tt]=w,nxt[tt]=h[u],h[u]=tt;
	to[++tt]=u,nxt[tt]=h[v],h[v]=tt;
}

bool bfs() {
	memset(dep,0,4*(cnt+1));
	queue<int> q;q.push(s);dep[s]=1;
	while(!q.empty()) {
		int u=q.front();q.pop();
		for(int i=h[u],v;v=to[i],i;i=nxt[i])
			if(!dep[v]&&ww[i]) {
				dep[v]=dep[u]+1,q.push(v);
				if(v==t) return 1;
			}
	}
	return 0;
}

int dfs(int u,int flow) {
	if(u==t) return flow;
	int ret=0;
	for(int &i=cur[u],v;v=to[i],i;i=nxt[i])
		if(dep[v]==dep[u]+1&&ww[i]) {
			int d=dfs(v,min(flow,ww[i]));
			ww[i]-=d,ww[i^1]+=d,ret+=d,flow-=d;
			if(!flow) return ret;
		}
	dep[u]=0;return ret;
}

int dinic() {
	int ret=0;
	while(bfs()) {
		memcpy(cur,h,4*(cnt+1));
		ret+=dfs(s,inf);
	}
	return ret;
}

int main() {
	cin>>n>>m;
	for(int i=1;i<=n;i++) {
		scanf("%s",ch+1);
		for(int j=1;j<=m;j++)
			if(ch[j]!='.') {
				x[++cnt]=i,y[cnt]=j;
				if(ch[j]=='S') s=cnt;
				else if(ch[j]=='T') t=cnt;
			}
	}
	if(x[s]==x[t]||y[s]==y[t]) return cout<<-1,0;
	for(int i=1;i<=cnt;i++) {
		adde(i,i+cnt,(i==s||i==t)?inf:1);
		adde(i+cnt,x[i]+2*cnt,inf);
		adde(x[i]+2*cnt,i,inf);
		adde(i+cnt,y[i]+2*cnt+n,inf);
		adde(y[i]+2*cnt+n,i,inf);
	}
	t+=cnt;cnt=2*cnt+n+m;
	cout<<dinic();
	return 0;
}


Measured memory_bytes: 1792
let x = Array.zeroCreate<int> 5

for i in [ 0..4 ] do
    x.[i] <- stdin.ReadLine() |> int

let mutable index = 0
let mutable value = x.[0] % 10

for i in [ 0..4 ] do
    if 0 < x.[i] % 10 && x.[i] % 10 < value then
        value <- x.[i] % 10
        index <- i

let mutable result = 0

for i in [ 0..4 ] do
    if i <> index then result <- result + 10 * int (ceil ((float x.[i]) / 10.))
    else result <- result + x.[i]

result |> stdout.WriteLine


Measured memory_bytes: 11348
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t H,W;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> H>>W;
	for (size_t i = 0; i < W+2; i++)
	{
		std::cout << "#";
	}
	std::cout << "\n";

	std::string s;
	for (size_t i = 0; i < H; i++)
	{
		std::cout << "#";
		std::cin >> s;
		std::cout << s;
		std::cout << "#\n";
	}

	for (size_t i = 0; i < W + 2; i++)
	{
		std::cout << "#";
	}
	std::cout << "\n";

	return 0;
}
#endif

#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
int32_t ARR[300000];
int64_t MAX[112345];//[N-1,2N][0,N+1]
int64_t MIN[112345];//[N-1,2N]
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N;
	for (size_t i = 0; i < 3*N; i++)
	{
		in >> ARR[i];
	}
	//std::sort(ARR, ARR + N);
	//std::sort(ARR+2*N-1, ARR + 3*N);

	//前を最大化
	{
		int64_t sum = 0;
		std::priority_queue<int32_t> que;
		for (int32_t i = 0; i < N; i++)
		{
			que.push(-ARR[i]);
			sum += ARR[i];
		}
		MAX[0] = sum;
		//[N,2N]を処理
		for (int32_t i = 0; i <= N; i++)
		{
			que.push(-ARR[N+i]);
			sum += ARR[N+i];
			sum += que.top(); que.pop();
			MAX[i+1] = sum;
		}
	}
	//後ろを最小化
	{
		int64_t sum = 0;
		std::priority_queue<int32_t> que;
		for (int32_t i = 0; i < N; i++)
		{
			que.push(ARR[3*N-1-i]);
			sum += ARR[3*N-1-i];
		}
		MIN[N+1] = sum;
		//[N,2N]を処理
		for (int32_t i = 0; i <= N; i++)
		{
			que.push(ARR[2*N-1 - i]);
			sum += ARR[2*N-1 - i];
			sum -= que.top(); que.pop();
			MIN[N-i] = sum;
		}
	}
	//[N-1,2N]を処理
	int64_t max_value = (-9223372036854775807i64 - 1);
	for (int32_t i = 0; i <= N; i++)
	{
		max_value = std::max(max_value, MAX[i] - MIN[i+1]);
	}
	std::cout << max_value << std::endl;
	return 0;
}
#endif


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

int main() {
  double h, n, a[100000], sum = 0;
  cin >> h >> n;
  for (int i = 0; i < n; i++){
      cin >> a[i];
  }
  for (int i = 0; i < n; i++){
      sum += a[i];
  }
  if(h <= sum){
      cout << "Yes" << endl;
  } else {
      cout << "No" << endl;
  }
}

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

const int MAXN = 100005;

int n, cnt[MAXN];

int main(){
	scanf("%d", &n);
	
	for(int x = 1; x <= 100; x++)
	for(int y = 1; y <= 100; y++)
	for(int z = 1; z <= 100; z++){
		cnt[x * x + y * y + z * z + x * y + y * z + z * x]++;
	}
	
	for(int i = 1; i <= n; i++)
		printf("%d\n", cnt[i]);
		
	return 0;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize(-O3)
#pragma GCC optimize(0fast)
#pragma GCC optimize("unroll-loops")

#define fi first
#define se second
#define sqr(x) (x) * (x)
#define p_b push_back
#define m_p make_pair
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
#define pw(x) (1ll << x)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 1e6;
const ll MOD = 1e9 + 7;

template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T> void vout(T s){cout << s << endl; exit(0);}


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

    ll n, L, sc = 0, ans = 1e18;
    cin >> n >> L;

    for(int i = 1; i <= n; i++){
        ll x = i + L -  1;
        sc += x;
        if(abs(x) < abs(ans))ans = x;
    }

    cout << sc - ans << "\n";

    return 0;
}


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

using namespace std;

int n;
string str;

int main()
{
	cin>>n>>str;
	int ans=0,l=0,r=str.size()-1;
	while(l<r)
	{
		if(str[l]=='R')
		{
			l++;
			continue;
		}
		if(str[r]=='W')
		{
			r--;
			continue;
		}
		ans++,l++,r--;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3708
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int INF=1e9+7;

const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  ll n,k,ans=0;cin>>n>>k;
  rep(i,k,n+2){
    ll b=((i-1)*i)/2,e=((2*n-i+1)*i)/2;
    ans+=(e-b+1)%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

template<typename T>
void say(vector<T> s, string t) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << t << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T & a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T & a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T> & v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

int main() {
	makei(a);
	makei(b);
	makei(c);
	Yn(a < b && b < c);
}


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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  string t, p;
  rep(i,s.size()) {
    t += s[i];
    if(t==p) continue;
    p = t;
    t = "";
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()

	fmt.Fprintln(stdout, n^1)
}


Measured memory_bytes: 1744
#include <stdio.h>

// min
int main(void){
  int a = 0, b = 0;
  
  scanf("%d%d", &a, &b);

  if(a < 10 && b < 10){
    printf("%d\n", a * b);
  }else{
    printf("-1\n");
  }

  return 0;

}



Measured memory_bytes: 128
def d_not_divisible():
    from collections import Counter
    N = int(input())
    A = [int(i) for i in input().split()]

    a_max = max(A)
    appear = [0] * (a_max + 1)
    for a in A:
        appear[a] += 1

    for j in range(1, a_max + 1):
        if appear[j] == 0:
            continue
        for k in range(j * 2, a_max + 1, j):
            appear[k] = 0
    return len([1 for a in appear if a == 1])

print(d_not_divisible())

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

typedef long long ll;


struct Node{
    ll key;
    Node *parent,*left,*right;
};


struct Tree{
    Node *nil,*root;

    void init(){
        root=nil;
    }

    void add(ll key){
        Node *newnode;
        Node *p;
        newnode = (Node*)malloc(sizeof(Node));

        newnode->key = key;
        newnode->parent = newnode->right = newnode->left = nil;

        Node *pa = find_parent(key);
        if(pa == nil){
            root = newnode;
        }else if(key < pa->key){
            pa->left = newnode;
        }else{
            pa->right = newnode;
        }
    }

    Node* find_parent(int key){
        Node *pa=nil;
        Node *loc=root;
        while(loc != nil){
            pa = loc;
            if(key < loc->key){
                loc = loc->left;
            }else{
                loc = loc->right;
            }
        }
        return pa;
    }

    void print_in(Node *r){
        if(r==nil)return;
        print_in(r->left);
        cout << " " << r->key;
        print_in(r->right);
    }

    void print_pre(Node *r){
        if(r==nil)return;
        cout << " " << r->key;
        print_pre(r->left);
        print_pre(r->right);
    }
    void print(){
        print_in(root);
        cout << endl;
        print_pre(root);
        cout << endl;
    }
};


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

    Tree tree;
    tree.init();
    int n;
    cin >> n;
    string s;
    int k;
    for(int i=0;i<n;i++){
        cin >> s;
        if(s=="insert"){
            cin >> k;
            tree.add(k);
        }else{
            tree.print();
        }
    }
    return 0;
}



Measured memory_bytes: 26636
#include<stdio.h>
int main(void){
  int n,res=0;
  scanf("%d",&n);
  for(int i=1;i<10;i++){
    if(n/i<10&&n%i==0){
      res=1;
      break;
    }
  }
  if(res==0)printf("No\n");
  else printf("Yes\n");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int n, a[N];

#define x(i, j) (a[i] <= T && a[j] <= T)
#define y(i, j) (a[i] > T && a[j] > T)

bool check(int T) {
    for(int len = 1 ; len <= 2 * n ; ++ len) {
        int i = n + len - 1, j = i + 1;
        int p = n - len + 1, q = p - 1;
        if(1 <= i && i <= 2 * n - 1
        && 1 <= j && j <= 2 * n - 1
        && 1 <= p && p <= 2 * n - 1
        && 1 <= q && q <= 2 * n - 1) {
            if(x(i, j) || x(p, q)) return 1;
            if(y(i, j) || y(p, q)) return 0;
        }
    } 
    return x(1, 1);
}

int main() {
    scanf("%d", &n);
    for(int i = 1 ; i <= 2 * n - 1 ; ++ i)
        scanf("%d", &a[i]);
    int l = 1, r = 2 * n - 1, ans = 0;
    while(l <= r) {
        int mid = (l + r) >> 1;
        if(check(mid)) {
            ans = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    } 
    printf("%d\n", ans); 
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());  //N角形

            var imp = Console.ReadLine().Split(' ');

            int[] sides = new int[N];
            for (int i = 0; i < N; i++)
            {
                sides[i] = int.Parse(imp[i]);
            }

            Array.Sort(sides);
            // Console.Write(sides[0]);

            int sum_not_longest = (sides.Sum())-(sides[N-1]);

            if ((sides[N - 1]) < sum_not_longest)
                        {
                            Console.Write("Yes");
                        }
                        else
                        {
                            Console.Write("No");
                        }

        }
    }
}

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

using ll = int64_t;
const int MAX = 2e5;
const int MOD = 1e9 + 7;

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n, k; cin >> n >> k;
    vector<ll> v(n);
    for (auto& it : v) cin >> it;
    int r = n-1, l = 0, sign = 1;
    ll ans = 1;

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

    if (k%2 == 1) {
        ans = v[r];
        r--, k--;
        sign = ans < 0 ? -1 : 1;
    }

    while (k) {
        ll x = v[l] * v[l+1];
        ll y = v[r] * v[r-1];
        if (x*sign > y*sign) ans = (ans * (x%MOD))%MOD, l += 2;
        else ans = (ans * (y%MOD))%MOD, r -= 2;
        k -= 2;
    }

    cout << (ans + MOD)%MOD;


    return 0;
}

Measured memory_bytes: 4748
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <cmath>
#include <cstring>

using namespace std;

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

int main() {
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    string s;
    cin >> s;
    int n = s.length();
    if(n == 1){
        if(s[0] == '?')
        s[0] = 'D';
        cout << s;
    }
    else if(n > 1){
    if(s[0] == '?'){
        if(s[1] == 'D')
        s[0] = 'P';
        else if(s[1] == 'P')
        s[0] = 'D';
        else if(s[1] == '?')
        s[0] = 'D';
    }
    for(int i = 1; i < s.length(); i++){
        if(s[i] == '?'){
            s[i] = 'D';
        }
    }
    cout << s;
    }
}









Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int i,j,k,x,y,z,l,m,n,count1=0,count2=0;
void A(void);
void B(void);
void C(void);
void D(void);
void E(void);
void F(void);

int main(void){
    B();
}

void B(){
    string s;
    int k;
    cin>>k>>s;
    if(s.length()<=k)cout<<s<<endl;
    else cout<<s.substr(0,k)<<"..."<<endl;
}

Measured memory_bytes: 3624
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int ll;
const int INF = 1e9 + 7;
int mod;

int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

const int nax = 1e5 + 5;
VI edges[nax], children[nax];
vector<PII> downs[nax], pref[nax], suf[nax];
PII down[nax], up[nax];

int add(int a, int b) {
    return (a + b) % mod;
}

int mul(int a, int b) {
    return (ll) a * b % mod;
}

#define black second
#define white first
PII merge(const PII& a, const PII& b) {
    PII p;
    p.white = mul(a.white, b.white);
    p.black = add(mul(a.black, add(b.white, b.black)), mul(a.white, b.black));
    return p;
}
PII process(PII p) {
    return {p.white, add(p.black, p.white)};
}
// black, white pair
void dfs_one(int a, int parent) {
    PII p{1, 0};
    for (int b : edges[a]) {
        if (b != parent) {
            children[a].push_back(b);
            dfs_one(b, a);
            // down[a].black = mul(down[a].black, add(down[b].black, down[b].white));
            // down[a].white = mul(down[a].white, down[b].white);
            p = merge(p, down[b]);
            downs[a].push_back(down[b]);
        }
    }
    down[a] = process(p);
}

void dfs_two(int a, int parent) {
    for (int i = 0; i < (int)children[a].size(); i++) {
        PII p{1, 0};
        if (i) {
            p = merge(p, pref[a][i - 1]);
        }
        if (i != (int)downs[a].size() - 1) {
            p = merge(p, suf[a][i + 1]);
        }
        if (a != 1) {
            p = merge(p, up[a]);
        }
        int b = children[a][i];
        up[b] = process(p);
        dfs_two(b, a);
    }
}

int main() {
    int n = nxt();
    mod = nxt();
    for (int i = 0; i < n - 1; i++) {
        int a = nxt(), b = nxt();
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    dfs_one(1, -1);
    for (int a = 1; a <= n; a++) {
        int k = downs[a].size();
        assert(k == (int)children[a].size());
        PII p{1, 0};
        for (int i = 0; i < k; i++) {
            p = merge(p, downs[a][i]);
            pref[a].push_back(p);
        }
        p = {1, 0};
        for (int i = k - 1; i >= 0; i--) {
            p = merge(p, downs[a][i]);
            suf[a].push_back(p);
        }
        reverse(all(suf[a]));
    }
    dfs_two(1, -1);
    for (int a = 1; a <= n; a++) {
        PII p{1, 0};
        if (a != 1) {
            p = merge(p, up[a]);
        }
        if (!children[a].empty()) {
            p = merge(p, pref[a].back());
        }
        p = process(p);
        printf("%d\n", p.black);
        // printf("%d\n", mod);
        // printf("%d %d\>n", up[a].second, down[a].second);
    }
    return 0;
}


Measured memory_bytes: 40344
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int h=sc.nextInt();
        int w=sc.nextInt();
        out.println((n-h+1)*(n-w+1));
    }
    //a文字目とb文字目を入れ替え（1-indexed）
    static String swap(String s,int a,int b){
        StringBuilder t=new StringBuilder(s);
        char A=s.charAt(a-1);
        char B=s.charAt(b-1);
        t.setCharAt(a-1,B);
        t.setCharAt(b-1,A);
        return t.toString();
    }
    static long power(long x,int n){
        long mod=1000000007;
        long ans=1;
        while (n>0) {
            if((n&1)==1){
                ans=(ans*x)%mod;
            }
            x=(x*x)%mod;
            n>>=1;
        }
        return ans;
    }
    //最大公約数
    static int gcd (int a,int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
    //※最小公倍数はa*b/gcd(a,b)である
    static class UF{
        static int size=51;
        static int[] par=new int[size];
        //初期化
        static void init(){
            for (int i = 1; i <size ; i++) {
                par[i]=i;
            }
        }
        //根をたどる
        static int root(int x){
            if(par[x]==x){
                return x;
            }else{
                return par[x]=root(par[x]);
            }
        }
        //同じ根をもつか(同じ集合に属するか)判定
        static boolean same(int x,int y){
            return root(x)==root(y);
        }
        //合体
        static void unite(int x,int y){
            x=root(x);
            y=root(y);
            if(x==y)return;
            par[x]=y;
        }
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <math.h>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e18
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 200000;

int main(){
    
    ll n,k;
    vector<pair<ll,ll> > v;
    ll ans = 0;
    ll a[maxn];
    ll f[maxn];
    
    cin >> n>> k;
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> f[i];
    }
    
    sort(a,a+n);
    sort(f,f+n);
    reverse(f,f+n);
    
    rep(i,n){
        v.push_back(make_pair(a[i]*f[i],f[i]));
    }
    
    ll l = 0,r=INF;
    
    while(l<r){
        ll cnt = 0;
        bool can = true;
        ll mid = (r+l)/2;
        rep(i,n){
            if(v[i].first>mid){
                cnt += (v[i].first-mid+v[i].second-1)/v[i].second;
            }
            if(cnt>k){
                can = false;
                break;
            }
        }
        
        if(can){
            r = mid;
            ans = mid;
        }else{
            l = mid+1;
        }
    }
    
    cout << ans<<endl;
    
    return 0;
}


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

int ans[200][2][12];//二つ目の次元の0の0に数列の長さ、0の1に操作回数、1に答えの数列

int counter=0,flag=0;

void solve(){
	int n;
	cin >> n;
	if(n==0){flag=1;return;}
	ans[counter][0][0]=n;
	
	int S[12];//数列
	for(int i=0;i<n;i++){
		cin >> S[i];
	}
	
	bool check=false;//操作の有無のフラグ
	int time=0;//操作回数
	do{
		map<int,int> marker;
		for(int i=0;i<n;i++){
			marker[S[i]];
			marker[S[i]]++;
		}
		check=false;
		for(int i=0;i<n;i++){
			if(S[i]!=marker[S[i]]){
				check=true;
				S[i]=marker[S[i]];
			}
		}
		if(check) time++;
	}while(check);
	
	ans[counter][0][1]=time;
	for(int i=0;i<n;i++){
		ans[counter][1][i]=S[i];
	}
	counter++;
}

int main(){
	while(flag==0)solve();
	for(int i=0;i<counter;i++){
		cout << ans[i][0][1] << endl;
		for(int j=0;j<ans[i][0][0]-1;j++){
			cout << ans[i][1][j]<<" ";
		}
		cout << ans[i][1][ans[i][0][0]-1] << endl;
	}
}
			
	
	

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B;
    cin >> A >> B;
    if (A == 1) {
        if (B == 1) {
            cout << "Draw" << endl;
        }
        else {
            cout << "Alice" << endl;
        }
    }
    else if (B == 1) {
        cout << "Bob" << endl;
    }
    else if (A < B) {
        cout << "Bob" << endl;
    }
    else if (A == B) {
        cout << "Draw" << endl;
    }
    else {
        cout << "Alice" << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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 main() {
	cin.tie(0);
	ios::sync_with_stdio(0);

	lint x, t;
  	cin>>x>>t;
  	if(t>x)co(0);
  	else co(x-t);
}

Measured memory_bytes: 256
import numpy as np
N, M = [int(i) for i in input().split()]

gate = np.zeros(N+1)
for i in range(0, M):
    L, R = [int(j) for j in input().split()]
    gate[L-1] += 1
    gate[R] -=1

count = 0
for i in range(1, len(gate)):
    gate[i] = gate[i] + gate[i-1]
    if gate[i] == M:
        count += 1

if gate[0] == M:
    count += 1
print(count)

Measured memory_bytes: 14552
#include<iostream>
using namespace std ;
string s;
int mod[200005],c[200005];
int i;
int main(){
	cin>>s;
	int a=1;
	for(i=s.size()-1;i>-1;i--){
		mod[i]=(mod[i+1]+(s[i]-'0')*a)%2019;
		a*=10;
		a%=2019;
	}
	int ans=0;
	for(i=0;i<=s.size();i++){
		ans+=c[mod[i]];
		c[mod[i]]+=1;
	}
	cout<<ans;
}                              

Measured memory_bytes: 4420
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;

  ll x = 0;
  for(ll i=1; i*i<=n; i++) {
    if(n % i == 0) x = i;
  }

  cout << (x + (n / x) - 2) << endl;
}


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


#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[210000];
main(){
  ll n;
  cin>>n;
  string s;
  cin>>s;
  ll ans=0;
  rep(i,0,n-2){
    if(s[i]=='A'&&+s[i+1]=='B'&&s[i+2]=='C')ans++;
  }
  cout<<ans;
}

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

using namespace std;

long long a, b, c, a1, b1, c1, k;

int main()
{
	cin >> a >> b >> c >> k;
	if ( k % 2 == 0)
	{
		cout << a - b;
		return 0;
	}
	cout << -1 * (a - b);
	return 0;
}


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

int a,b;

int main()
{
    cin >> a >> b;
    if ((a+b) % 2 == 0) cout << (a+b)/2; else cout << "IMPOSSIBLE";

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
for g in G[0]:
    if N - 1 in G[g]:
        print('POSSIBLE')
        sys.exit()
print('IMPOSSIBLE')


Measured memory_bytes: 41788
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#define ll long long
using namespace std;
int main(){
    string s;
    cin >> s;
    int count=0;
    for(int i=0;i<4;i++){
        if(s[i]=='2'){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();
        if (i == 1) {
            System.out.println("Hello World");
        } else if (i == 2) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(a+b);
        }
    }
}


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

namespace AtTest.ABC_150
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] kx = ReadInts();
            int k = kx[0];
            int x = kx[1];
            if (k * 500 >= x) WriteLine("Yes");
            else WriteLine("No");
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>

int main(void) {
	int n, a, b;
	int suma = 0;
	int sumb = 0;
	while (1) {
		scanf("%d", &n);
		if (n == 0) {
			return 0;
		}
		int i;
		for (i = n; i > 0; i--) {
			scanf("%d %d", &a, &b);
			if (a > b) {
				suma = suma + a + b;
			}
			else if (b > a) {
				sumb = sumb + a + b;
			}
			else {
				suma = suma + a;
				sumb = sumb + b;
			}
		}
		printf("%d %d\n", suma, sumb);
		suma = 0;
		sumb = 0;
	}
return 0;
	
}

Measured memory_bytes: 1804
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
vector<vector<ll> >G(2*100010);
ll ma=0;
ll s=1;
void dfs(ll i,ll p,ll d){
    if(d>ma){
        ma=d;
        s=i;
    }
    for(auto e:G[i]){
        if(e==p)continue;
        dfs(e,i,d+1);
    }
}
void dfs2(ll i,ll p,ll d){
    if(d>ma){
        ma=d;
    }
    for(auto e:G[i]){
        if(e==p)continue;
        dfs(e,i,d+1);
    }
}
int main(){
    ll n;cin>>n;
    rep(i,n-1){
        ll a,b;cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
    }
    dfs(1,0,0);
    ma=0;
    dfs2(s,0,0);
    if(ma%3==1)cout<<"Second"<<endl;
    else cout<<"First"<<endl;
}

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

ll modpow(ll a, ll n, ll mod){
    ll ret=1;
    while(n>0){
        if(n&1) ret=ret*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ret;
}

int main(){
    ll n;
    cin>>n;
    ll ans=modpow(10,n,MOD);
    ans-=modpow(9,n,MOD);
    ans=(ans+MOD)%MOD;
    ans-=modpow(9,n,MOD);
    ans=(ans+MOD)%MOD;
    ans+=modpow(8,n,MOD);
    ans=(ans+MOD)%MOD;
    cout<<ans<<endl;


}

Measured memory_bytes: 3200
x,y,a,b,c=map(int,input().split())
*p,=sorted(map(int, input().split()))
*q,=sorted(map(int, input().split()))
*r,=map(int, input().split())

p=p[-x:]
q=q[-y:]
r=sorted(p+q+r)
print(sum(r[-x-y:]))

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

int dp[101][1<<16];
int main(){
	int N;
	while(cin >> N&&N){
		memset(dp,0,sizeof(dp));
		for(int i = 0 ; i < N ; i++){
			int M,L;
			cin >> M >> L;
			int b = 0;
			for(int j = 0 ; j < M ; j++){
				int s,e;
				cin >> s >> e;
				s -= 6;
				e -= 6;
				b |= ((1<<(e-s))-1) << s;
			}
			for(int k = 0 ; k < (1<<16) ; k++){
				dp[i+1][k] = max(dp[i][k],dp[i+1][k]);
				if( k & b ) continue;
				dp[i+1][k|b] = max(dp[i+1][k|b],dp[i][k]+L);
			}
			
		}
		int res = 0;
		for(int i = 0 ; i < (1<<16) ; i++)
			res = max(res,dp[N][i]);
		cout << res << endl;
	}
}

Measured memory_bytes: 27024
read s
read t
u=`<<<$t sed s/./[?\&]/g`

{
<<<$s sed "s@$u@$t@
ts
cUNRESTORABLE
:s
y/?/a/"

<<<$s sed "s@\(.*\)$u@\\1$t@
ts
cUNRESTORABLE
:s
y/?/a/"
}|sort|head -1


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

int main()
{
	double W, H, x, y;
	cin >> W >> H >> x >> y;

	double S = W * H / 2;
	int is_exist = (int)(x*2 == W && y*2 == H);
	
	cout << fixed << setprecision(10) << S << endl;
	cout << is_exist << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int A[2][N];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A[i][j];
    }
  }
  int dp[2][N];
  dp[0][0] = A[0][0];//A[0][0]=start地点((1,1))
  dp[1][0] = A[0][0] + A[1][0];//座標で言うと(1,1)と(1,2)の合計がdp[1][0]
  for (int i = 1; i < N; i++) {
    dp[0][i] = dp[0][i - 1] + A[0][i];//1行目を横一列に足していく
    dp[1][i] = max(dp[0][i], dp[1][i - 1]) + A[1][i];//1行目の「途中」(最初から・最後までかもしれないけど)までの和と2行目の「途中」-1番目までの和の大きい方を選択
  }
  cout << dp[1][N - 1];
}


Measured memory_bytes: 256
from collections import deque

H,W=list(map(int,input().split()))
S=[input() for _ in range(H)]

start=[[j,i] for i in range(W) for j in range(H)]
res=0

for pt in start:
    v=[[0]*W for _ in range(H)]
    if S[pt[0]][pt[1]]=='#':
        continue
    q=deque([pt+[0]])
    dist=0

    while len(q)>0:
        h,w,cnt=q.popleft()
        
        if v[h][w]==1:
            continue
        else:
            v[h][w]=1

        dist=max(dist,cnt)

        for dh,dw in [[1,0],[-1,0],[0,1],[0,-1]]:
            nh=h+dh
            nw=w+dw
            if 0>nh or nh>=H or 0>nw or nw>=W or S[nh][nw]=='#':
                continue
            q.append([nh,nw,cnt+1])
    
    res=max(res,dist)

print(res)

Measured memory_bytes: 44252
#include <stdio.h>
#include <stdlib.h>

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

    int eat_order[n+1];
    eat_order[0] = -1;
    for ( i=1; i<n+1; i++ )
        scanf("%d", &eat_order[i]);

    int ans=0;
    int tmp;
    for ( i=1; i<n+1; i++ ) {
        scanf("%d", &tmp);
        ans += tmp;
    }

    /* if eat No.1 and No.2, then add order_bonus[1] */
    int order_bonus[n];
    for ( i=1; i<n; i++ )
        scanf("%d", &order_bonus[i]);

    for ( i=1; i<n+1; i++ ) {
        if ( eat_order[i] == eat_order[i-1]+1 )
            ans += order_bonus[eat_order[i-1]];
    }
    printf("%d\n", ans);
    return EXIT_SUCCESS;
}


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

int main(){
  int N;cin >> N;
  vector<int> a(N);
  rep(i,N) cin >> a[i];

  int count=0;
  rep(i,N){
    if((i+1)%2==1 && a[i]%2==1){
      count++;
    }
  }
  cout << count;
  return 0;
}


Measured memory_bytes: 3588
#include<cstdio>  
#include<cstdlib> 
#include<cstring>  
#include<cmath>  
#include<algorithm>  
using namespace std;  
int n,all;  
struct NOOD {
	int x, y;
}a[105], b[105];
bool line[205][205];
int t[205];  
bool used[205];

bool find(int x){  
	for(int j = 1; j <= n; j++){  
		if(line[x][j + n] == true && used[j + n] == false){  
			used[j + n] = 1;  
			if(t[j + n] == 0 || find(t[j + n])){  
				t[j + n] = x;  
				return true;  
			}  
		}  
	}  
	return false;  
}  
void solve() {
	for(int i = 1; i <= n; i++) scanf("%d%d", &a[i].x, &a[i].y);
	for(int i = 1; i <= n; i++) scanf("%d%d", &b[i].x, &b[i].y);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			if(a[i].x < b[j].x && a[i].y < b[j].y) {
				line[i][j + n] = 1;
				line[j + n][i] = 1;
			}
	for(int i = 1; i <= n; i++){
		memset(used,0,sizeof(used));
		if(find(i)) all++;
	}
	printf("%d\n", all);

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

Measured memory_bytes: 256
def main():
    import sys
    from fractions import gcd
    input=sys.stdin.readline
    n=int(input())
    a=tuple(map(int,input().split()))
    ide_ele=0
    num=2**(n-1).bit_length()
    seg=[ide_ele]*2*num
    def init(init_val):
        for i in range(n):
            seg[i+num-1]=init_val[i]
        for i in range(num-2,-1,-1):
            seg[i]=gcd(seg[2*i+1],seg[2*i+2])
    
    def update(k,x):
        k+=num-1
        seg[k]=x
        while k:
            k=(k-1)//2
            seg[k]=gcd(seg[k*2+1],seg[k*2+2])
    
    def query(p,q):
        if q<=p:
            return ide_ele
        p+=num-1
        q+=num-2
        res=ide_ele
        while q-p>1:
            if p&1==0:
                res=gcd(res,seg[p])
            if q&1==1:
                res=gcd(res,seg[q])
                q-=1
            p=p//2
            q=(q-1)//2
        if p==q:
            res=gcd(res,seg[p])
        else:
            res=gcd(gcd(res,seg[p]),seg[q])       
        return res

    init(a)
    ans=-1
    for i in range(n):
        ans=max(ans,gcd(query(0,i),query(i+1,n)))
    print(ans)
main()

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

vector<string> A;

bool check(vector<int> V, int i, vector<vector<int>> Graph) {
    if(i == V.size()-1) return true;
    int now = V[i];
    int nxt = V[i+1];
    int cnt  = 0;

    for(auto g : Graph[now]) {
        if(nxt != g) ++cnt;
    } 
    if(cnt == Graph[now].size()) return false;
    if(check(V, i+1, Graph)) return true;
    else return false;
}


int main() {
    int ans = 0;
    int N, M;
    cin >> N >> M;
    vector<vector<int>> Graph(N+1);

    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        Graph[a].push_back(b);
        Graph[b].push_back(a);
    }

    vector<int> V;

    for(int i = 1; i <=N; ++i) {
        V.push_back(i);
    }

    do {
        if(V[0] != 1) continue;
        bool ok = check(V, 0, Graph);
        if(ok) ++ans;
    } while(next_permutation(V.begin(), V.end()));

    cout << ans << endl;
}

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

int main(){
    int K,N;
    cin >> K >> N;
    int d = 0;
    int maxd=0;
    int mind = 1000000;
    int minmind = 1000000;
    vector<pair<int, bool >> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A.at(i).first;
        A.at(i).second= false;
    }
//    for (int i = 0; i < N; ++i) {
////        cout << A.at(i).second << endl;
//        if(i>0 && i<N-1){
//            d+= min(abs(A.at(i+1).first-A.at(i).first), abs(A.at(i).first-A.at(i-1).first));
//        }else if(i==0){
//            d+= min(abs(A.at(i).first+(K-A.at(N-1).first)),A.at(i+1).first-A.at(i).first)
//        }
//    }
    for (int i = 1; i < N-1; ++i) {
            if((A.at(i+1).first - A.at(i).first) > maxd){
                maxd = (A.at(i+1).first - A.at(i).first) ;
            }

        }
    if(A.at(0).first + K - A.at(N-1).first > maxd){
        maxd = A.at(0).first + K - A.at(N-1).first;
    }
    cout << K-maxd << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
using namespace std;
#define S 100000
typedef struct{char n[10];int t;}QUE;QUE que[S];main(){int i=0,T=0,h=0,t,n,q;scanf("%d %d",&n,&q);for(t=n;i<n;)scanf("%s %d",que[i++].n,&que[i].t);while(h!=t){i=que[h].t<=q||t-h==1;T+=i?que[h].t:q;if(i)printf("%s %d\n",que[h].n,T);else{que[h].t-=q;que[t]=que[h];t=S==t+1?0:t+1;}h=S==h+1?0:h+1;}}


Measured memory_bytes: 4256
# -*- coding utf-8 -*-

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

a=[input() for i in range(n)]
b=[input() for i in range(m)]

for i in range (n-m+1):
    for j in range(n-m+1):
        c=[a[i+k][j:j+m] for k in range(m)]
        if b==c:
            print('Yes');exit()

print("No")


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

ll ans=0;
ll n;

void func(bool a,bool b,bool c,string now){
  if(now!=""&&atol(now.c_str())>n)return;
  if(a&&b&&c&&atol(now.c_str())<=n)ans++;
  func(true,b,c,'3'+now);
  func(a,true,c,'5'+now);
  func(a,b,true,'7'+now);
}

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

  cin>>n;
  func(false,false,false,"");
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    long long i,j,l,add=0;
    cin >> s;
    for(i=0; i<s.size();i++){
        add+=(s[i]-'0');
    }
    if(add%9==0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,x,y;
    scanf("%d",&a);
    if(a==1)
        printf("Hello World\n");
    else
    {
        scanf("%d%d",&x,&y);
        printf("%d\n",x+y);
    }
    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  int black_num = 0;
  vector<vector<char>> maze(H, vector<char>(W, ' '));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> maze.at(i).at(j);
      if (maze.at(i).at(j) == '#') black_num++;
    }
  }
  
  vector<vector<int>> count(H, vector<int>(W, -1));
  count.at(0).at(0) = 1;
  
  queue<pair<int, int>> que;
  que.push(pair<int, int>(0, 0));
  
  int dx[] = {1, -1, 0, 0};
  int dy[] = {0, 0, 1, -1};
  
  bool check = false;
  while(!que.empty()) {
    pair<int, int> pos = que.front();
    que.pop();
    
    if (pos.first == H - 1 && pos.second == W - 1) {
      check = true;
      cout << H * W - black_num - count.at(pos.first).at(pos.second) << endl;
      break;
    }
    
    for (int i = 0; i < 4; i++) {
      int nx = pos.first + dx[i];
      int ny = pos.second + dy[i];
      
      if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
      if (maze.at(nx).at(ny) == '#') continue;
      if (count.at(nx).at(ny) != -1) continue;
      
      count.at(nx).at(ny) = count.at(pos.first).at(pos.second) + 1;
      que.push(pair<int, int>(nx, ny));
    }
  }
  
  if (!check) {
    cout << -1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}

ll dp[3][100005];
int n,h[3][100005];
int main() {
	memset(dp,0,sizeof(dp));
	cin>>n;
	rep(i,1,n+1){
		cin>>h[0][i]>>h[1][i]>>h[2][i];
	}
	rep(i,1,n+1){
		rep(j,0,3){
			rep(k,0,3){
				if(j==k)continue;
				dp[j][i]=max(dp[j][i],dp[k][i-1]+h[j][i]);
			}
		}
	}
	cout<<max(max(dp[0][n],dp[1][n]),dp[2][n])<<endl;
	return 0;
}


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


int main(){
	int N;
	cin >> N;
	int a[100010],b[100010];
	int Min= 0;
	int B;
	for(int i=0;i<N;i++){
		cin >> a[i] >> b[i];
		Min = max(a[i],Min);
		if(Min == a[i]){
			B = b[i];
		}
	}
	
	cout << Min + B << endl;
	return 0;
}


Measured memory_bytes: 1024