akhauriyash/Code-Regression huggingface dataset:
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    std::vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    std::cin >> k;
    std::cout << v[k - 1] << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 100000 + 5;

int n, m;
int vis[N], col[N];
std::vector<int> v[N], w[N], zkx;
LL ans;
LL f[4];

void dfs(int x) {
	vis[x] = 1; zkx.push_back(x);
	f[col[x]]++;
	for (int i = 0; i < v[x].size(); i++) {
		int y = v[x][i];
		if (vis[y]) continue;
		col[y] = (col[x] + w[x][i] + 3) % 3;
		dfs(y);
	}
}

int check(int x) {
	for (int i = 0; i < v[x].size(); i++) {
		int y = v[x][i];
		if (col[y] != (col[x] + w[x][i] + 3) % 3) return 0;
	}
	return 1;
}

int main() {
	read(n), read(m);
	for (int i = 1, x, y; i <= m; i++) {
		read(x), read(y);
		v[x].push_back(y); w[x].push_back(1);
		v[y].push_back(x); w[y].push_back(-1);
	}
	for (int i = 1; i <= n; i++)
		if (!vis[i]) {
			zkx.clear();
			f[0] = f[1] = f[2] = 0;
			dfs(i);
			int flag = 1, tmp = 0;
			for (int j = 0; j < zkx.size(); j++) {
				tmp += v[zkx[j]].size();
				if (!check(zkx[j])) {
					flag = 0;
					break;
				}
			}
			tmp /= 2;
			int cnt  = (f[0] ? 1 : 0) + (f[1] ? 1 : 0) + (f[2] ? 1 : 0);
			if (flag && cnt < 3) ans += tmp;
			if (flag && cnt == 3) ans += f[0] * f[1] + f[1] * f[2] + f[2] * f[0];
			if (!flag) ans += 1LL * zkx.size() * zkx.size();
		}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 17148
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int a = 0;
    string s;
    cin >> s;
    for(int i=0;i<3;i++){
        if(s[i] == 'A') a++;
    }
    if(a > 0 && a < 3) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int H, N;
    cin >> H >> N;

    vector<int> A(N);
    int sum = 0;

    for(int i = 0; i < N; i++)
    {
        cin >> A.at(i);
        sum += A.at(i);
    }

    if(sum >= H)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }


    return 0;
}

Measured memory_bytes: 640
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize};

    let mut count = 0;

    for i in 1..n + 1 {
        if i.to_string().len() % 2 == 1 {
            count += 1;
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 2156
import Text.Regex

main::IO()
main =do
  abc<-getLine
  let dat = map read (words abc)::[Int]
  print (solver dat)

solver::[Int]->Int
solver (a:b:c:[]) = if (a==b)&&(b==c) then 1 else (if (a/=b)&&(b/=c)&&(a/=c) then 3 else 2)

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

using namespace std;

template <class T> inline bool chmax(T &a, T b) { /* {{{ */
  if (a < b) {
    a = b;
    return true;
  }
  return false;
} /* }}} */

int main() {
  int N;
  string S;
  cin >> N >> S;
  int cnt = 0;
  int pre = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == '(') {
      cnt++;
    } else {
      cnt--;
      chmax(pre, -cnt);
    }
  }

  for (int i = 0; i < pre; i++) {
    cout << '(';
  }
  cout << S;
  for (int i = 0; i < cnt + pre; i++) {
    cout << ')';
  }
  cout << endl;

  return 0;
}
/* vim:set fdm=marker: */


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

typedef long long ll;

ll a, b, c;

