akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;
use nalgebra::min;

#[fastout]
fn main() {
    input! {
    n: usize,
    a: [usize; n + 1],
    b: [usize; n]
    }
    let mut ans = 0;
    let mut tmp = a[0];
    for i in 0..n {
        ans += min(tmp + a[i + 1], b[i]);
        tmp = if b[i] >= tmp + a[i + 1] {0} else { tmp + a[i + 1] - b[i]};
        if tmp > a[i + 1] {tmp = a[i + 1]}
    }
    println!("{}", ans);
}


Measured memory_bytes: 5564
import math

def chk(n):
	if n < 2 == 0:
		return False
	if n == 2:
		return True
	if n % 2 == 0:
		return False

	x = int(math.sqrt(n))
	sw = True
	i = 3
	while i <= x:
		if n % i == 0:
			sw = False
			break
		i += 1
	return sw

cnt = 0
while 1:
	try:
		n = int(input())
		sw = chk(n)
		if sw == True:
			cnt += 1
	except:
		break
print(cnt)


Measured memory_bytes: 5676
def divisors(N):
    U = int(N ** 0.5)
    res = []
    any(res.extend((i, N // i)) for i in range(1, U) if N % i == 0)
    if N % U == 0:
        res.append(U)
    res.sort()
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll n,k; cin >> n >> k;
  vector<ll> M, P;
  ll zero = 0;
  loop(i,0,n) {
    ll a; cin >> a;
    if (a == 0) zero++;
    else if (a < 0) M.push_back(a);
    else P.push_back(a);
  }
  sort(M.begin(), M.end());
  sort(P.begin(), P.end());
  ll m = M.size(), p = P.size();

  if (k <= m*p) {
    auto f = [&](ll x) {
      ll num = 0;
      // ある正整数P[i]に対して、積がx以下となるような相方の数を見つける
      // Mは昇順なので、左の方が積が大きい.
      // 満たさない箇所が一度出ればそれ以降はすべて満たさない
      // i.e. 2で満たさないとする
      // 1  1  2  2  3
      //   ok ng
      // 2個
      loop(i,0,p) {
        ll ok = -1, ng = m;
        while (ok + 1 < ng) {
          ll mid = (ok+ng)>>1;
          if (P[i]*M[mid]<=x) ok = mid;
          else ng = mid;
        }
        num += ng;
      }
      return num;
    };

    ll ng = -1000000000000000001, ok = 1000000000000000001;
    while (ng+1<ok) {
      ll mid = (ng+ok)>>1;
      if (f(mid) < k) ng = mid;
      else ok = mid;
    }
    cout << ok << endl;
    return 0;
  }

  k -= m*p;

  ll numZero = zero ? zero*(zero-1)/2 : 0;
  numZero += zero * (m+p);
  if (k <= numZero) {
    cout << 0 << endl;
    return 0;
  }

  k -= numZero;

  // どうせ負同士で積をとるので符号は正として昇順
  // でも組み合わせの数としては依然MとPを別々に計算する必要はある
  loop(i,0,m) M[i] *= -1;
  reverse(M.begin(), M.end());

  auto f = [&](ll x) {
    ll num = 0;
    // 各正整数に対して、ペアに出来る正整数の数を求める.
    // ただし、自分自身とは組めないので範囲に自身も含まれる場合は-1
    // (i,j) (j,i)の両方をカウントしているので最後に2で割る.
    loop(i,0,p) {
      ll ok = -1, ng = p;
      while (ok + 1 < ng) {
        ll mid = (ok+ng)>>1;
        if (P[i]*P[mid]<=x) ok = mid;
        else ng = mid;
      }
      if (i < ng) ng--;
      num += ng;
    }
    loop(i,0,m) {
      ll ok = -1, ng = m;
      while (ok + 1 < ng) {
        ll mid = (ok+ng)>>1;
        if (M[i]*M[mid]<=x) ok = mid;
        else ng = mid;
      }
      if (i < ng) ng--;
      num += ng;
    }
    return num>>1;
  };

  ll ng = -1000000000000000001, ok = 1000000000000000001;
  while (ng+1<ok) {
    ll mid = (ng+ok)>>1;
    if (f(mid) < k) ng = mid;
    else ok = mid;
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 5096
import bisect

n=int(raw_input())
x=map(int,raw_input().split())+[float('inf')]
l=int(raw_input())
q=int(raw_input())
r=[[0]*20 for _ in xrange(n)]

for i in xrange(n):
    if x[i]+l==x[bisect.bisect_left(x,x[i]+l)]:
        r[i][0]=bisect.bisect_left(x,x[i]+l)
    else:
        r[i][0]=bisect.bisect_left(x,x[i]+l)-1

for k in xrange(19):
    for i in xrange(n):
        r[i][k+1]=r[r[i][k]][k]
        
for i in xrange(q):
    a,b=map(int,raw_input().split())
    a-=1
    b-=1
    ans=0
    if a>b:
        a,b=b,a
    while 1:
        if bisect.bisect_left(r[a],b)>=1:
            ans+=1<<(bisect.bisect_left(r[a],b)-1)
            a=r[a][bisect.bisect_left(r[a],b)-1]
        else :
            ans+=1<<bisect.bisect_left(r[a],b)
            break
    print(ans)

Measured memory_bytes: 60328
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        Set<Integer> set = new HashSet<>();
        set.add(a);
        set.add(b);
        set.add(c);
        
        if(set.size() == 2){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716
N, X, M = map(int, input().split())

if N == 1:
    print(X)
    exit()

A = [-1] * (10**5 + 1)
A[1] = X

# %M は答えをMOD Mにしなさいといってくれているだけ
# M はたかだか10^5なので10^5繰り返すとどこかで循環する。循環するまで繰り返す。
S = set([X])
i = 2
while True:
    A[i] = ((A[i - 1])**2) % M
    if A[i] in S:
        break
    S.add(A[i])
    i += 1
# i -= 1
# print(f'{A[:20]=}, {S=}, {i=}')

end_idx = i - 1
start_idx = 0
for start_idx in range(i):
    if A[start_idx] == A[i]:
        break

num_circles = end_idx - start_idx + 1
# print(f'{start_idx=}, {end_idx=}, {num_circles=}')

A[0] = 0
if start_idx > N:
    ans = sum(A[:N + 1])
    print(ans)
    exit()

# print(f'{A[:20]=}')
# print(f'{A[:start_idx]=}')
v1 = sum(A[:start_idx])

remain_N = N - start_idx + 1
# print(f'{remain_N=}')

div, mod = divmod(remain_N, num_circles)
# print(f'{div=}, {mod=}')
# print(f'{A[start_idx:end_idx + 1]=}')
sum_circles = sum(A[start_idx:end_idx + 1])
# print(f'{sum_circles=}')

v2 = sum_circles * div

if mod == 0:
    v3 = 0
else:
    # print(f'{A[start_idx:start_idx + mod]=}')
    v3 = sum(A[start_idx:start_idx + mod])

ans = v1 + v2 + v3
print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
#define endl "\n";
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define POSITIVE_INFINITY 9223372036854775807
#define NEGATIVE_INFINITY -9223372036854775807
#define MOD 1000000007

const int N = 1000002;
bool prime[N + 2];
vector<int>ar;
int sz = -1;

void F()
{
    prime[0] = true;
    prime[1] = true;

    for (int i = 4; i <= N; i += 2)
        prime[i] = true;
    for (int i = 3; i * i <= N; i += 2)
    {
        if (!prime[i])
        {
            for (int j = (i * i); j <= N; j += (i << 1))
                prime[j] = true;
        }
    }
    ar.push_back(2);

    for (int i = 3; i <= N; i += 2)
    {
        if (!prime[i])
            ar.push_back(i);
    }
    sz = ar.size();
}

int main()
{
    FASTER;
    F();
    ll n, p;
    cin >> n >> p;
    ll ans = 1;
    if (n == 1)
    {
        cout << p << endl;
        return 0;
    }

    vector<pair<long, long>> v;
    for (int i = 0; ar[i] * ar[i] <= p && i < sz; i++)
    {
        if (p % ar[i] == 0)
        {
            ll cnt = 0;
            while (p % ar[i] == 0)
            {
                cnt++;
                p /= ar[i];
            }
            
            cnt /= n;
            while (cnt--)
            {
                ans *= ar[i];
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1916
N = int(input())

ans = []
i = 1
while len(ans)<N:
  tmp = i*10 +1
  i += 1
  flag = 0
  for j in range(3, tmp//3+1):
    if tmp%j == 0:
      flag = 1
      break
  if flag == 0:
    ans.append(tmp)

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

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();

        int ans = 1;
        int num = k;

        for (int i = 0; i < 1000000; i++) {
            if (num > n) {
                System.out.println(ans);
                break;
            } else {
                num *= k;
                ans++;
            }
        }
    }


}


Measured memory_bytes: 25300
#include <bits/stdc++.h>
#define N 200007
#define mod 998244353
using namespace std;
typedef long long ll;

inline int rd() {
  int x = 0;
  char c = getchar();
  while(!isdigit(c)) c = getchar();
  while (isdigit(c)) {
    x = x * 10 + (c ^ 48);
    c = getchar();
  }
  return x;
}

int c[N];

inline int mo(int x) {
  if (x < 0) return x + mod;
  return x >= mod ? x - mod : x;
}

inline int lowbit(int x) {
  return x & (-x);
}

inline void add(int p, int x) {
  for(;p < N; p += lowbit(p)) c[p] = mo(c[p] + x);
}

inline int query(int p) {
  int res = 0;
  for (; p; p -= lowbit(p)) res = mo(res + c[p]);
  return res;
}

int n, k, l[11], r[11];

int main() {
  n = rd(); k = rd();
  for (int i = 1; i <= k; ++i) {
    l[i] = rd(); r[i] = rd();
    add(1 + l[i], 1); add(2 + r[i], -1);
  }
  for (int i = 2, x; i <= n; ++i) {
    x = query(i);
    for (int j = 1; j <= k; ++j) {
      add(i + l[j], x); add(i + r[j] + 1, -x);
    }
  }
  printf("%d\n", query(n));
  return 0;
}


Measured memory_bytes: 4516
#include<stdio.h>

int main(void)
{
  int i=0,j=0,k=0;
  char a[101],b[101],c[101],turn = 'a';
  scanf("%s",a);
  scanf("%s",b);
  scanf("%s",c);
  while(1)
    {
      if(turn == 'a')
	{
	  if(a[i] == '\0')
	    {
	      printf("A\n");
	      return 0;
	    }
	  turn = a[i];
	  i++;
	}
      else if(turn == 'b')
	{
	  if(b[j] == '\0')
	    {
	      printf("B\n");
	      return 0;
	    }
	  turn = b[j];
	  j++;
	}
      else if(turn == 'c')
	{
	  if(c[k] == '\0')
	    {
	      printf("C\n");
	      return 0;
	    }
	  turn = c[k];
	  k++;
	}
    }
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstdlib>
#include <clocale>
#include<cmath>
#include<sstream>
#include<set>
#include<stack>
using namespace std;
const int INF=0x3f3f3f3f;
const int MX=1e5+10;
typedef unsigned long long ull;
typedef pair<int ,int> p; 
vector<int>vc[MX];
int col[MX],vis[MX][11],d[MX],v[MX],c[MX];
void dfs(int d,int v,int c){
	if(d<0||vis[v][d])return;
	for(int i=d;~i;i--)vis[v][i]=1;
	if(!col[v])col[v]=c;
	for(int i=0;i<vc[v].size();i++)
		dfs(d-1,vc[v][i],c);
}
int main(){
	int n,m,a,b,q;
	cin>>n>>m;
	memset(col,0,sizeof(col));
	while(m--){
		cin>>a>>b;
		vc[a].push_back(b);
		vc[b].push_back(a);
	}
	cin>>q;
	for(int i=1;i<=q;i++)
		cin>>v[i]>>d[i]>>c[i];
	for(int i=q;i;i--)dfs(d[i],v[i],c[i]);
	for(int i=1;i<=n;i++)
		printf("%d\n",col[i]);
    system("pause");
    return 0;
}

Measured memory_bytes: 12536
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		double x[]=new double[21];
		double y[]=new double[21];
		int i=0;
		double S=0;
		while(in.hasNext())
		{
			String s[]=in.next().split(",");
			x[i]=Double.valueOf(s[0]);
			y[i]=Double.valueOf(s[1]);
			i++;
		}
		x[i]=x[0];
		y[i]=y[0];
		for(int j=0;j<i;j++)
		{
			double seki=(x[j]-x[j+1])*(y[j]+y[j+1]);
			S+=seki;
		}
		System.out.printf("%.6f\n",Math.abs(S/2));
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

    int d[10] = {};
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        d[t] = 1;
    }

    for (int i = n;; i++) {
        bool b = false;
        for (int m = i; m > 0; m /= 10) {
            if (d[m % 10]) {
                b = true;
                break;
            }
        }
        if (!b) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()



int main()
{
  int T;
  cin >> T;
  set<string> st;
  while(T--) {
    string s; cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;
  return 0;
}


Measured memory_bytes: 19256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <utility>

int difNum1(std::string S){
	int count=0;
	for(int i=0; i<S.length(); i++){
		if(i%2==0 && S[i] == '0'){
			count++;
		}
		else if(i%2!=0 && S[i] == '1'){
			count++;
		}
	}
	return count;
}

int difNum2(std::string S){
	int count=0;
	for(int i=0; i<S.length(); i++){
		if(i%2==0 && S[i] == '1'){
			count++;
		}
		else if(i%2!=0 && S[i] == '0'){
			count++;
		}
	}
	return count;
}

int main()
{
	int count1, count2, ans=0;
	std::string S;
	std::cin >> S;
	count1 = difNum1(S);
	count2 = difNum2(S);
	ans = std::min(count1, count2);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    int n, m;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s.at(i);
    cin >> m;
    vector<string> t(m);
    rep(i, m) cin >> t.at(i);
    map<string, int> a;
    rep(i, n) {
        if (a.count(s.at(i))) {
            a[s.at(i)]++;
        }
        else {
            a[s.at(i)] = 1;
        }
    }
    rep(i, m) {
        if (a.count(t.at(i))) {
            a[t.at(i)]--;
        }
        else {
            a[t.at(i)] = -1;
        }
    }
    int ans = -10000;
    for(auto p : a) {
        auto value = p.second;
        ans = max(ans, value);
    }
    if (ans < 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<bool>key(1e9 + 3, false);
  for (int i = 0; i < N; i ++) {
    int a;
    cin >> a;
    if (key[a]) {
      cout << "NO" << endl;
      return 0;
    }
    else key[a] = true;
  }
  cout << "YES" << endl;
}
  


Measured memory_bytes: 122368
n = gets.chomp.to_i
map = Hash.new(false)
count = 0
(1...n).each do |i|
  break if map[i]
  break if map[n - i]
  break if i == n - i
  map[i] = true
  map[n - i] = true
  count += 1
end
puts count

Measured memory_bytes: 66300
#!/usr/bin/ruby

def main()
	n = gets.chomp.to_i

	3.upto(n) do |i|
		if three(i) then
			print ' %d' % i
		end
	end
	puts
end

def three(i)
	if i%3 == 0
		return true
	end

	while i > 0 do
		if i%10 == 3 then
			return true
		end
		i /= 10
	end
	return false
end

if __FILE__ == $0
	main()
end



Measured memory_bytes: 6888
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "bits/stdc++.h"
#define pi (3.141592653589)
#define mod 1e9 + 7
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define mint(a, b, c) min(c, min(a, b))
#define minf(a, b, c, d) min(d, min(c, min(a, b)))
#define maxt(a, b, c) max(c, max(a, b))
#define maxf(a, b, c, d) max(d, max(c, max(a, b)))
#define vi vector<int>
#define vul vector<unsigned long long int>
#define vll vector<long long int>
#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace __gnu_pbds;
using namespace std;
typedef unsigned long long int ul;
typedef long long int ll;
int main()
{
    fast;
    int x;
    cin >> x;
    int num;
    if (400 <= x && x <= 599)
        num = 8;
    else if (600 <= x && x <= 799)
        num = 7;
    else if (800 <= x && x <= 999)
        num = 6;
    else if (1000 <= x && x <= 1199)
        num = 5;
    else if (1200 <= x && x <= 1399)
        num = 4;
    else if (1400 <= x && x <= 1599)
        num = 3;
    else if (1600 <= x && x <= 1799)
        num = 2;
    else
        num = 1;
    cout << num;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main()
{
  int cnt;
  int N,K;
  int C;
  int i;

  cnt = scanf("%d %d", &N, &K);

  for (i=1; i<=N; i++) {
    if ((i&1) != 0) C++;
  }

  if (C >= K) {
    printf("YES");
  } else {
    printf("NO");
  }

  return 0;
} 

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli mod = 998244353;

lli n;
vector<vdl> p;
mat c;
mat bl;
lli ans = 0;

lld deg(vdl a,vdl from){
  return fmod(atan2(a[1]-from[1],a[0]-from[0])+2*M_PI,2*M_PI);
}

lld deg(vdl a,vdl b,vdl from){
  return fmod(deg(b,from)-deg(a,from)+2*M_PI,2*M_PI);
}

lld abs(vdl to,vdl from){
  lld x = to[0]-from[0];
  lld y = to[1]-from[1];
  return sqrt(x*x+y*y);
}

lld dot(vdl a,vdl b,vdl from){
  lld x1 = a[0]-from[0];
  lld y1 = a[1]-from[1];
  lld x2 = b[0]-from[0];
  lld y2 = b[1]-from[1];
  return x1*x2+y1*y2;
}

lli pow(lli x,lli r,lli mod = 998244353){
  lli ret = 1;
  for(;r != 0;r >>= 1){
    if(r&1 != 0) ret *= x,ret %= mod;
    x *= x,x %= mod;
  }
  return ret;
}

set<vdl> s;
map<vdl,lli> m;

int main(){
  cin >> n;
  p = vector<vdl>(n,vdl(2));
  for(lli i = 0;i < n;i++) cin >> p[i][0] >> p[i][1];
  bl = mat(n,vll(n));
  for(lli i = 0;i < n;i++){
    bl[i][i] = 1;
    for(lli j = 0;j < n;j++){
      if(bl[i][j]) continue;
      set<lli> s;
      bl[i][j] = bl[j][i] = 1;
      s.insert(i);
      s.insert(j);
      for(lli k = 0;k < n;k++){
        if((p[k][1]-p[i][1])*(p[j][0]-p[i][0]) == (p[j][1]-p[i][1])*(p[k][0]-p[i][0])){
          for(lli x : s){
            bl[x][k] = bl[k][x] = 1;
          }
          s.insert(k);
        }
      }
      ans += pow(2ll,(lli)s.size())-1-s.size();

    }
  }

  // for(lli i = 0;i < n;i++){
  //   for(lli j = 0;j < n;j++){
  //     cout << bl[i][j];
  //   }
  //   cout << endl;
  // }
  ans += 1ll;
  ans += n;
  ans %= mod;
  cout << ((pow(2ll,n)-ans+mod)%mod) << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m ;
  cin >> n >> m ;
  
  vint num(n+1,1) ;
  
  REP(i,m){
    int a ;
    cin >> a ;
    num[a] = 0 ;
  }
  
  vector<ll> ans(n+1,0) ;
  ans[0] = 1 ;
  if(num[1]==1){
    ans[1] = 1 ;
  }
  else{
    ans[1] = 0 ;
  }
  
  for(int i=2;i<=n;i++){
    if(num[i]==0){
      continue ;
    }
    
    if(num[i-1]==1){
      ans[i] += ans[i-1] ;
      ans[i] = ans[i]%MOD ;
    }
    if(num[i-2]==1){
      ans[i] += ans[i-2] ;
      ans[i] = ans[i]%MOD ;
    }
  }
  
  
  /*
  REP(i,n+1){
    cout << i <<";" << ans[i] <<endl ;
  }
  */
    
  
  cout << ans[n] <<endl ;
      
      
      
    
  
    
  
  
  
  return 0 ;
}

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

int main()
{

    int n, mn = INT_MAX, mx = -1;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        int a;
        scanf("%d", &a);
        mn = min(a, mn);
        mx = max(a, mx);
    }
    printf("%d", mx-mn);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,a,b,c;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a >> b >> c;
        if(a*a+b*b==c*c)         cout << "YES" << endl;
        else if(b*b+c*c==a*a)    cout << "YES" << endl;
        else if(c*c+a*a==b*b)    cout << "YES" << endl;
        else                    cout << "NO" << endl;
    }
}



Measured memory_bytes: 3052
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod =  1000000007;
ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
   int ans=0,n;
   cin>>n;
   vi p(n);
   rep(i,n)cin>>p.at(i);
   
   rep(i,n-2){
       if(p.at(i)<=p.at(i+1)&&p.at(i+1)<=p.at(i+2))ans++;
       else if(p.at(i)>=p.at(i+1)&&p.at(i+1)>=p.at(i+2))ans++;
   }
   cout<<ans<<endl;
}
   



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  string A , B;
  
  cin >> A >> B;

  if(A.size() > B.size() )
    cout << "GREATER" << endl;
  else if(A.size() == B.size())
    for(int i = 0 ; A.size() ; i++){
      if(int(A[i]) > int(B[i])){
        cout << "GREATER" << endl;
        break;
      }
      else if(int(A[i]) ==int(B[i])){
        if(i == A.size() - 1){
          cout << "EQUAL" << endl;
          break;
        }
        else
          continue;
      }
      else{
        cout << "LESS" << endl;
        break;
      }
    }
  else
    cout << "LESS" << endl; 
  
  return 0;
}

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

using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n+1];
  for(int i=1;i<=n;i++)cin >> a[i];
  
  int counter=0;
  int number=1;
  for(int i=1;i<=n+1;i++){
    //cout << number << endl;
    number=a[number];
    counter++;
    if(number==2)break;
    if((i==n+1)&&(number!=2))counter=-1;
  }
  cout << counter << endl;
}

Measured memory_bytes: 640
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7

def main():
  w,h,n = map(int,input().split())
  rec = [[0] * w for _ in range(h)] # 0:white, 1:black
  
  # --start
  #for i in range(h):
  #  print('{}'.format(rec[i]))
  
  for _ in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
      for i in range(h):
        for j in range(0,x):
          #print(i,j)
          rec[i][j] = 1 # blacked
    elif a == 2:
       for i in range(h):
        for j in range(x,w):
          #print(i,j)
          rec[i][j] = 1 # blacked
    elif a == 3:
       for i in range(0,y):
        for j in range(w):
          #print(i,j)
          rec[i][j] = 1 # blacked
    if a == 4:
      #print(y)
      for i in range(y,h):
        for j in range(w):
          #print(i,j)
          rec[i][j] = 1 # blacked
      #rec[0][2] = 1
      
      
  # --done?
  """for i in range(h):
    #print(i)
    print('{}'.format(rec[i]))"""
  
  # --search
  sx,sy,gx,gy = -1,-1,-1,-1 #なくてもいい
  flag = False
  for j in range(w): # y = 0 ~ 
    for i in range(h): # x = 0 ~ xをまず求める
      if (not flag) and rec[i][j] == 0:
        flag = True
        sx,sy = j,i
      # to right
      # flaged
      # print(flag)
      if flag:#(8,8)の挙動を調べたい。
        if rec[i][j] == 0:
          gx,gy = j,i
        """if j+1<w:#(1,8)(i,j)
          if rec[i][j+1] == 1:
            if i+1<h:
              if rec[i+1][j] != 0:
                print(j+1,i)
                gx,gy = j+1,i
                continue
              else:
                pass
            else:
              gx,gy = j+1,i
              break
        else:##i方向を調べる
          if i+1<h:
            if rec[i+1][j] == 1:
              gx,gy = j,i+1
              continue"""
          
  #print(sx,sy,gx,gy)
  if gx==sx==-1 and sy==gy==-1:
    print(0)
    exit()
  print((gx-sx+1)*(gy-sy+1))
  
if __name__ == '__main__':
  main()

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

using namespace std;

int main(int argc, char* argv[])
{
  int N; cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  bool ans = true;
  int cnt = 0;
  vector<int> ball(N, 0);
  for (int i = N-1; i >= 0; i--) {
    if (i >= N/2) {
      if(A[i] == 1) {
	ball[i] = 1;
	cnt++;
      }
    } else {
      int ball_cnt = 0;
      for (int j = i; j < N; j+=(i+1)) {
	if (ball[j] == 1) {
	  ball_cnt++;
	}
      }

      if (ball_cnt%2 != A[i]) {
	ball[i] = 1;
	cnt++;
      }
    }
  }

  cout << cnt << endl;
  for (int i = 0; i < N; i++) {
    if (ball[i] == 1) {
      cout << i+1 << endl;
    }
  }
  return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int n; cin >> n;
    bool ok = false;
    for(int i = 1; i < 10; ++i){
        if(n % i == 0 && n / i >= 1 && n / i <= 9) ok = true;
    }
    if(ok == true) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define mod 1000000007
#define N 100
typedef pair<int, int> pi;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    ll  x,y;
    ll ans=100000000000000;
    for(ll i=1; i*i<=n; i++)  {
       if(n%i==0)  {
         x=i;
         y=n/i;
         ans=min(ans,x+y-2);
       }
    }
      cout<< ans  <<"\n";
    return 0;
}


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

int main(void){
    int H,W;
    cin >> H >> W;
    
    for(int i=0; i<H; i++){
        string s;
        cin >> s;
        cout << s << "\n" << endl;
        cout << s << "\n" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>;
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }

int c[7][7];
signed main() {
    int h,w,k, ans = 0;
    cin>>h>>w>>k;
    rep(i, h) rep(j, w) {
        char x;
        cin>>x;
        if (x == '#') c[i][j] = 1;
    }
    rep(i, 1<<h) {
        rep(j, 1<<w) {
            int sum = 0;
            rep(a, h) {
                if(i & (1<<a))
                    rep(b, w) {
                        if (j & (1<<b))
                            sum += c[a][b];
                    }
            }
            if (sum == k) ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3632
n = int(input())

numbers = list(map(int, input().split(" ")))

flag = 1

cnt = 0

while flag:
    flag = 0
    for j in range(n - 1, 0, -1):
        if numbers[j] < numbers[j - 1]:
            numbers[j], numbers[j - 1] = numbers[j - 1], numbers[j]
            flag = 1
            cnt += 1

numbers = map(str, numbers)
print(" ".join(numbers))

print(cnt)

Measured memory_bytes: 7656
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	int n;
	public void run() {
		while(sc.hasNext()){
			String str=sc.next();
			String[] strs=str.split(",");
			int[] dists=new int[10];


			int sum=0;
			for(int i=0;i<10;i++){
				dists[i]=Integer.parseInt(strs[i]);
				sum+=dists[i];
			}

			int v1=Integer.parseInt(strs[10]);
			int v2=Integer.parseInt(strs[11]);
			double pos=(double)sum*v1/(v1+v2);

			int res=0;
			for(int i=0;i<dists.length;i++){
				pos-=dists[i];
				if(pos<=0){
					res=i;
					break;
				}
			}
			ln((res+1));
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include<string>
#include <cassert>
#include <algorithm>
#include <functional>
#include<stdio.h>

using namespace std;


int main() {
	int N;
	int d[120];
	int counter = 0;
	cin >> N;

	for (int i = 0; i < N; ++i) {
		cin >> d[i];
	}
	//sort
	sort(d, d + N);
	//n=n+1とn!=n+1で場合分け
	for (int i = 0; i < N; ++i) {
		if (d[i] != d[i + 1]) {
			++counter;
		}
	}
	cout << counter << endl;
}


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

using namespace std;

int main() {
    int n, a, b, res = 0;

    cin >> n;

    for (int i=0; i<n; i++) {
        cin >> a >> b;
        res += b-a+1;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int c = input.nextInt();
        if((a < b) && (b < c)) System.out.println("Yes");
        else System.out.println("No");
    }
}



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

int main(){
    int N, P;
    string S;
    cin >> N >> P >> S;
    int64_t ans = 0;
    if(P == 2 || P == 5){
        for(int i=0; i<N; i++){
            int d = S[i] - '0';
            if(d%P == 0) ans += i+1;
        }
    }else{
        vector<int> num(P);
        int base = 1, sum = 0;
        num[0] = 1;
        for(int i=N-1; i>=0; i--){
            int d = S[i] - '0';
            sum = (sum + base*d) % P;
            ans += num[sum];
            num[sum]++;
            base = base * 10 % P;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int N,X;
	int a[N];
	cin>>N>>X;
	for (int i = 0; i < N; i++){
		cin>>a[i];
	}

	int total=0,min=a[0];
	for (int j = 0; j < N; j++){
		total += a[j];
		if(min>a[j])
			min=a[j];
	}

	cout<< N+(X-total)/min <<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> comb;

inline int first(int n){
	return ((1 << n) - 1);
}

int nextSet(int x){
	int small, ripple, newSmall,ones;
	
	small = x & -x;
	ripple = x + small;
	newSmall = ripple & -ripple;
	ones = (( newSmall / small ) >> 1) - 1;
	
	return (ripple | ones);
}

comb setComb(int s, int n){
	comb c;
	for(int i=1 ; i<=n ; i++){
		if( s & 1)c.push_back(i-1);
		s >>= 1;
	}
	return c;
}

int main(){
	int n=10, k, x, s, sum, ans;
	comb c;
	
	while( cin >> k >> s , k || s){
		ans = 0;
		x = first(k);
		while( !(x & ~first(n) ) ){
			c = setComb( x , n );
			sum = 0;
			for(int i=0 ; i<c.size() ; i++){
				sum += c.at(i);
			}
			if(sum==s) ans++;
			x = nextSet( x );
		}
		cout << ans << endl;
	}
}

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

using namespace std;


int main(){
	int N;
	cin >> N;
	vector<int> a;
	vector<int> s;
	for(int i=0;i<N;i++){
		int A;
		cin >> A;
		a.push_back(A);
		s.push_back(0);
	}
	
	int hung = N/2;

	for(int i=N-1;i>=hung;i--){

		if(a[i]==0){
			s[i]=0;
		}else if(a[i]==1){
			s[i]=1;
		}
	}

	for(int i=hung-1;i>=0;i--){
		int sum=0;
		int num=N/(i+1);
		for(int n=1;n<=num;n++){
			sum=sum+s[(i+1)*n-1];

		}
		if(a[i]==1){
			if(sum%2==0){
				s[i]=1;
			}else if(sum%2==1){
				s[i]=0;
			}
		}else if(a[i]==0){
			if(sum%2==0){
				s[i]=0;
			}else if(sum%2==1){
				s[i]=1;
			}

		}
	}
	int sum = 0;
	vector<int> w;
	for(int i=0;i<N;i++){
		sum =sum+s[i];
		if(s[i]==1){
			w.push_back(i+1);
		}
	}
	cout << sum << endl;
	for(int i=0;i<w.size();i++){
		cout << w[i];
		cout << " ";

	}





	return 0;

}



Measured memory_bytes: 3564
N = int(input())
towns = [tuple(map(int, input().split())) for _ in range(N)]

xs = []
ys = []

for i, (x,y) in enumerate(towns):
    xs.append((x, i))
    ys.append((y, i))

xs.sort()
ys.sort()

es = []
for (x1, i1), (x2, i2) in zip(xs, xs[1:]):
    es.append((x2-x1, i1, i2)) #i1からi2までのコストがx2-x1、絶対値とってないけど

for (y1, i1), (y2, i2) in zip(ys, ys[1:]):
    es.append((y2-y1, i1, i2)) #i1からi2までのコストがy2-y1、
es.sort()

class UnionFind:
    def __init__(self, N):
        #初めの親ノードはすべて異なる
        self.parent = [i for i in range(N)]
        #木の高さ
        self.rank = [0] * N
        self.count = 0

    #どのUnionに所属するか判定
    def root(self, a):
        #親が根の場合
        if self.parent[a] == a:
            return a
        else:
            #親の親を調べなおす＆見つかった根に接続しなおす
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]

    #同じUnionか判定
    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    #Unionを作る
    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return
        #高いほうの下に小さいほうを繋ぐ
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count +=1


ans = 0
uf = UnionFind(N)
for d,a,b in es:
    #すでに繋がれてるならスキップ
    if uf.is_same(a,b):
        continue
    uf.unite(a,b) #esはソート済みのため短い順から重複をせずにN個の町が繋がれることが保証される
    ans += d
print(ans)

Measured memory_bytes: 61104
n = int(input())
s = list(map(int,input().split()))
 
a = s[0]
b = sum(s)-a
ans = abs(a-b)
 
for i in range(1,n-1):
    a += s[i]
    b -= s[i]
    ans = min(ans,abs(a-b))
    
print(ans)

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

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

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

  vector<vector<int>> graph(N);
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    graph[x].push_back(y);
    // graph[y].push_back(x);
  }

  int S, T;
  cin >> S >> T;
  S--;
  T--;
  vector<vector<int>> memo(N, vector<int>(3, -3));
  queue<PII> que;
  que.push(PII(S, 0));
  memo[S][0] = 0;
  while (!que.empty()) {
    PII v = que.front();
    // cout << v.first << " " << v.second << " " << memo[v.first][v.second]
    //     << endl;
    que.pop();
    int nxt = (v.second + 1) % 3;
    for (auto u1 : graph[v.first]) {
      if (memo[u1][nxt] >= 0) continue;
      memo[u1][nxt] = memo[v.first][v.second] + 1;
      que.push(PII(u1, nxt));
    }
  }
  cout << memo[T][0] / 3 << endl;

  return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vi a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vi b(n);
  for (int i = 0; i < n; i++) cin >> b[i];
  reverse(all(b));
  int l = 0, r = n - 1;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) continue;
    if (a[l] != b[i] and a[i] != b[l]) {
      swap(b[i], b[l++]);
    } else if (a[r] != b[i] and a[i] != b[r]) {
      swap(b[i], b[r--]);
    } else {
      cout << "No\n";
      return (0);
    }
  }
  cout << "Yes\n";
  for (int i = 0; i < n; i++) cout << b[i] << " \n"[i == n - 1];
  return (0);
}


Measured memory_bytes: 4776
//JSD
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long a,b;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>b;	
	long long int x=__gcd(a,b);
	long long  n=x;
		int ans=0;
	for(long long i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ans++;
			while(n%i==0)
			{
				n=n/i;
			}
		}
	}
	if(n>1)
	{
		ans++;
	}
	cout<<ans+1;

	return 0;
}


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

void insertionSort(int*, int);
void printArray(int*, int);

int main(void) {
    int n, *a, i = 0;
    scanf("%d", &n);
    a = malloc(sizeof(int) * n);
    while (i < n) {
        scanf("%d", &a[i]);
        i++;
    }
    printArray(a, n);
    insertionSort(a, n);
    return 0;
}

void insertionSort(int *a, int n) {
    int i, j, v;
    for (i = 1; i < n; i++) {
        v = a[i];
        j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        printArray(a, n);
    }
}

void printArray(int *a, int n) {
    int i = 0;
    while (i < n - 1) {
        printf("%d ", a[i]);
        i++;
    }
    printf("%d\n", a[i]);
}



Measured memory_bytes: 1932
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e5 + 11;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll idx, ll val){
	if(start == end)
		segtree[node] += val;
	else{
		ll mid=(start + end)/2;
		if(idx <= mid)
			update(left(node), start, mid, idx, val);
		else
			update(right(node), mid+1, end, idx, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(right(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n, m;
	cin >> n >> m;
	ll mn = INF;
	ll a, b;
	while(n--){
		cin >> a >> b;
		if(b <= m)
			mn = min(mn, a);
	}
	if(mn == INF)
		cout << "TLE";
	else
		cout << mn;
	return 0;
}

Measured memory_bytes: 3576
#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() {
    int n, x, y;
    std::cin >> n >> x >> y;
    x--;
    y--;
    std::map<int, int> mp;
    rep(i, n - 1) {
        repeat(j, i + 1, n) {
            mp[std::min({std::abs(j - i), std::abs(x - i) + 1 + std::abs(y - j), std::abs(x - j) + 1 + std::abs(y - i)})]++;
        }
    }
    repeat(i, 1, n) {
        std::cout << mp[i] << std::endl;
    }
}

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

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, string>
const int INF = INT_MAX / 2;
const int MAX_M = 1010;

P cntSpace(string str){
    int cnt = 0;
    while(str[cnt] == ' ') cnt++;
    return P(cnt, str.substr(cnt));
}

bool isParent(int x, int y, vector<int> parent){
    if(parent[y] == x) return true;
    else return false;
}

bool checkQ(string str, map<string, int> list_i, vector<int> parent){
    stringstream ss(str);
    vector<string> vec;
    string tmp;
    while(ss >>tmp) vec.push_back(tmp);

    int x = list_i[vec[0]];
    int y = list_i[vec[5].erase(vec[5].size() - 1)];

    if(vec[3] == "child") return isParent(y, x, parent);
    if(vec[3] == "parent") return isParent(x, y, parent);
    if(vec[3] == "sibling") return parent[x] == parent[y];
    if(vec[3] == "descendant"){
        int now_x = x;
        while(parent[now_x] != -1){
            if(isParent(y, now_x, parent) == true) return true;
            now_x = parent[now_x];
        }
        return false;
    }
    if(vec[3] == "ancestor"){
        int now_y = y;
        while(parent[now_y] != -1){
            if(isParent(x, now_y, parent) == true) return true;
            now_y = parent[now_y];
        }
        return false;
    }
}



int main(){
    int m, n;
    while(cin >>m >>n && (n && m)){
        string name_line;
        getline(cin, name_line);

        vector<int> parent(m);
        int current_parent_i[MAX_M];
        map<string, int> list_i;

        parent[0] = -1;

        REP(i, m){
            getline(cin, name_line);

            P rank_and_name = cntSpace(name_line);
            current_parent_i[rank_and_name.first + 1] = i;
            list_i[rank_and_name.second] = i;

            if(i != 0){
                int now_parent = current_parent_i[rank_and_name.first];
                parent[i] = now_parent;
            }
        }

        REP(i, n){
            string q;
            getline(cin, q);
            bool ans = checkQ(q, list_i, parent);
            if(ans) cout <<"True" <<endl;
            else cout <<"False" <<endl;
        }
        cout <<endl;
    }
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    double a,b,x; cin >> a >> b >> x;
    if ((a*a*b)/2.0 <= x){
        double ans = atan(2.0*(a*a*b-x)/(a*a*a));
        cout << fixed << setprecision(10) << ans*180.0/M_PI << endl;
    }else{
        double ans = atan(a*b*b/(x*2.0));
        cout << fixed << setprecision(10) << ans*180.0/M_PI << endl;

    }
    return 0;
}

Measured memory_bytes: 4140
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin >> s;
int sum = 0;
for(int i = 0; i < s.size(); i++){
    int num = s[i] - '0';
    sum += num;
}
int S = atoi(s.c_str());
if(S % sum == 0)
cout << "Yes" << endl;
else
{
    cout << "No" << endl;
}

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
    int A,B;
    cin >> A >> B;
    int res=0;
    if (A > 12) {
        res = B;
    }   else if(A >= 6) {
        res = B/2;
    } 
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

const int INF = 1000000000;

struct edge{int to,cost;};
typedef pair<int,int> P;
int v,e;
vector<edge> G[10000];
bool used[10000];
int ans = 0;
priority_queue<P,vector<P>,greater<P> > q;

int main(){
  scanf("%d %d",&v,&e);
  for(int i=0;i<e;i++){
    int s,t,d;
    scanf("%d %d %d",&s,&t,&d);
    edge e;
    e.cost = d;
    e.to = t;
    G[s].push_back(e);
    e.to = s;
    G[t].push_back(e);
  }
  fill(used,used+v,false);
  q.push(P(0,0));
  while(!q.empty()){
    P p = q.top(); q.pop();
    int nv = p.second;
    if(used[nv]) continue;
    ans += p.first;
    used[nv] = true;
    for(int i=0;i<G[nv].size();i++){
      q.push(P(G[nv][i].cost,G[nv][i].to));
    }
  }
  printf("%d\n",ans);
  return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(M);
    for(int i=0; i<M; ++i) cin >> A.at(i);

    int sum = 0;
    for(int i=0; i<M; ++i) sum += A.at(i);
    if(N >= sum) cout << N - sum << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys
import heapq
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7

n=int(input())
G=[[] for i in range(n)]
for _ in range(n):
    inp = list(map(int,input().split()))
    u,k=inp[:2]
    for i in range(k):
        G[u].append((inp[2+2*i],inp[3+2*i]))

def disktra(g,s):
    n=len(g)
    dist = [inf]*n
    dist[s] = 0
    hq=[]
    heapq.heappush(hq,(dist[s],s))
    while hq:
        cost,u =heapq.heappop(hq)
        if dist[u] < cost:
            continue
        for v,c in g[u]:
            if dist[v] <= dist[u] +c:
                continue
            dist[v] = dist[u] + c
            heapq.heappush(hq,(dist[v],v))
    return dist

d=disktra(G,0)
for i in range(n):
    print(i,d[i])


Measured memory_bytes: 6212
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  cin>>s;
  int ans=999;
  int n=s.size();
  for(int i=0;i<n-2;i++){
    int num=(s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0';
    ans=min(ans,abs(num-753));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
n, m = list(map(int, input().split()))

d = [10] * n
r = 0

for i in range(m):
  s, c = list(map(int, input().split()))
  if d[s-1]>=c:
    if d[s-1]!=10 and d[s-1]!=c:
      print(-1)
      exit()
    d[s-1]=c
  else:
    print(-1)
    exit()

if n==1:
  if d[0]==10:
    d[0] = 0
if n==2:
  if d[0]==10:
    d[0] = 1
  if d[1]==10:
    d[1] = 0
if n==3:
  if d[0]==10:
    d[0] = 1
  if d[1]==10:
    d[1] = 0
  if d[2]==10:
    d[2] = 0
        
if (r==-1):
  print(r)
else:
  dd = int(''.join(map(str, d)))
  if len(str(dd))==n:
    print(dd)
  else:
    print(-1)


Measured memory_bytes: 3064