akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       ll x,y;
       cin>>x>>y;
       if(y>=2*x&&y<=4*x&&y%2==0)
         cout<<"Yes\n";
       else
         cout<<"No\n";
   }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, X;
    cin >> n >> X;
    vector<int> x(n + 1);
    rep(i, 0, n) cin >> x[i];
    x[n] = X;
    sort(x.begin(), x.end());
    int ans = x[1] - x[0];
    rep(i, 1, n) ans = gcd(ans, x[i + 1] - x[i]);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=2000005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int a[MAXN],n,flag;
char st[MAXN];
int C(int x,int y)
{
	int z=x-y;
	if (x-__builtin_popcount(x)==y-__builtin_popcount(y)+z-__builtin_popcount(z)) return 1;
	else return 0;
}
int getans()
{
	int ans=0;
	for (int i=1;i<=n;i++) 
		if (C(n-1,i-1)) ans^=a[i];
	return ans;
}
int main()
{
	n=read(),flag=0;
	scanf("%s",st+1);
	for (int i=1;i<n;i++) a[i]=abs(st[i+1]-st[i]),flag|=(a[i]&1); 
	if (n==1) { printf("%d\n",a[0]); return 0; }
	n--;
	if (flag) for (int i=1;i<=n;i++) a[i]=a[i]&1;
	else for (int i=1;i<=n;i++) a[i]>>=1;
//	for (int i=1;i<=n;i++) cout<<a[i];cout<<endl;
	
	int t=getans();
	if (flag&&t) puts("1");
	if (!flag&&t) puts("2");
	if (!t) puts("0");
	return 0;
}

Measured memory_bytes: 5376
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x = scan.nextInt();
		int t = scan.nextInt();
		int ans = 0;

		while(n > 0) {
			n -= x;
			ans++;
		}
		System.out.println(ans*t);

	}

}

Measured memory_bytes: 35568
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
#define LL long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
using namespace std;

const int MOD=1e9+7;
const int INF=0x7ffffff;
const int magic=348;
const double eps=1e-9;

int n,e;
vector<Pair> v[100048];
vector<int> vv[300048];
vector<int> col[1000048];
vector<int> path;queue<int> q;
int cur[100048],visited[100048];
int max_col=-1;
int dist[300048];

int main ()
{
	int i,j,color,k,x,y,c,xx;
	scanf("%d%d",&n,&e);
	for (i=1;i<=e;i++)
	{
		scanf("%d%d%d",&x,&y,&c);
		v[x].pb(mp(c,y));
		v[y].pb(mp(c,x));
		col[c].pb(x);col[c].pb(y);
		max_col=max(max_col,c);
	}
	for (i=1;i<=n;i++) sort(v[i].begin(),v[i].end());
	int new_g=n;
	for (color=1;color<=max_col;color++)
	{
		if (col[color].size()==0) continue;
		for (i=0;i<col[color].size();i++)
		{
			x=col[color][i];
			if (visited[x]==color) continue;
			visited[x]=color;
			path.clear();
			q.push(x);
			while (!q.empty())
			{
				x=q.front();path.pb(x);q.pop();
				for (j=cur[x];j<v[x].size();j++)
				{
					if (v[x][j].x!=color) break;
					xx=v[x][j].y;if (visited[xx]==color) continue;
					visited[xx]=color;
					q.push(xx);
				}
				cur[x]=j;
			}
			++new_g;
			for (j=0;j<path.size();j++)
			{
				vv[new_g].pb(path[j]);
				vv[path[j]].pb(new_g);
			}
		}
	}
	for (i=1;i<=new_g;i++) dist[i]=-1;
	dist[1]=0;q.push(1);
	while (!q.empty())
	{
		x=q.front();q.pop();
		for (i=0;i<vv[x].size();i++)
		{
			xx=vv[x][i];
			if (dist[xx]==-1)
			{
				dist[xx]=dist[x]+1;
				q.push(xx);
			}
		}
	}
	if (dist[n]==-1) printf("-1\n"); else printf("%d\n",dist[n]/2);
	return 0;
}

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

void solver() {
  int n;
  string s;
  cin >> n >> s;

  long long n_r = 0;
  long long n_g = 0;
  long long n_b = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') n_r++;
    else if (s[i] == 'G') n_g++;
    else if (s[i] == 'B') n_b++;
  }

  long long ans = n_r * n_g * n_b;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      int k = (2 * j) - i;
      if (k <= j) continue;
      if (k > 0 && k < n && s[i] != s[j] && s[i] != s[k] && s[k] != s[j]) ans--;
    }
  }

  cout << ans << "\n";
}