int main()
{
    cin >> a >> b >> c;
    if (a > b) swap(a, b);
    if (b > c) swap(b, c);
    if (a > b) swap(a, b);
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
        printf("0\n");
    else printf("%lld\n", ll(a) * b);
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[list(map(int,input().split()))[:2]for i in range(m)]
b=[i for i in range(n+1)]
c=[1]*(n+1)
def root(x):
    if b[x]==x:
        return x
    x=b[x]
    return root(x)
def unite(x,y):
    x=root(x)
    y=root(y)
    if x!=y:
        if c[x]>c[y]:
            b[y]=x
            c[x]+=1
        else:
            b[x]=y
            c[y]+=1
for i,j in a:
    unite(i,j)
for i in range(1,n+1):
    b[i]=root(i)
print(len(set(b[1:])))

Measured memory_bytes: 31780
def gcd(m, n):
    if m < n:
        return gcd(n, m)
    elif n == 0:
        return m
    return gcd(n, m % n)

def lcm(m, n):
    return gcd(m, n) * m // gcd(m, n) * n // gcd(m, n)

A, B, C, D = map(int, input().split())
all_nums = B - A + 1
c_divisible = B // C - (A // C if A % C != 0 else A // C - 1) 
d_divisible = B // D - (A // D if A % D != 0 else A // D - 1)
cd_divisible = B // lcm(C, D) - (A // lcm(C, D) if A % lcm(C, D) != 0 else A // lcm(C, D) - 1)
print(all_nums - c_divisible - d_divisible + cd_divisible)

Measured memory_bytes: 3064
s = int(input())
a = {s}
res = 1
while True:
    res += 1
    if s%2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    if not s in a:
        a.add(s)
    else:
        print(res)
        break
 


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

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

    int n;
    long long k;
    cin >> n >> k;

    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a.begin(), a.end());

    long long le = -1000000000000000001LL;
    long long ri = 1000000000000000001LL;

    while (ri - le > 1)
    {
        long long m = (le + ri) / 2;
        long long cnt = 0;

        for (int i = 0; i < n; i++)
            if (a[i] > 0)
            {
                int le2 = -1;
                int ri2 = n;

                while (ri2 - le2 > 1)
                {
                    int m2 = (le2 + ri2) / 2;

                    if ((long long)a[i] * a[m2] <= m)
                        le2 = m2;
                    else
                        ri2 = m2;
                }

                cnt += ri2;
            }
            else
            {
                int le2 = -1;
                int ri2 = n;

                while (ri2 - le2 > 1)
                {
                    int m2 = (le2 + ri2) / 2;

                    if ((long long)a[i] * a[m2] > m)
                        le2 = m2;
                    else
                        ri2 = m2;
                }

                cnt += n - ri2;
            }

        for (int i = 0; i < n; i++)
            if ((long long)a[i] * a[i] <= m)
                cnt--;

        cnt /= 2;

        if (cnt < k)
            le = m;
        else
            ri = m;
    }

    cout << ri << "\n";

    return 0;
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.Closeable;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HBonsai
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BYYMMOrMMYY solver = new BYYMMOrMMYY();
        solver.solve(1, in, out);
        out.close();
    }

    static class BYYMMOrMMYY {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String S = in.next();
            int zenhan = Integer.parseInt(S.substring(0, 2));
            int kouhan = Integer.parseInt(S.substring(2, 4));
            if ((zenhan >= 1 && zenhan <= 12) && (kouhan >= 1 && kouhan <= 12)) {
                out.println("AMBIGUOUS");
            } else if (zenhan >= 1 && zenhan <= 12) {
                out.println("MMYY");
            } else if (kouhan >= 1 && kouhan <= 12) {
                out.println("YYMM");
            } else {
                out.println("NA");
            }
        }

    }

    static class FastScanner implements Closeable {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public void close() {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}



Measured memory_bytes: 21460
#include<bits/stdc++.h>
#define lint long long int
using namespace std;
int main() 
{
	lint n=0;
	lint m=0;
	lint ans=0;
	cin>>n>>m;
	vector<lint> v(m);
	for(int i=0;i<m;i++)
	{
		cin>>v[i];
		ans+=v[i];
	}
	if(ans>n)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<n-ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
main()
{
	int n,b[100005];
	memset(b,0,sizeof(b));
	scanf("%d",&n);
	while(n--)
	{
		int a;
		scanf("%d",&a);
		if(a==1)
		{
			b[1]++;
			b[2]++;
		}
		else if(a==100000)
		{
			b[100000]++;
			b[99999]++;
		}
		else
		{
			b[a-1]++;
			b[a]++;
			b[a+1]++; 
		}
	}
	int max=0;
	for(int i=1;i<=100000;i++)
	{
		if(b[i]>max)max=b[i];
	}
	printf("%d",max);
}

Measured memory_bytes: 4192
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var lastX = 0;
        var lastY = 0;
        var lastT = 0;
        for (int i = 0; i < n; i++)
        {
            var txy = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int t = txy[0], x = txy[1], y = txy[2];
            var dt = t - lastT;
            var dx = Abs(x - lastX);
            var dy = Abs(y - lastY);
            if (dt < dx + dy || ((dt ^ (dx + dy)) & 1) == 1)
            {
                Console.WriteLine("No");
                return;
            }
            lastX = x;
            lastY = y;
            lastT = t;
        }
        Console.WriteLine("Yes");
    }
}


Measured memory_bytes: 15408
use std::io;
use std::io::prelude::*;

fn main() {
    let stdin = io::stdin();
    let mut lock = stdin.lock();
    let mut iter = lock.lines();

    iter.next();
    println!(
        "{}",
        iter.next()
            .unwrap()
            .unwrap()
            .split(' ')
            .scan(0, |acc, s| {
                *acc = if s == "1" { *acc + 1 } else { 0 };
                Some(*acc)
            }).max()
            .unwrap()
            + 1
            );
}



Measured memory_bytes: 5032
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() 
{
	while (1) {
		int a, b, c, d, e;
		cin >> a;
		if (a == 0)break;
		cin >> b >> c >> d >> e;
		if (a==b&&b==c&&c==d&&d==e) { cout << "3\n3\n3\n3\n3\n"; continue; }
		vector<int>f(5);
		vector<int>q(5);
		f[0] = a;
		f[1] = b;
		f[2] = c;
		f[3] = d;
		f[4] = e;
		q[0] = a;
		q[1] = b;
		q[2] = c;
		q[3] = d;
		q[4] = e;
		sort(f.begin(), f.end());
		if(f[0]==1&&(f[1]==2||f[2]==2||f[3]==2)&&f[4]==3){cout<<"3\n3\n3\n3\n3\n"; continue;}
		if (f[0] == 2) {
			for (int i = 0; i < 5; i++) {
				if (q[i] == 2)cout << 1 << endl;
				else cout << 2 << endl;
			}
			continue;
		}
		if (f[4] == 3) {
			for (int i = 0; i < 5; i++) {
				if (q[i] == 3)cout << 1 << endl;
				else cout << 2 << endl;
			}
			continue;
		}
		else {
			for (int i = 0; i < 5; i++) {
				if (q[i] == 1)cout << 1 << endl;
				else cout << 2 << endl;
			}
			continue;
		}
	}
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
char s[100009],t[100009];
int nxt[100009][28];
int main()
{
    scanf("%s%s",s+1,t+1);
    int len = strlen(s+1);
    for(int i=len; i>0; i--)
    {
        for(int j='a'; j<='z'; j++) nxt[i-1][j-'a'] = nxt[i][j-'a'];
        nxt[i-1][s[i]-'a'] = i;
    }
    int lent=strlen(t+1);
    int p=0;
    ll cnt=0;
    bool flag=false;
    for(int i=1;i<=lent;i++)
    {
        if(nxt[p][t[i]-'a'])p=nxt[p][t[i]-'a'];
        else if(!nxt[p][t[i]-'a']&&p==0){
            flag=true;break;
        }
        else{
            i--;p=0;cnt++;
        }
    }
    if(flag)cout<<-1<<endl;
    else cout<<1ll*cnt*len+1ll*p<<endl;
    return 0;
}

Measured memory_bytes: 11392
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M,syutuzyousya=0,siaisu=0;
    vector<int> a(300);

    cin>>N;
    cin>>M;

    for(int i=0;i<M;i++){
        cin>>a[i];
    }

    syutuzyousya=N-M;

    while(syutuzyousya!=1&&syutuzyousya>0){
        siaisu=siaisu+syutuzyousya/2;
        syutuzyousya=syutuzyousya/2+syutuzyousya%2;
    }

    cout<<siaisu<<endl;

}

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

int main() {
  int n, d;
  cin >> d >> n;
  switch(d) {
    case 0:
      printf("%d\n", n + (n == 100 ? 1 : 0));
      break;
    case 1:
      printf("%d\n", 100*n + (n == 100 ? 100 : 0));
      break;
    default:
      printf("%d\n", 10000*n + (n == 100 ? 10000 : 0));
   }
  return 0;}


Measured memory_bytes: 256
c = [list(map(int,input().split())) for _ in range(3)]
a = [0]*3
b = c[0]
a[1] = c[1][0]-b[0]
a[2] = c[2][0]-b[0]
flag = False
ans = "Yes"
for i in range(3):
    if flag:
        break
    for j in range(3):
        if c[i][j] != a[i]+b[j]:
            ans = "No"
            flag = True
            break
print(ans)

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	string N;
  cin >> N;
  int sw = 0,count = 0,max = 0;
  froop1(0,3){
    if(N[i] == 'R'){
      count++;
    }else{
      if(max < count)max = count;
      count = 0;
    }
  }
  if(count > max)max = count;
  cout << max << endl;
      
    

return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n,a,b;

    Scd(n);

    if(n == 1){
        printf ("Hello World\n");
        return 0;
    }
    if(n == 2){
         Scd2(a,b);
         printf ("%d\n", a+b);
    }

    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize(2) 