int main() {
  solver();
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<cxxabi.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mp make_pair
#define fi first
#define se second
#define All(x) (x).begin(),(x).end()
#define TYPEVS(x) typeid(x).name()
#define TYPEGC(x) abi::__cxa_demangle(typeid(x).name(), 0, 0, 0)
#define Y1 "YES"
#define N1 "NO"
#define ENDL '\n'
#define count2(x) _builtin_popcount(x)
ll nums[6001];
ll sat[4001][3001],ans;
ll mod=998244353;
int main(){
	ll n,s;
	cin>>n>>s;
	sat[0][0]=1;//sat[i][j]表示选择其中不超过i个数，和为j的方案 
	for(ll i=0;i<n;++i)
	cin>>nums[i];
	for(ll i=0;i<n;++i){
		for(int j=0;j<=s;j++){
			sat[i+1][j]+=2*sat[i][j];
			sat[i+1][j]%=mod;
			if(j+nums[i]<=s)
			sat[i+1][j+nums[i]]+=sat[i][j];
			sat[i+1][j+nums[i]]%=mod;
		}
	}
	cout<<sat[n][s];
}


Measured memory_bytes: 73932
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const int mod = 1e9+7;
long long modPow(long long a, int p){
    if (p == 0) return 1;
    if (p%2 == 0) {
        long long half = modPow(a, p/2);
        return half * half % mod;
    }
    else return a * modPow(a, p-1) % mod;
}
struct Combination {
    long long *fac, *facInv, *inv;
    explicit Combination(int size) {
        fac = (long long *) malloc(sizeof(long long) * (size+1));
        facInv = (long long *) malloc(sizeof(long long) * (size+1));
        inv = (long long *) malloc(sizeof(long long) * (size+1));
        fac[0] = fac[1] = 1;
        facInv[0] = facInv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i <= size; ++i) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            facInv[i] = facInv[i - 1] * inv[i] % mod;
        }
    }
    long long operator()(int n, int r) {
        if (n < r || n < 0 || r < 0) return 0;
        return fac[n] * facInv[r] % mod * facInv[n - r] % mod;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<long long> A(N);
    for (auto & a : A) cin >> a;
    long long tmp = A[0], tmpGCD = A[0];
    boost::multiprecision::cpp_int tmpLCM = A[0];
    for (int i = 1; i < N; ++i) {
        tmp *= A[i];
        tmp %= mod;
        tmpGCD = __gcd(A[i], tmpGCD);
        tmpGCD %= mod;
        tmpLCM = tmpLCM*A[i]/__gcd((boost::multiprecision::cpp_int)A[i], tmpLCM);
    }
    long long lcm = (long long)(tmpLCM % mod); //tmp * modPow(tmpGCD, mod-2) % mod;
    long long ans = 0;
    Combination c(1000000);
    for (int i = 0; i < N; ++i) {
        ans += lcm * c.inv[A[i]] % mod;
        if (ans >= mod) {
            ans -= mod;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

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


using namespace std;
using ll = long long;

#define sz(x) (int)(x).size()

template<class T>
void print (vector<T>& v, bool spaced = true) {
    int n = v.size();
    string space = (spaced ? " ": "");
    for (int i = 0; i < n; ++i) {
        cout << v[i] << space;
    }cout << '\n';
}

int main () {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
  
    
     int n; cin>> n;
     cout << (n + 999)/1000 * 1000 - n << '\n';

    
    return 0;
}







Measured memory_bytes: 3628
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 3], [0, 2, 1, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0], [2, 1, 0, 1]]
succeed = False
for i in range(6):
    match = True
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
            match = False
            break
        else:
            if x[j] == y[z[i][j]]:
                order[j] = 1
                if x[j] == x[-j-1]:
                    order[j] = 2
    if match:
        if 2 in order:
            succeed = True
            break
        if z[i][3] == 0 or z[i][3] == 3:
            if sum(order) % 2:
                succeed = True
                break
        if z[i][3] == 1:
            if not sum(order) % 2:
                succeed = True
                break
if succeed:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 7732
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
void print(int x) {
    int n = x;
    int d = 0;
    while(n) {
        n /= 10;
        d++;
    }
    rep(i, 6-d) {
        cout << 0;
    }
    cout << x;
}
int main(void) {
    int n, m; cin >> n >> m;
    vector<int> x[n];
    vector<P> q(m);
    rep(i, m) {
        int a, b;
        cin >> a >> b; a--;
        q[i].first = a; q[i].second = b;
        x[a].push_back(b);
    }
    rep(i, n)
        sort(x[i].begin(),x[i].end());
    rep(i, m) {
        int a = q[i].first;
        int b = q[i].second;
        auto it = lower_bound(x[a].begin(),x[a].end(),b);
        print(a+1); print(it-x[a].begin()+1); puts("");
    }
}



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

#define ll long long
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define ii pair < int, int >
#define vi vector < int > 
#define all(a) (a).begin(), (a).end()

using namespace std;

const int MAXN = 2e5 + 10;

void solve() {
	int a, b, c;
	cin >> a >> b >> c;
	if ( a == b && a != c ) cout << "Yes\n";
	else if ( a == c && a != b ) cout << "Yes\n";
	else if ( b == c && b != a ) cout << "Yes\n";
	else cout << "No\n";
}

int main() {
	int t = 1;
	//cin >> t;
	while ( t-- ) solve();
	return 0;
}


Measured memory_bytes: 256
n = ["0"] + list(input())
n = n[::-1]
ans = 1

for i in range(len(n)):
    n[i] = int(n[i])

dp = [[0] * 2 for i in range(len(n) + 1)]
dp[0][1] = 1
for i in range(len(n)):
    dp[i + 1][0] = min(dp[i][0] + n[i], dp[i][1] + n[i] + 1)
    dp[i + 1][1] = min(dp[i][0] + 10 - n[i], dp[i][1] + 10 - (n[i] + 1))

print(min(dp[-1]))

Measured memory_bytes: 166440
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int a;
int b;

void input() {
  cin >> a >> b;
}

void solve() {
  int ans = 0;
  int cur = 1;

  while (cur < b) {
    cur += a;

    --cur;
    ++ans;
  }

  cout << ans << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  _times = 3;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")

using namespace std;

int A[500000], K[500001], k=1, CL=0, CR=-1, n, B;

void add(int I)
{
    K[A[I]]++;
    if (K[A[I]] == 1)
    {
        k++;
    }
}

void Remove(int I)
{
    K[A[I]]--;
    if (K[A[I]] == 0)
    {
        k--;
    }
}

int query (int L, int R)
{
    while (CL < L)
    {
        Remove(CL);
        CL++;
    }
    while (CL > L)
    {
        CL--;
        add(CL);
    }
    while (CR < R)
    {
        CR++;
        add(CR);
    }
    while (CR > R)
    {
        Remove(CR);
        CR--;
    }
    return k;
}

bool Bsort (const pair<pair<int,int>,int> &a, const pair<pair<int,int>,int> &b)
{
    if (a.first.first / B == b.first.first / B)
    {
        return a.first.second < b.first.second;
    }
    else
    {
        return a.first.first / B < b.first.first / B;
    }
}

int main()
{
    int m, l, r, L, R, p, I;
    cin >> n >> m;
    B = sqrt(n);
    map <int,int> M;
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
        if (M[A[i]] == 0)
        {
            M[A[i]] = k;
            k++;
            K[A[i]] = 0;
        }
        A[i] = M[A[i]];
    }
    k = 0;
    int U[m];
    vector <pair<pair<int,int>,int> > V;
    for (int i = 0; i < m; i++)
    {
        cin >> l >> r;
        l--;
        r--;
        V.push_back({{l,r},i});
    }
    sort(V.begin(),V.end(), Bsort);
    for (int i = 0; i < m; i++)
    {
        L = V[i].first.first;
        R = V[i].first.second;
        I = V[i].second;
        U[I] = query(L, R);
    }
    for (int i = 0; i < m; i++)
    {
        cout << U[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 39024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef long long int ll;
const ll MOD=1000000007;

int main(){
	ll n,k,ans;
	scanf("%lld %lld",&n,&k);
	ans=1;
	while(n--){
		ans*=k;
		ans%=MOD;
		k--;
	}
	printf("%lld\n",ans);
}


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

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll num = n / (a + b);
	ll tmp = n % (a + b);
	ll ans = num * a;
	if (tmp >= a) ans += a;
	else ans += tmp;
	cout << ans << endl;
	return 0;
}


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

int main(){
  int N,Z=0;
  cin>>N;
  vector<int64_t> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int k=j+1;k<N;k++){
        if(max(p[i],max(p[j],p[k]))<p[i]+p[j]+p[k]-max(p[i],max(p[j],p[k]))){
          if(p[i]!=p[j]&&p[j]!=p[k]&&p[k]!=p[i]){
            Z++;
          }
        }
      }
    }
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n + 5];
		int now = 0;
		for(int i = 1 ; i <= n ; i++) {
			int b = sc.nextInt();
			if(b == now + 1) {
				now++;
			}
		}

		sc.close();
		System.out.println(now == 0 ? now - 1 : n - now);

	}
}