#include<bits/stdc++.h>
#define rg register
#define il inline
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int n,x,y,z,ok,all;
ll ans=1,dp[45][1<<18];
int main(){
	scanf("%d%d%d%d",&n,&x,&y,&z);
	for(int i=1;i<=n;++i)ans=10*ans%mod;
	all=(1<<x+y+z)-1;
	ok=(1<<x+y+z-1)|(1<<y+z-1)|(1<<z-1);
	dp[0][0]=1;
	for(int i=1;i<=n;++i)
		for(int j=0;j<=all;++j)
			if(dp[i-1][j])
				for(int k=1;k<11;++k){
					int s=((j<<k)|(1<<k-1))&all;
					if((s&ok)==ok)continue;
					(dp[i][s]+=dp[i-1][j])%=mod;
				}
	for(int i=0;i<=all;++i)(ans+=mod-dp[n][i])%=mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 82176
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int N=1010;
inline int read(){
    int x=0;char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x;
}
int n;
vector<int>e[N*N];
int Tot;

map<pii,int>mp;
inline int asa(int i,int j){
	if(i>j)swap(i,j);
	if(!mp[make_pair(i,j)]){
		mp[make_pair(i,j)]=++Tot;
	}
	return (mp[make_pair(i,j)]);
}

int dp[N*N],deg[N*N];
queue<int>q;
bool topu(){
	int num=0;
	for(register int i=1;i<=Tot;i++){
		if(deg[i]==0)q.push(i),dp[i]=1;
	}
	while(!q.empty()){
        int x=q.front();q.pop();num++;
        for(register int i=0;i<e[x].size();i++){
			int y=e[x][i];
			deg[y]--;dp[y]=max(dp[y],dp[x]+1);
			if(deg[y]==0)q.push(y);
		}
    }
    if(num==Tot)return 1;
    return 0;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		int lst=read();
		for(int j=2;j<n;j++){
			int a=read();
			int id1=asa(i,lst),id2=asa(i,a);
			e[id1].push_back(id2);deg[id2]++;
			lst=a;
		}
	}
	if(topu()){
		int ans=0;
		for(int i=1;i<=Tot;i++)ans=max(ans,dp[i]);
		printf("%d\n",ans);
	}
	else puts("-1");
}


Measured memory_bytes: 78848
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	A, B = getlist()
	if 2 * B >= A:
		print(0)
	else:
		print(A - 2 * B)
		
	


if __name__ == '__main__':
	main()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#include<cstdlib>
using namespace std;
typedef long l;
typedef long long ll;
typedef unsigned long long ull;

#define pii pair<int,int>
#define pil pair<int,long>
#define pli pair<long,int>
#define pll pair<long,long>

#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pii>
#define vul vector<ull>
#define vvul vector<vector<ull>>
#define vs vector<string>
#define vl vector<long>

#define lp(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define loopd(i,a,n) for(i=a;i>n;i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define MAX 1000000007
        
vvul arr;
vvul jump;
int n;

void dp(int i){
  if(i>=0){
    jump[i][0] = arr[i][0] + max(jump[i+1][1],jump[i+1][2]);
    jump[i][1] = arr[i][1] + max(jump[i+1][0],jump[i+1][2]);
    jump[i][2] = arr[i][2] + max(jump[i+1][0],jump[i+1][1]);
    dp(i-1);
  }
}  

int main(){
  int i;
  cin>>n;
  arr.resize(n);
  jump.resize(n);
  lp(i,n){
    arr[i].resize(3);
    jump[i].resize(3);
    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    jump[i][0]=jump[i][1]=jump[i][2]=0;
  }
  jump[n-1][0]=arr[n-1][0];
  jump[n-1][1]=arr[n-1][1];
  jump[n-1][2]=arr[n-1][2];
  if(n>1){
    dp(n-2);
  } 
  cout<<max(jump[0][0], max(jump[0][1], jump[0][2]))<<endl;
  return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
	long long a;
	string s;
	cin>>a>>s;
	int b=(s[0]-'0')*100+(s[2]-'0')*10+s[3]-'0';
	cout<<(long long)((a*b)/100);
}