Measured memory_bytes: 59932
#include <cmath>
#include <iostream>
#include <set>
#include <string>
using namespace std;

int main(void) {
  string str;
  int k;
  set<string> s;
  cin >> str >> k;
  for (int i = 1; i <= 20; i++) {

    for (int j = 0; j < str.length(); j++) {
      
      if (str.length() - j < i)
        continue;
      s.insert(str.substr(j, i));
    }
  }
  auto itr = s.begin();
  if (k != 1) {
    for (int i = 0; i < k - 1; i++) {
      ++itr;
    }
  }

  cout << *itr << endl;
  return 0;
}


Measured memory_bytes: 9088
#include <stdio.h>

int main(void)
{
	int s, h, m;
	scanf("%d", &s);
	m = s / 60;
	s -= m * 60;
	h = m / 60;
	m -= h * 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}


Measured memory_bytes: 2056
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var cards map[string]int

func print(A []string) {
	fmt.Println(strings.Join(A, " "))
}

func parseNum(c string) int {
	if n, ok := cards[c]; ok {
		return n
	}

	ar := strings.Split(c, "")
	n, err := strconv.Atoi(ar[1])
	if err != nil {
		panic(err)
	}
	cards[c] = n
	return n
}

func bubbleSort(A []string, N int) []string {
	ba := make([]string, N)
	copy(ba, A)

	f := true
	for f {
		f = false
		for i := N - 1; i > 0; i-- {
			j := i - 1
			ai := parseNum(ba[i])
			aj := parseNum(ba[j])
			if ai < aj {
				ba[i], ba[j] = ba[j], ba[i]
				f = true
			}
		}
	}
	return ba
}

func selectionSort(A []string, N int) []string {
	sa := make([]string, N)
	copy(sa, A)

	for i := 0; i < N-1; i++ {
		min := i
		for j := i + 1; j < N; j++ {
			ai := parseNum(sa[j])
			aj := parseNum(sa[min])
			if ai < aj {
				min = j
			}
		}
		if min != i {
			sa[i], sa[min] = sa[min], sa[i]
		}
	}
	return sa
}

func main() {
	cards = map[string]int{}

	var sc = bufio.NewScanner(os.Stdin)

	sc.Scan()
	N, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}

	sc.Scan()
	A := strings.Split(sc.Text(), " ")

	ba := bubbleSort(A, N)
	print(ba)
	fmt.Println("Stable")

	isStable := true
	sa := selectionSort(A, N)
	print(sa)
	for i, c := range ba {
		if sa[i] != c {
			isStable = false
			break
		}
	}
	if isStable {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}
}


Measured memory_bytes: 1184
#include<stdio.h>

#define N 20

int n;
int A[N];

int solve(int i, int m){
  int res;
  
  if(m==0) return 1;
  if(i>=n) return 0;

  res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}

int main(){

  int q;
  int i,j,check;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);

  int m[q];
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }


  for(i=0;i<q;i++){
    check = 1;
    for(j=0;j<n;j++){
      if(solve(j,m[i])==1){
	printf("yes\n");
	check = 0;
	break;
      }
    }
    if(check){
      printf("no\n");
    }
  }

  return 0;
}



Measured memory_bytes: 2080
if __name__ == "__main__":
    N = int(input())
    E = [0]*(N+1)
    W = [0]*(N+1)
    for i, s in enumerate(input()):
        if s == "E":
            E[i+1] = 1
        elif s == "W":
            W[i+1] = 1
        E[i+1] += E[i]
        W[i+1] += W[i]
    ans = 3*10**5
    for i in range(N):
        if i == 0:
            ans = min(ans, E[N]-E[1])
            continue
        if i == N-1:
            ans = min(ans, W[i])
            continue
        ans = min(ans, E[N]-E[i+1] + W[i])
    print(ans)


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

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

using namespace std;