Measured memory_bytes: 3624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BTrickOrTreat solver = new BTrickOrTreat();
        solver.solve(1, in, out);
        out.close();
    }

    static class BTrickOrTreat {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int n = s.nextInt();
            int k = s.nextInt();
            HashSet<Integer> set = new HashSet<>();
            for (int i = 0; i < k; i++) {
                int size = s.nextInt();
                for (int j = 0; j < size; j++) {
                    set.add(s.nextInt());
                }
            }

            out.println(n - set.size());
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32964
<?php
$fl=[];
for($i=0;$i<4;$i++){
  $fl[$i]=[];
  for($j=0;$j<3;$j++){
    $fl[$i][$j]=[];
    for($k=0;$k<10;$k++)$fl[$i][$j][$k]=0;
  }
}

$n=trim(fgets(STDIN));

for($i=0;$i<$n;$i++){
  list($b,$f,$r,$v)=explode(' ',trim(fgets(STDIN)));
  $fl[$b-1][$f-1][$r-1]+=$v;
}

$o=[];
$sp='';for($i=0;$i<20;$i++){$sp.='#';}
for($i=0;$i<4;$i++){
  for($j=0;$j<3;$j++){
    $o[]=' '.implode(' ',$fl[$i][$j]);
  }
  if($i<3)$o[]=$sp;
}
print implode(PHP_EOL,$o);
?>

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

int main() {
  string s;
  cin >> s;
  int count = 0;
  for (int i = 0; i < 3; i++) {
  	if (s.at(i) == '1') {
    	count ++;
    }
  }
  cout << count << endl;
}

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

N = int(input())
d = [[] for _ in range(N)]
iro = [0] * (N)

def dfs(n, v, k):
    for i in d[n]:
        if k % 2 != 0:
            iro[n] = 1
        if v == i[0]:
            continue
        dfs(i[0], n, k + i[1])

for i in range(N - 1):
    u, v, w = map(int, input().split())
    v -= 1
    u -= 1
    d[u].append((v, w))
    d[v].append((u, w))

dfs(0, 0, 0)
for i in iro:
    print(i)

Measured memory_bytes: 81328
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;

ll gcd( ll a, ll b ){//最大公約数
    ll tmp;
    if( a < b ) { tmp = a; a = b; b = tmp; }
    if( b < 1 ) return -1;

    if( a % b == 0 ) return b;
    return gcd( b, a % b );
}
ll lcm(ll a, ll b){//最小公倍数
    return a * b / gcd(a, b);
}
ll sosuu(ll x){
    for(int i = 2; i < x; i++){
        if(x % i == 0) return false;
    }

    return true;
}


//入力

ll hp[200010];

int main(){

    int h, n;
    cin >> h >> n;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int in;
        cin >> in;

        ans += in;
    }

    if(h <= ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<int> a, b, d;
ll dif;

int main()
{
    int n, ans;
    cin>>n;
    ans = 0;

    REP(i,n) {
        int t;
        cin>>t;
        dif += t;
        a.push_back(t);
    }
    REP(i,n) {
        int t;
        cin>>t;
        dif -= t;
        b.push_back(t);
    }
    if (dif < 0) {
        cout<<-1<<endl;
        return 0;
    }
    REP(i,n) {
        /*if (a[i] < b[i]) {
            dif -= b[i] - a[i];
        } else if (a[i] > b[i]) {
            d.push_back(a[i] - b[i]);
        } else {
            ans--;
        }*/
        if (a[i] != b[i])
            d.push_back(a[i] - b[i]);
    }
    SORT(d);
    REPALL(i,d) {
        /*if (d[i] <= dif) {
            dif -= d[i];
        } else {
            ans--;
        }*/
        if (d[i] < 0) {
            //dif += d[i];
            ans++;
        } else {
            if (d[i] <= dif) {
                dif -= d[i];
            } else {
                ans++;
            }
        }
    }
    //if (dif > 0) ans++;

    cout<<ans<<endl;

    return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  vector<int> a(5);
  REP(i, 5) cin >> a[i];
  int k; cin >> k;
  if (a[4] - a[0] <= k) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}


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

using namespace std;

#define N 100000

char str[N + 2];

int main(){
	int n, i;

	scanf("%[^\r\n]%n", str, &n);

	for (i = 0; i < n - 1; i++){
		if (str[i] == 'A' and str[i + 1] == 'C'){
			break;
		}
	}

	if (i < n - 1){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 256
s=input()
q=int(input())
cn=0
l1=""
l2=""
for i in range(q):
    p=input()
    if p=="1":
        cn+=1
    else:
        _,f,c=p.split()
        if f=="1":
            if cn%2==0:
                l1+=c
            else:
                l2+=c
        else:
            if cn%2==1:
                l1+=c
            else:
                l2+=c
if cn%2==1:
    s=s[::-1]
    l1,l2=l2,l1
print(l1[::-1]+s+l2)


Measured memory_bytes: 4340
#include <iostream>

 using namespace std;
 typedef long long ll;

 int main(void){
 ll H,W;
　　　　 cin >> H >> W;

 　　　　if(H == 1 || W == 1){
 cout << 1 << endl;
 } 　　　else {
 　　cout << (H * W + 1) / 2 << endl;
 }

 　　　　　　　　　　　return 0;
 }


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

using namespace std;

vector<vector<int>> graph;
vector<int> ret;
vector<bool> visited;

void dfs(int from, int x) {
    x += ret[from];
    ret[from] = x;
    visited[from] = true;

    for (auto to:graph[from]) {
        if (!visited[to])dfs(to, ret[from]);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    graph = vector<vector<int>>(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    ret = vector<int>(n);
    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        ret[p - 1] += x;
    }
    visited = vector<bool>(n);
    dfs(0, 0);

    for (int i = 0; i < n; i++) {
        if (i > 0)cout << " ";
        cout << ret[i];
    }
    cout << endl;
    return 0;
}


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

int main(){
    int n;cin>>n;vector<int> s(n);for(int i=0;i<n;i++) cin>>s[i];
    int q;cin>>q;vector<int> t(q);for(int j=0;j<q;j++) cin>>t[j];
    int cnt=0;
    sort(s.begin(),s.end());sort(t.begin(),t.end());
    for(int i=0;i<n;i++){
        if(i>0) if(s[i-1]==s[i]) continue;
        for(int j=0;j<q;j++){
            if(s[i]==t[j]) cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <cstring>
#define und &&
#define oder ||
using namespace std;
int main()
{
    int X;
    while(cin>>X)
    {
        if(X==3 oder X==5 oder X==7)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int x,index1,index2,min=51;
    cin>>x;
    int arr[x];
    bool isSorted=true;

    for(int i=0; i<x; i++)
    {
        cin>>arr[i];
    }
    for(int i=0; i<x-1; i++)
    {
        if(isSorted)
        {
            index1=i;
        }
        if(arr[i]>=arr[i+1])
        {
            isSorted=false;
        }
    }

    if(isSorted)
    {
        cout<<"YES"<<endl;
        return 0;
    }
    else
    {
        for(int i=index1; i<x; i++)
        {
            if(arr[i]<=min)
            {
                min=arr[i];
                index2=i;
            }
        }

        int temp=arr[index1];
        arr[index1]=arr[index2];
        arr[index2]=temp;

        //Display
    }


    isSorted=true;
    for(int i=0; i<x-1; i++)
    {
        if(arr[i]>arr[i+1])
        {
            isSorted=false;
        }
    }

    if(isSorted)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
}


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

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, a = 0, b = 0;
	cin >> n;
	rep(i, n) {
		string s, t;
		cin >> s >> t;
		if (s < t)b += 3;
		else if (s > t)a += 3;
		else if (s == t) { a++; b++; }
	}
	cout << a << " " << b << endl;
}


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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ',') cerr << *sdbg++; cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

ll a[100];

void next(int n, ll a[]){
	a[0] -= n;
	for (int i = 1; i < n; ++i)
		++a[i];
	int k = 0;
	for (; k < n && a[k] < a[k + 1]; ++k)
		swap(a[k], a[k + 1]);
}

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%lld", a + i);
	sort(a, a + n, greater<ll>());

	ll ans = 0;
	for (int i = 1; i < n; ++i){
		if (a[i - 1] - a[i] >= n + 1){ // - n + (i - 1), +(i), dis: n + 1
			ll d = (a[i - 1] - a[i]) / (n + 1);
			for (int j = 0; j < i; ++j)
				a[j] += d * (-n + (i - 1));
			for (int j = i; j < n; ++j)
				a[j] += d * i;

			ans += d * i;
			sort(a, a + n, greater<ll>());

			eput(i, d, ans, vector<int>(a, a + n));
		}
		while (a[0] >= a[i] + n)
			next(n, a), ++ans;
	}
	if (a[n - 1] >= n){
		ll d = a[n - 1] - n;
		ans += d * n;
		for (int i = 0; i < n; ++i)
			a[i] -= d;
	}
	while (a[0] >= n)
		next(n, a), ++ans;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

#define inf  1000000007
#define ll long long
#define PA pair<int,int>
#define PPAP pair<int,PA>
#define  MP make_pair
#define  PB push_back

using namespace std;
long long  mod = 1000000007;

int main(){
	int h,k;
	cin >> h >> k;
	vector<string> v(h);
	for(int i=0;i<h;i++){
		cin >> v[i];
	}
	int a[30]={};
	for(int i=0;i<h;i++){
		for(int j=0;j<k;j++){
			a[v[i][j]-'a']++;
		}
	}
	int x=0,y=0,z=0,w=0;
	for(int i=0;i<26;i++){
		if(a[i]%4==0){
			x++;
		}else if(a[i]%4==1){
			y++;
		}else if(a[i]%4==2){
			z++;
		}else{
			w++;
		}
	}
	if(h%2==0&&k%2==0){
		if(x!=26){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
		}
	}else if((h+k)%2==1){
		int p;
		if(h%2==0){
			p = h/2;
		}else{
			p = k/2;
		}
		if(y==0&&w==0){
			if(p>=z&&(p-z)%2==0){
				cout << "Yes" << endl;
			}else{
				cout << "No" << endl;
			}
		}else{
			cout << "No" << endl;
		}
	}else{
		int p,q;
		p = h/2+k/2;
		bool flag=0;
		if(y==0){
			if(w!=1){
				flag =0;
			}else{
				if(p-1>=z&&(p-1-z)%2==0){
					flag = 1;
				}else{
					flag = 0;
				}
			}
		}else if(y==1){
			if(w!=0){
				flag =0;
			}else{
				if(p>=z&&(p-z)%2==0){
					flag = 1;
				}else{
					flag = 0;
				}
			}
		}else{
			flag = 0;
		}
		if(flag){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
def f(n):
    s=str(n)
    return sum([int(s[i]) for i in range(len(s))])

sunuke=[]
for i in range(16):
    for j in range(1,500):
        sunuke.append(j*(10**i)-1)

sunuke=list(set(sunuke))
sunuke.sort()
sunuke.pop(0)
L=len(sunuke)

tmp1,tmp2=sunuke[L-1],f(sunuke[L-1])
ans=[sunuke[L-1]]
for i in range(len(sunuke)-2,-1,-1):
    x=sunuke[i]
    if x*tmp2<=tmp1*f(x):
        ans.append(x)
        tmp1,tmp2=x,f(x)

ans.sort()

    

for i in range(int(input())):
    print(ans[i])

Measured memory_bytes: 3948
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2010, MOD = 1e9 + 7;
int dp[2][N],n,k,s,p,sum[N],ans,jc[N],inv[N];
typedef long long ll;
ll power(ll a,int b) {
  ll res = 1;
  while (b) {
    if (b&1) (res *= a) %= MOD;
    (a *= a) %= MOD;
    b >>= 1;
  }
  return res;
}
ll comb(int a,int b) {
  if (a < 0 || b < 0 || a < b) return 0;
  return 1ll * jc[a] * inv[b] % MOD * inv[a-b] % MOD;
}
signed main() {
  scanf("%lld%lld",&n,&k);
  jc[0] = 1;
  for (int i = 1 ; i <= n ; ++ i)
    jc[i] = 1ll * jc[i-1] * i % MOD;
  inv[n] = power(jc[n],MOD-2);
  for (int i = n-1 ; i >= 0 ; -- i)
    inv[i] = 1ll * inv[i+1] * (i+1) % MOD;
  s = k-1;
  p = 0;
  sum[2] = 1;
  sum[3] = -1;
  for (int i = 1 ; i <= s ; ++ i) {
    p ^= 1;
    memset(dp[p],0,sizeof dp[p]);
    for (int j = 1 ; j <= i+1 ; ++ j)
      (sum[j] += sum[j-1]) %= MOD;
    for (int j = 1 ; j <= i+1 ; ++ j)
      (dp[p][j] += sum[j]) %= MOD, sum[j] = 0;
    sum[i+2] = 0;
    for (int j = 1 ; j <= i+1 ; ++ j) {
      (sum[2] += dp[p][j]) %= MOD;
      (sum[j+2] -= dp[p][j]) %= MOD;
    }
  }
  for (int i = 1 ; i <= s + 1 ; ++ i) {
    (ans += 1ll * comb(n-k+i-1,i-1) * dp[p][i] % MOD);
    ans %= MOD;
  }
  if (k == 1) ans = 1;
  if (n > k)
    ans = 1ll * power(2,n-k-1) * ans % MOD;
  ans = (ans + MOD) % MOD;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 384
#include <iostream>


int divide (int a, int ans) {
    int count = 0;
    for(int i = 0; a != 0; ++i){
        if(a % 2 == 0){
            a = a / 2;
            ++count;
        } else break;
    }
    if(ans > count) return count;
    return ans;
}

int main () {
    int n, ans = 10000000;
    std::cin >> n;
    int a[n];
    
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
        ans = divide(a[i], ans);
    }
    
    std::cout << ans << std::endl;
}

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

int main() {
    int n;
    cin >> n;
    int a, b,judge = 0,ans = 0;
    for (int i = 0; i < n; i++){
        cin >> a >> b;
        if(a == b)judge ++;
        else judge = 0;
        if(judge == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3620
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.array;

void main() {
	while (true) {
		auto N = readln.chomp;
		if (N == "0") break;
		auto k = readln.split.map!(to!int).array;
		if (reduce!((a,b)=> a > b ? a : b)(k) < 2UL) {
			writeln("NA");
			continue;
		}
		auto count = filter!((a)=> a != 0)(k).array.length;
		writeln(count + 1);
	}
}

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

const int MAXN = 5e5 + 5;
const int MOD = 1e9 + 7;
const long long BASE = 2e9;

void open() {
    freopen("river.in", "r", stdin);
    freopen("river.out", "w", stdout);
}

int N;
struct Node {
    int b, k;
    bool operator<(const Node &a) const {
        return b < a.b;
    }
} a[MAXN];
struct In {
    int l, r;
    bool operator<(const In &a) const {
        return r < a.r || r == a.r && l < a.l;
    }
} t[MAXN];

void input() {
    scanf("%d", &N);
    for (int i = 1; i <= N; ++i) {
        scanf("%d%d", &a[i].b, &a[i].k);
    }
}

void rebuild() {
    static long long Tmp[MAXN], A[MAXN];
    for (int i = 1; i <= N; ++i) {
        Tmp[i] = A[i] = BASE * a[i].k + a[i].b;
    }
    std::sort(Tmp + 1, Tmp + 1 + N);
    int cnt = std::unique(Tmp + 1, Tmp + 1 + N) - Tmp - 1;
    for (int i = 1; i <= N; ++i) {
        a[i].k = std::lower_bound(Tmp + 1, Tmp + 1 + cnt, A[i]) - Tmp;
    }
    std::sort(a + 1, a + 1 + N);
}

void getLR() {
    int lmin = a[N].k, rmax = a[1].k;
    for (int i = N; i >= 1; --i) {
        lmin = std::min(lmin, a[i].k);
        t[i].l = lmin;
    }
    for (int i = 1; i <= N; ++i) {
        rmax = std::max(rmax, a[i].k);
        t[i].r = rmax;
    }
    std::sort(t + 1, t + 1 + N);
}

void getAns() {
    static long long F[MAXN];
    F[0] = 1;
    int pos = 1;
    for (int i = 1; i <= N; ++i) {
        F[i] = F[i - 1];
        while (t[pos].r < i) ++pos;
        while (t[pos].r == i) {
            F[i] <<= 1;
            if (t[pos].l != 1) F[i] -= F[t[pos].l - 2];
            F[i] %= MOD;
            ++pos;
        }
    }
    printf("%lld\n", ((F[N] - F[N - 1]) % MOD + MOD) % MOD);
}

int main() {
    //open();
    input();
    rebuild();
    getLR();
    getAns();
    return 0;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                             //n is odd
        return x*power(x*x,(n-1)/2);
}
int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);  
}
ll powermod(ll x, ll y, ll p)  
{  
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;  
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}
 
int main()
{
    ld n,d,x,y;
    int c=0;
    cin>>n>>d;
    while(n--)
    {
        cin>>x>>y;
        ld val=sqrt(x*x +y*y);
        if(val<=d)
        c++;
        
    }
        
        cout<<c<<endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#define INF 0x3f3f3f3f
#define MAX_N 1001000
using namespace std;
void optimize_cpp_stdio()
{
    std::ios::sync_with_stdio(false);
    std::cout.tie(NULL);
    std::cin.tie(NULL);
}
int n, r;
int main()
{
    scanf("%d %d", &n, &r);
    if(n < 10)
        r = r + 100 * (10 - n);
    printf("%d\n", r);
}


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

double prob(int n, int d) {
    if (d == 0) return 1.0 / n;
    else return (double)(n - d) * 2 / n / n;
}

int main() {
    int n, m, d; cin >> n >> m >> d;
    cout << fixed << setprecision(7) << prob(n, d) * (m - 1);
}

Measured memory_bytes: 256
M,K = map(int,input().split())

if M == 0:
    if K == 0:
        print(0,0)
    else:
        print(-1)
elif M == 1:
    if K == 0:
        print(0,0,1,1)
    else:
        print(-1)
else:
    if K == 0:
        A = [i//2 for i in range(2**(M+1))]
        print(*A)
    elif 0 < K < 2**M:
        A = []
        for i in range(K):
            A.append(i)
        for i in range(2**M-K-1):
            A.append(2**M-i-1)
        A.append(0)
        for i in range(2**M-K):
            A.append(K+i)
        for i in range(K-1):
            A.append(K-i-1)
        A.append(K)
        print(*A)
    else:
        print(-1)

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

using namespace std;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX = 1e9 + 5;

int main() {
    long long n;
    cin >> n;
    string ans;
    while (n > 0) {
        n--;
        ans = (char)('a' + n%26) + ans;
        n /= 26;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
struct s
{
    int x, y, r;
};
long double cost[1005];
struct z
{
    int idx;
    bool operator < (const z &o) const
    {
        return cost[idx] > cost[o.idx] ;
    }
};
s f;
s p[(int)1005];
long double dist(s x, s y)
{
    long double X = x.x-y.x;
    X*=X;
    long double Y = x.y-y.y;
    Y*=Y;
    X+=Y;
    X = sqrt(X);
    X -= x.r;
    X -= y.r;
    return max((long double) 0.0000,X);
}
int main()
{
    for(int i = 0 ; i < 1005; i++) cost[i] = 1e18;
    cin >>p[0].x >> p[0].y ;
    p[0].r = 0;
    cin >> f.x >> f.y;
    f.r = 0 ;
    int n ;
    cin >> n;
    for(int i = 1 ; i <= n ; i++)
        cin >>p[i].x >> p[i].y >> p[i].r;
    p[n+1].x = f.x;
    p[n+1].y = f.y;
    p[n+1].r = 0;
    priority_queue<z> pq;
    cost[0] = 0;
    pq.push({0});
    bool vis[1005] = {};
    while(!pq.empty())
    {
        z tp = pq.top();
        pq.pop();
        if(vis[tp.idx]) continue;
        vis[tp.idx] = 1;
//        cout << tp.idx << " " << tp.cost << endl;
        for(int i = 0 ; i <= n+1 ; i++)
        {
            if(i == tp.idx) continue;
            if(cost[i] > cost[tp.idx]+dist(p[i],p[tp.idx])>= 1e-13)
            {
                vis[i] = 0;
                cost[i] = cost[tp.idx]+dist(p[i],p[tp.idx]);
                pq.push({i});
            }
        }
    }
    cout << fixed << setprecision(13) << cost[n+1] << "\n";
}


Measured memory_bytes: 1400