int main(){
	int L; cin>>L;

	int n;
	for(n=0;(1<<n)<=L;n++);

	vector<vector<pair<int,int>>> G(n);
	rep(i,n-1){
		G[i].emplace_back(i+1,0);
		G[i].emplace_back(i+1,1<<(n-i-2));
	}
	int sum=1<<(n-1);
	rep(i,n-1) if(L>>(n-i-2)&1) {
		G[0].emplace_back(i+1,sum);
		sum+=1<<(n-i-2);
	}

	int m=0;
	rep(u,n) m+=G[u].size();

	printf("%d %d\n",n,m);
	rep(u,n) for(auto e:G[u]) printf("%d %d %d\n",u+1,e.first+1,e.second);

	return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	int n, m;cin >> n >> m;
	vector<ll> v(2 * n);
	REP(i, 2 * n)cin >> v[i];

	sort(ALL(v), greater<ll>());

	ll l = 0;
	ll r = n + 1;

	while(r - l > 1){
		ll mid = (l + r) / 2;
		ll tmp = LLINF;
		for(int i = 0;i < mid;i++){
			tmp = min(tmp, (v[i] + v[2 * mid - i - 1]));
		}
		if(tmp >= m)l = mid;
		else r = mid;
	}

	ll ans = 0;
	for(int i = 0;i < l;i++){
		ans = max(ans, (v[i] + v[2 * l - i - 1]) % m);
	}
	for(int i = 0;i < n - l;i++){
		ans = max(ans, (v[2 * l + i] + v[2 * n - 1 - i]) % m);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
N,T=map(int,input().split())
s=[]
o=[]
for i in range(N):
  c,t=map(int,input().split())
  if t<=T:
    s.append(c)
  else:
    o.append(c)
if len(o)==N:
  print("TLE")
else:
  print(min(s))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, long long K)
{
    ll ans = 0;
    if(K == 0){
        cout << N * N << endl;
        return;
    }
    for (int b = K + 1; b <= N; b++)
    {
        ll loop = N / b;
        ll contains = b - K;

        ans += loop * contains;

        ll modu = N % b;
        if(K <= modu){
            ans += modu - K + 1;
        }
    }
    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
import numpy as np

N = int(input())
A = sorted(map(int, input().split()))
MAX_A = 10 ** 6
checked = np.zeros(MAX_A + 1, dtype=bool)

for i, a in enumerate(A):
    if not checked[a]:
        if i >= 1 and A[i - 1] == A[i]:
            checked[a] = True
        k = 2
        while a * k <= MAX_A:
            checked[a * k] = True
            k += 1

cnt = 0
for a in A:
    if not checked[a]:
        cnt += 1

print(cnt)


Measured memory_bytes: 51472
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>

#define DEBUG 1
#define fi first
#define se second
#define pb push_back
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1e9 + 3;
const int MOD = 1e9 + 7;

int main() {
#ifndef ONLINE_JUDGE

    ios_base::sync_with_stdio(false); cin.tie(0);
#endif
    int n; cin >> n;
    vi p(n); for (int &x : p) cin >> x;
    int cnt = 0;
    fore(i, 1, n - 1) if ((p[i - 1] <= p[i] && p[i] <= p[i + 1]) || (p[i - 1] >= p[i] && p[i] >= p[i + 1])) ++cnt;
    cout << cnt << '\n';
    return 0;
}


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

int R,G,B,N;
long long ans=0;

int main(){
	scanf("%d%d%d%d",&R,&G,&B,&N);
	for(int i=0;i<=N;i++){
		int sum1=i*R;
		int n=N;
		n-=sum1;
		if(n<0) break;
		for(int j=0;j<=N;j++){
			int sum2=j*G;
			int m=n;
			m-=sum2;
			if(m<0) break;
			if(m%B==0) ans++; 
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
s=input()
t=s.find('R')
if t==2:
    print(1)
elif t==-1:
    print('0')
elif t==0:
    if s[t]==s[t+1]:
        if s[t+1]==s[t+2]:
            print('3')
        else:
            print('2')
    else:
        print(1)
else:
    if s[t]==s[t+1]:
        print(2)
    else:
        print(1)

Measured memory_bytes: 9108
#include <stdio.h>

int main(void){
    int i=1,n,ans=0;
    scanf("%d",&n);
    while(i<=100){
        if((n/i) % 10 == 7){
            ans = 1;
        }
        i *= 10;
    }
    if(ans == 1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1604
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define ll long long int
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'
 
 
 
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
/*typedef tuple<ll,ll,ll>tpl;
 
ll bigmod(ll n,ll pow)
{
    if(pow==0)
        return 1;
    if(pow==1)
        return n%MOD;
 
    ll ans=bigmod(n,pow/2);
    ans=(ans*ans)%MOD;
 
    if(pow%2==1)
    {
        ans=(ans*n)%MOD;
    }
    return ans%MOD;
}
 
ll fact[1000005];
 
ll nCr(ll n,ll r)
{
 
    ll ans=fact[n];
    ans=(ans*bigmod(fact[r],MOD-2))%MOD;
    ans=(ans*bigmod(fact[n-r],MOD-2))%MOD;
    return ans;
} */
 
ll rw[300005],cl[300005],mr=-1,mc=-1,ri=-1,ci=-1;
map<pair<ll,ll>,ll>mm;
int main()
{
    _fastio
    ll h,w,m,x,y;
    cin>>h>>w>>m;
 
    for1(i,m)
    {
        cin>>x>>y;
 
        cl[y]+=1;
        rw[x]+=1;
 
        mm[{x,y}]=1;
    }
 
    for1(i,h)
    {
        if(rw[i]>mr)
        {
            mr=rw[i];
            ri=i;
        }
    }
    ll ans=0;
    for(ll i=1;i<=w;i++)
    {
        ll cn=mr+cl[i];
        if(mm[{ri,i}]==1)
            cn-=1;
        ans=max(ans,cn);
    }
    //cout<<"1="<<ans<<en;
    for1(i,w)
    {
        if(cl[i]>mc)
        {
            mc=cl[i];
            ci=i;
        }
    }
    for(ll i=1;i<=h;i++)
    {
        ll cn=mc+rw[i];
        if(mm[{i,ci}]==1)
            cn-=1;
        ans=max(ans,cn);
    }

    cout<<ans<<en;
}

Measured memory_bytes: 64560
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())

dp = [[h*w for i in range(w+1)] for j in range(h+1)]

dp[0][1] = 0
dp[1][0] = 0

for i in range(h):
    for j in range(w):
        dp[i+1][j+1] = min(
            dp[i][j+1] + (s[i][j] == '#' and (i == 0 or s[i-1][j] == '.')),
            dp[i+1][j] + (s[i][j] == '#' and (j == 0 or s[i][j-1] == '.'))
        )

print(dp[-1][-1])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
typedef long long ll;
long bigp = 1000000007;

int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i,n){cin >> v[i];}
    ll maxvalue = 0;
    reps(a,0,n+1){
        reps(b,0,n+1){
            if(a+b>k){continue;}
            if(a+b>n){continue;}
            vector<ll> soto;
            reps(i,0,a){soto.push_back(v[i]);}
            repr(i,n-1,n-b-1){soto.push_back(v[i]);}
            sort(soto.begin(),soto.end());
            int s = soto.size();
            ll value = 0;

            repr(i,s-1,-1){
                value += soto[i];
                if(value > maxvalue && k-(a+b) >= i){
                    maxvalue = value;
                }
            }
        }
    }
    cout << maxvalue;
}

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

using namespace std;

//#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

int digit(int n) {
  int ans = 0;
  while(n > 0) {
    ans++;
    n /= 10;
  }
  return ans;
}

signed main () {
  cin.tie(0);
  cout << setprecision(10);
  int n, m; cin >> n >> m;
  vector<vector<pair<int, pair<int, int>>>> a(n);
  int tmpp, tmpy;
  pair<int, pair<int, int>> p;
  REP(i, m) {
    cin >> tmpp >> tmpy;
    p.first = tmpy;
    p.second.first = tmpp;
    p.second.second = i;
    a[tmpp-1].pb(p);
  }
  REP(i, n) {
    sort(a[i].begin(), a[i].end());
  }

  vector<string> ans(m);
  string s = "";
  REP(i, n) {
    REP(j, a[i].size()) {
      s = "";
      REP(k, 6-digit(a[i][j].second.first)) s += "0";
      s += to_string(a[i][j].second.first);
      REP(k, 6-digit(j+1)) s += "0";
      s += to_string(j+1);
      ans[a[i][j].second.second] = s;
    }
  }

  REP(i, m) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 12416
v = []
for i in range(2):
    x = list(map(int, input().split()))
    N, x = x[0], x[1:]
    for j in range(N):
        v.append(x[j * 2] * 60 + x[j * 2 + 1])
print(' '.join(['{0}:{1:02d}'.format(i // 60, i % 60) for i in sorted(set(v))]))

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

struct Card{ char suit, value;};

void bubble(struct Card A[], int N){
  Card tmp;

  for( int i = 0; i < N-1; i++){
    for( int j = N-1; j >= i; j--) {
      if (A[j].value < A[j-1].value) {
        tmp = A[j-1]; A[j-1] = A[j]; A[j] = tmp;
      }
    }
  }
}

void selection(struct Card A[], int N) {
  int minj;
  Card tmp;

  for ( int i = 0; i < N-1; i++) {
    minj = i;
    for ( int j = i; j < N; j++) {
      if ( A[j].value < A[minj].value ) minj = j;
    }
    tmp = A[i]; A[i] = A[minj]; A[minj] = tmp;
  }
}

void print(struct Card A[], int N) {
  for ( int i = 0; i < N; i++) {
    if ( i > 0 ) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}      

bool isStable(struct Card C1[], struct Card C2[], int N) {
  for ( int i = 0; i < N; i++) {
    if ( C1[i].suit != C2[i].suit ) return false;
  }
  return true;
}

int main() {
  Card C1[100], C2[100];
  int N;
  char ch;

  cin >> N;
  for ( int i = 0; i < N; i++ ) {
    cin >> C1[i].suit >> C1[i].value;
  }

  for ( int i = 0; i < N; i++ ) C2[i] = C1[i];

  bubble(C1, N);
  selection(C2, N);

  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if ( isStable(C1, C2, N) ){
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  return 0;
}


Measured memory_bytes: 3088
X = int(input())
X_i = X 

while X_i >= X:
  ans = 0 
  for i in range(2,int(X_i//(X_i**(1/2))//1)+1):
      if X_i%i == 0:
        ans = 1
        break
      else:
        continue
  if ans != 0:
    X_i += 1
  else:
    print(X_i)
    break

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
 int main(void){
	 int N,sum=0,go=0;
	 cin >> N;
	 int P[N+10];
	 for(int i=0; i<N; i++){
		 cin >> P[i];
		 sum=max(sum,P[i]);
		 go+=P[i];
	 }cout << go-sum/2 << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int n;
vector<vi> G;
vi num;
vi nchild;

void dfs(int v, int pv, int npar){
    num[v] = npar, nchild[v] = 0;

    for(auto& nv : G[v]){
        if(nv == pv) continue;
        dfs(nv, v, min(2, 1 + npar) + nchild[v]);
        nchild[v]++;
    }
}

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

    ll K; cin >> n >> K;
    G = vector<vi>(n);
    rep(_, n-1){
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    num = nchild = vi(n);
    dfs(0, -1, 0);
    ll res = 1LL;
    for(auto& e : num){
        res = MUL(res, max(0LL, K - e));
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 1000006, MAXM = 1003, Mod = 1000000007 , MAXLog = 20;


double area(int n, vector<pair<pair<int, int>, char>> &arr, double moment) {
    double mnx = LLONG_MAX, mxx = LLONG_MIN, mny = LLONG_MAX, mxy = LLONG_MIN;
    for (int i = 0; i < n; ++i) {
        double x = arr[i].first.first;
        double y = arr[i].first.second;
        if (arr[i].second == 'R') {
            x += moment;
        } else if (arr[i].second == 'L') {
            x -= moment;
        } else if (arr[i].second == 'U') {
            y += moment;
        } else {
            y -= moment;
        }
        mnx = min(mnx, x);
        mxx = max(mxx, x);
        mny = min(mny, y);
        mxy = max(mxy, y);
    }
//    cout << mxx << ' ' << mnx << ' ' << mxy << ' ' << mny << '\n';
    return 1.0 * (mxx - mnx) * (mxy - mny);
}


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    int n;
    cin >> n;
    vector<pair<pair<int, int>, char>> arr(n);
    for (int i = 0; i < n; ++i) {
        cin >> arr[i].first.first >> arr[i].first.second >> arr[i].second;
    }

    double l = 0, r = inf;
    double ans = LLONG_MAX;
    for (int i = 0; i < 300; ++i) {
        double m1 = l + (r - l) / 3;
        double m2 = r - (r - l) / 3;
        double f1 = area(n, arr, m1);
        double f2 = area(n, arr, m2);
        if (f1 > f2) {
            l = m1;
        } else {
            r = m2;
        }
        ans = min(ans, min(f1, f2));
    }

    cout << area(n, arr, r) << '\n';

    return 0;
}

Measured memory_bytes: 1408
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		long A = sc.nextInt();
		long B = sc.nextInt();

		System.out.println(A * B / gcd(A, B));

	}

	public static long gcd(long a, long b) {

		if (a < b)
			return gcd(b, a);

		long c = 0;
		c = a % b;

		if (c == 0)
			return b;

		return gcd(b, c);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	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 long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22484
#include <iostream>

int main(){
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    int l = a + b, r = c + d;
    if(l > r){
        std::cout << "Left" << std::endl;
    }else if(l == r){
        std::cout << "Balanced" << std::endl;
    }else{
        std::cout << "Right" << std::endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>

using namespace std;

int main(){
	int a,b,c,d,e = -1;
	cin >> a >> b >> c;
	
	if(a == 1)
		e = 1;
	d = a;
	for(;;){
		if(a > b)
			break;
		a+=a;
	}
	
	for(int i = 0; i < b+1; i++){
		if(a % b == c){
			e = 1;
			break;
		}
		a += d;
	}
		
	if(e == 1){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

ll gcd(ll a, ll b)
{
    if (a < b) {
      ll c=a;
      a=b;
      b=c;
    }
    
    return b ? gcd(b, a % b) : a;
}

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

int main(){
  ll a,b;
  cin>>a>>b;
  ll y = lcm(a, b);
  cout<<y<<endl;
  return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vi isprime(60000, 1);
	isprime[0] = 0; isprime[1] = 0;
	REP(i, isprime.size()) {
		if (isprime[i]) {
			for (int j = 2; i*j < isprime.size(); ++j) {
				isprime[i*j] = 0;
			}
		}
	}
	vi p;
	REP(i, isprime.size()) {
		if (i % 5 == 1 && isprime[i])p.push_back(i);
	}
	REP(i, n) {
		if (i)cout << " ";
		cout << p[i];
	}
	cout << endl;

}


Measured memory_bytes: 512
// hmmmm ...coool
#include<bits/stdc++.h>
using namespace std;  
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n; i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  // #endif
  IOS;
  int T=1;
  // cin >> T;
  while(T--){
    int n, k;
    cin >> k >> n;
    map<int,int>mp;
    fn{
      cin >> ar[i];
      mp[ar[i]]=1;
    }
    vector<int>v;
    for(int i=-1000;i<=1000;i++)if(mp[i]==0)v.pb(i);
    int diff = INT_MAX , ans=INT_MAX;
    for(int i =0 ;i < v.size();i++){
      int x = abs(k - v[i]);    
      if(diff > x){
        diff =x ;
        ans = v[i];
      }else if(diff ==x){
        ans = min(ans,v[i]);
      }
    }
    cout<<ans;
  
  }
  return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int N;
    cin >> N;
    vector<LL> x(N);
    vector<LL> y(N);

    REP(i,N){
        cin >> x[i] >> y[i];
    }

    vector<LL> z(N);
    vector<LL> w(N);
    REP(i,N){
        z[i] = x[i] + y[i];
        w[i] = x[i] - y[i];
    }

    LL max_Z = *max_element(z.begin(), z.end());
    LL min_Z = *min_element(z.begin(), z.end());
    
    LL max_W = *max_element(w.begin(), w.end());
    LL min_W = *min_element(w.begin(), w.end());

    LL ans = max({max_Z-min_Z, max_W-min_W});

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

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

using Edges=vector<int>;
using Graph=vector<Edges>;
const int HALF=20;
vector<int> dp0(1<<HALF);
vector<int> vs0(HALF,0);
vector<int> dp1(1<<HALF);
vector<int> vs1(HALF,0);
int solve(Graph& g,vector<int>& b){
    int n=g.size();
    if(n==1){
        return b[0];
    }
    int half=n/2;
    int rest=n-half;
    const int INF=1e6;
    for(int i=0;i<half;i++){
        vs0[i]=0;
        for(int j=0;j<g[i].size();j++){
            if(g[i][j]<half) vs0[i]|=(1<<g[i][j]);
        }
    }
    for(int i=1;i<(1<<half);i+=2){
        int vs=0;
        int val=0;
        for(int j=0;j<half;j++){
            if((1<<j)&i){
                val+=b[j];
                vs|=vs0[j];
            }
            if(vs&i) val=-INF;
            dp0[i]=val;
        }
    }

    
    for(int i=0;i<rest;i++){
        vs1[i]=0;
        for(int j=0;j<g[i+half].size();j++){
            if(g[i+half][j]>=half) vs1[i]|=(1<<(g[i+half][j]-half));
        }
    }
    for(int i=0;i<(1<<rest);i++){
        bool isok=true;
        int vs=0;
        int val=0;
        for(int j=0;j<rest;j++){
            if((1<<j)&i){
                val+=b[j+half];
                vs|=vs1[j];
            }
            if(i&vs) val=-INF;
            dp1[i]=val;
        }
    }
    for(int i=0;i<(1<<rest);i++){
        for(int j=0;j<rest;j++){
            dp1[i|(1<<j)]=max(dp1[i|(1<<j)],dp1[i]); 
        }
    }

    vector<int> vs01(half,0);
    for(int i=0;i<half;i++){
        for(int j=0;j<g[i].size();j++){
            if(g[i][j]>=half) vs01[i]|=(1<<(g[i][j]-half));
        }
    }
    int res=0;
    vector<int> opn(1<<half,(1<<rest)-1);
    for(int i=1;i<(1<<half);i+=2){
        int opn=(1<<rest)-1;
        for(int j=0;j<half;j++){
            if(i&(1<<j)) opn&=~vs01[j];
        }
        res=max(res,dp0[i]+dp1[opn]);
    }
    return res;
}

int main(){
    //ios_base::sync_with_stdio(false);
    int n;
    while(cin>>n,n){
        vector<string> a(n);
        vector<int> b(n);
        vector<int> c(n);
        vector<vector<string>> d(n);
        for(int i=0;i<n;i++){
            cin>>a[i]>>b[i]>>c[i];
            d[i].assign(c[i],"");
            for(int j=0;j<c[i];j++){
                cin>>d[i][j];
            }
        }

        map<string,int> dic;
        for(int i=0;i<n;i++) dic[a[i]]=i;
        Graph g(n);
        for(int i=0;i<n;i++){
            for(int j=0;j<c[i];j++){
                int v=dic[d[i][j]];
                g[i].push_back(v);
            }
        }
        cout<<solve(g,b)<<"\n";
    }
    return 0;
}


Measured memory_bytes: 15332