akhauriyash/Code-Regression huggingface dataset:
long M=1e9+7,m[1<<18],h,w,a,s;long p(a,b)long a,b;{return b?b%2?p(a*a%M,b/2)*a%M:p(a*a%M,b/2):1;}main(i){for(*m=1;i<1<<18;i++)m[i]=m[i-1]*i%M;for(scanf("%d%d%d%d",&h,&w,&a,&i);i<w;i++)s=(s+m[h-a-1+i]*p(m[h-a-1],M-2)%M*p(m[i],M-2)%M*m[a+w-i-2]%M*p(m[a-1],M-2)%M*p(m[w-i-1],M-2)%M)%M;printf("%d",s);}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll xpowy(ll x, ll y) {
    ll res = 1LL;
    while (y > 0) {
        if ((y & 1)) 
            res = res * x;
        x = x * x;
        y >>= 1;
    }
    return res;
}

ll x, y;    
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> x >> y;
    ll i = 1LL;
    while (x * xpowy(2, i-1) <= y) i++;
    printf("%lld\n", i-1);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  string s,t;
  cin >>s>>t;
  ll ss=s.size(),ts=t.size();
  vector <string> v;
  for(ll i=0;i<ss;i++){
    if(s[i]==t[0]||s[i]=='?'){
      string p;ll k=0,fl=0;
      for(ll j=i;j<ss;j++){
         if(k==ts) break;
         if(j==ss-1&&k<ts-1){
           fl=0;
           break;
         }
         if(s[j]==t[k]||s[j]=='?'){
           fl=1;
           k++;
         }
         else {
           fl=0;
           break;
         }
      }
      if(fl==1){
        string q;
        for(ll l=0;l<ss;l++){
          if(l==i){
            q+=t;
            l+=(ts-1);
          }
          else if(s[l]=='?') q+='a';
          else q+=s[l];
        }
        v.push_back(q);
      }
    }
   }
   ll vs=v.size();
   if(vs==0) cout <<"UNRESTORABLE"<<endl;
   else{
     sort(v.begin(),v.end());
     cout <<v[0]<<endl;
   }
  }


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;  typedef pair<int,ll> pii;
typedef vector<int> VI; typedef vector<ll> VL;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	if(abs(n-m) >=2){puts("0"); return 0;}
	ll ans = n==m? 2:1;
	rep2(i,1,n+1){
		(ans *= i )%=MD;
	}
	rep2(i,1,m+1){
		(ans *= i )%=MD;
	}
	
	cout <<ans <<"\n";
	
	return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())


ans = 0

for ai in range(a+1):
    for bi in range(b+1):
        for ci in range(c+1):
#            print((ai,bi,ci))
            ans += 1 if x == 500*ai + 100*bi + 50*ci else 0

print(ans)

Measured memory_bytes: 3064
function main(input){
  input = input.split("\n");
//  const N = parseInt(input[0]);
  const AB = input[0].split(" ").map(x => parseInt(x))
//  console.log(AB);

  if((AB[0]+AB[1])%2 == 1){
    console.log('IMPOSSIBLE');
  }else{
    console.log((AB[0]+AB[1])/2);
  }


}
  
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21952
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct LIST{//?§????????????£?¨?
  struct LIST *prev;//??????????´??????????????????????
  struct LIST *next;//??????????´??????????????????????
  int key;
};

struct LIST *list;//???????????????????????????
void insert(int x);//?????¨????????¢??°?????£?¨?
void delete(int x);
void deleteFirst();
void deleteLast();
void printList();

int main(void){
  list=(struct LIST *)malloc(sizeof(struct LIST));//?????¢????¢????
  list->next=list;//?????????????´???????????????????????????????
  list->prev=list;
  int key,N;
  char comm[20];
  scanf("%d",&N);//????????°????????????
  for(int i=0;i<N;i++){//?????????????????????
    scanf("%s%d",comm,&key);
    if(comm[0]=='i'){//insert
      insert(key);
    }else{
      if(strlen(comm)>6){
        if(comm[6]=='F'){//deleteFirst
          deleteFirst();
        }else if(comm[6]=='L'){//deleteLast
          deleteLast();
        }
      }else{//delete
        delete(key);
      }
    }
  }
  printList();
  return 0;
}

void insert(int x){//????????¨?¬????????´????????????¢????????????????´?????????\??????
  struct LIST *y = (struct LIST *)malloc(sizeof(struct LIST));//?????\??????????????°????????????????¢????
    y->key = x;
    y->next = list->next;
    list->next->prev = y;
    list->next = y;
    y->prev = list;
}

void delete(int x){//????????????key?????????
  struct LIST *i = list->next;//list????¬????????´?????????????????±?????????????
  while(i != list && i->key != x ) {//???????????????key??¨?????´??????????´??????¢???
      i = i ->next;
    }
  if(i==list)return;//???????????????????????????????????£?????´??????i???list??????????????????????????£??????????????§?????????????????¢??°?????????
  i->prev->next=i->next;
  i->next->prev=i->prev;
  free(i);//?????¢???????§£???
}

void deleteFirst(){
  struct LIST *t = list->next;//list????¬????????´?????????????????????????????´??????????
  if(t==list)return;//list->next=list?????????????´???????????????§?????????????????¢??°?????????
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);//?????¢???????§£???
}

void deleteLast(){
  struct LIST *t = list->prev;//list??????????????????????????????????´??????????
  if(t==list)return;//?????????????§????????????????????´???????????????§??¢??°?????????
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);//?????¢???????§£???
}

void printList(){//????????????????´??????????
  struct LIST *i;
  i = list->next;//??????????¬????????????????????´?
  int j = 0;
  while(1) {
    if (i == list) break;//i=list?????´??????????´????????????????????????????????????????????????????
    if(j++ > 0) printf(" ");//?????????????????????????????????????????????????????§???????????????
    printf("%d", i->key);//key?????????
    i = i->next;//?¬????????´????
  }
  printf("\n");
}

Measured memory_bytes: 32920
#include <iostream>

using namespace std;

int main(void){
	const int N = 123456 * 2 + 1;
	bool num[N];
	for(int i = 1; i < N; i ++) num[i] = i - 1;
	for(int i = 2; i * i < N; i ++) if(num[i]) for(int j = i; i * j < N; j ++) num[i * j] = false;

	for(int n, count = 0; cin >> n, n; cout << count << endl, count = 0)
		for(int i = n + 1; i <= 2 * n; i ++) if(num[i]) count ++;

	return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

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

        int i, j, t;
        int cnt = 0;
        int check = 0;
        int mini, minikey;
        int n = sc.nextInt();
        int[] num;
        num = new int[n];

        for(i=0; i<n; i++){
            num[i] = sc.nextInt();
        }

        for(i=0; i<n-1; i++){
            mini =i;
            minikey = num[i];
            for(j=i+1; j < n; j++){
                if(num[j] < minikey){
                    mini = j;
                    minikey = num[j];
                    check++;
                }
            }
            t = num[i];
            num[i] = num[mini];
            num[mini] = t;
            if(check >0)
                cnt++; check=0;
        }

        for(i=0; i<n-1; i++){
            System.out.print(num[i]+" ");
        }
        System.out.println(num[n-1]);
        System.out.println(cnt);
        sc.close();


    }
}


Measured memory_bytes: 26404
<?php

class In {

	private $buf = [];
	private $count = 0;
	private $pointer = 0;

	public function nextLine() {
		$ret = '';
		if($this->hasNext()){
			while($this->hasNext()){
				$ret .= $this->next();
			}
		}else{
			$ret = trim(fgets(STDIN));
		}

		return $ret;
	}

	public function next() {
		if(!$this->hasNext()) {
			$str = trim(fgets(STDIN));
			$this->buf = explode(' ',$str);
			$this->count = count($this->buf);
			$this->pointer = 0;
		}

		return $this->buf[$this->pointer++];
	}

	public function hasNext() {
		return $this->pointer < $this->count;
	}

	public function nextInt() {
		return (int)$this->next();
	}

	public function nextDouble() {
		return (double)$this->next();
	}
}

class Out {
	public function println($str = '') {
		echo $str . PHP_EOL;
	}
}

$in = new In();
$out = new Out();

$A = $in->nextInt();
$B = $in->nextInt();
$C = $in->nextInt();

if ($A <= $C && $C <= $B) {
	$out->println('Yes');
} else {
	$out->println('No');
}

?>


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

const int N = 1e5 + 7;

int a[N];
int n;
int tp[N];
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	sort (a + 1, a + n + 1, greater<int>());
	for (int i = n; i >= 1; i--) {
		if (a[i] > a[i + 1])
			continue;
		if (tp[i + 1] == 0)
			tp[i] = 1;
	}
	int x = 1;
	while (x < n && a[x + 1] >= x + 1)
		x++;
	if (a[x] == x) {
		if (tp[x]) {
			cout << "First";
			return 0;
		} 
		else {
			cout << "Second";
			return 0;
		}
	}
	if (x + 1 <= n) {
		if (a[x + 1] == x) {
			if (tp[x + 1] == 0) {
				cout << "First";
				return 0;
			}
			if (x % 2 == a[x] % 2) {
				cout << "Second";
				return 0;
			}
			else {
				cout << "First";
				return 0;
			}
		}
	}
	if (x % 2 == a[x] % 2) {
		cout << "Second";
		return 0;
	}
	else {
		cout << "First";
		return 0;
	}
	
	return 0;
}

















Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    ull N,ans=0,a=0;
    cin >> N;
    if(N%2==1)
        ans = 0;
    else
    {
        N /= 2;
        while (N >= 5)
        {
            N /= 5;
            a += N;
        }
        ans += a;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;

const ll INF = 1LL << 60;

class mint
{
  const ll mod = 1000000007;
  ll x;

public:
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const
  {
    return mint(-x);
  }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint &a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint &a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint &a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint &a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint &a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint &a) const
  {
    mint res(*this);
    return res /= a;
  }
  friend ostream &operator<<(ostream &os, const mint &m)
  {
    os << m.x;
    return os;
  }
};

int main()
{
  ll N, K;
  cin >> N >> K;

  mint ans = 0;
  FOR(k, K, N + 1)
  {
    ll min = (k - 1) * k / 2;
    ll max = (2 * N - k + 1) * k / 2;

    ans += max - min + 1;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
using namespace std;
int n,m,q,v[2002][2002],e[2][2002][2002];
string s[2002];
int main(void){
    cin>>n>>m>>q;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            v[i][j]=e[0][i][j]=e[1][i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1][j-1]=='1'){
                v[i][j]++;
                if(j>1){
                    if(s[i-1][j-2]=='1'){
                        e[0][i][j]++;
                    }
                }
                if(i>1){
                    if(s[i-2][j-1]=='1'){
                        e[1][i][j]++;
                    }
                }
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            v[i][j]+=v[i][j-1];
            e[0][i][j]+=e[0][i][j-1];
            e[1][i][j]+=e[1][i][j-1];
        }
    }
    for(int j=1;j<=m;j++){
        for(int i=1;i<=n;i++){
            v[i][j]+=v[i-1][j];
            e[0][i][j]+=e[0][i-1][j];
            e[1][i][j]+=e[1][i-1][j];
        }
    }

    for(int i=0;i<q;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int t=0;
        t+=v[c][d]-v[c][b-1]-v[a-1][d]+v[a-1][b-1];
        t-=e[0][c][d]-e[0][c][b]-e[0][a-1][d]+e[0][a-1][b];
        t-=e[1][c][d]-e[1][c][b-1]-e[1][a][d]+e[1][a][b-1];
        cout<<t<<endl;
    }
}


Measured memory_bytes: 52864
n,m=map(int,input().split())
x=list(map(int,input().split()))
if n>=m:
    print(0)
else:
    y=sorted(x)
    s= sorted([y[i]-y[i-1] for i in range(1, m)])
    ans=0
    for i in range(m-n):
        ans += s[i]
    print(ans)


Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

template<class S>int sum(vector<S>&a){return accumulate(all(a),int());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

int main(void){
	int n,m;
	cin >> n >> m;
	vector<ll> h(n);
	rep(i,n) cin >> h[i];
	vector<bool> good(n, true);
	Rep(m){
		int a,b; cin >> a >> b;
		if(h[--a] >= h[--b]) good[b] = false;
		if(h[b] >= h[a]) good[a] = false;
	}
	cout << sum(good) << endl;
}

Measured memory_bytes: 4028
while True:
    a,b=map(int,input().split())
    if a ==0 and b==0:
        break
    for u in range(a):
        for i in range(b):

            if (i+u)%2==0:
                print("#", end="")
            else:
                print(".", end="")
        print()

    print()


Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;
// int64_tは9*10^18まで、intは2*10^9まで

#define MAX_N 1000002

int prime[MAX_N];         // i番目の素数
bool is_prime[MAX_N + 1]; // is_prime[i]がtrueならiは素数

int sieve(int n) { // n以下の素数の数を返す
  int p = 0;
  for (int i = 0; i <= n; i++)
    is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime[p++] = i;
      for (int j = 2 * i; j <= n; j += i)
        is_prime[j] = false;
    }
  }
  return p;
}

int main() {
  int n, flaga=0;
  set<int> s;
  cin >> n;
  int p = sieve(1000);
  int b[p] = {0}, c[p] = {0}, a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  if(n==2){
    if(gcd(a[0], a[1])==1)
      cout << "pairwise coprime";
    else
      cout << "not coprime";
    return 0;
  }
  
  int flag = 0;
  for (int i = 1; i <n; i++) {
    if (a[i] == a[i - 1] && a[i]!=1)
      flag++;
  }
  if (flag == n-1) {
    cout << "not coprime";
    return 0;
  }
  
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < p; j++) {
      if (a[i] % prime[j] == 0){
        while(a[i]%prime[j]==0){
          a[i]/=prime[j];
        }
        b[j]++;
      }
      else
        c[j]++;
    }
    if(a[i]!=1&&!s.count(a[i])){
      s.insert(a[i]);
    }
    else if(a[i]!=1){
      flaga++;
    }
  }
  int flagb = 0, flagc = 0;
  for (int i = 0; i < p; i++) {
    if (b[i] >= 2)
      flagb++;
    if (c[i] == 0)
      flagc++;
  }

  if(flaga>0&&flaga<n-1&&flagc==0){
    cout << "setwise coprime";
    return 0;
  }
  if(flaga>0){
    cout << "not coprime";
    return 0;
  }
  
  if (flagb == 0 &&flag==0)
    cout << "pairwise coprime";
  else if (flagc == 0)
    cout << "setwise coprime";
  else
    cout << "not coprime";
  return 0;
}


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

#define ALL(a)  (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define REP(i,n) for(int i=0;i<(int)n;++i)

#define CLEAR(a) memset((a), 0, sizeof(a))

inline int toInt(string s) { int x; istringstream iss(s); iss >> x; return x; }
template<class T> inline string toString(T x) { ostringstream oss; oss <<x ; return oss.str(); }
template<class T> inline T sqr(T x) { return x * x; }

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

static const auto io_sync_off = []() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    return nullptr;
}();

using value_type = pair<int, int>;
struct value_order {
  bool operator()(const value_type& x, const value_type& y) const {
    return x.second < y.second;
  }
};

int main(int argc, char *argv[]) {
    int n; cin >> n;

    map<int, int> odd, even;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        if (i % 2 == 0) even[x]++; else odd[x]++;
    }

    priority_queue<value_type, vector<value_type>, value_order> p, q;
    for (auto x : even) p.push(x);
    for (auto x : odd) q.push(x);

    int ans = 0;
    if (p.top().first == q.top().first) {
        int np = p.top().second;
        int nq = q.top().second;

        ans = min(n - np, n - nq);

        p.pop(); q.pop();
        if (!q.empty()) ans = min(ans, n - np - q.top().second);
        if (!p.empty()) ans = min(ans, n - nq - p.top().second);
    }
    else {
        ans = n - p.top().second - q.top().second;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 6140
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = int64_t;
using namespace std;

int main(){
  int r;cin>>r;
  cout << fixed << setprecision(5);
  cout<<2*r*3.1415926;
}

Measured memory_bytes: 3784
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().ToCharArray();

        var flag1 = false;
        var flag2 = false;

        if(input[2] == input[3])
        {
            flag1 = true;
        }
        if (input[4] == input[5])
        {
            flag2 = true;
        }

        if(flag1 && flag2)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");

        }

        Console.ReadLine();
    }
}



Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//W?????????
		int W = sc.nextInt();
		//H?????????
		int H = sc.nextInt();
		//x?????????
		int x = sc.nextInt();
		//y?????????
		int y = sc.nextInt();
		//r?????????
		int r = sc.nextInt();

		//?????¶???
		if((x + r) <= W && (y + r) <= H && 0 <= (x - r) && 0 <= (y - r)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

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

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

  sort(a, a + N, greater<int>());
  int Alice = 0;
  int Bob = 0;
  for (int i = 0; i < N; ++i) {
    if (i % 2 == 0) {
      Alice += a[i];
    } else {
      Bob += a[i];
    }
  }
  cout << Alice - Bob << endl;
}

Measured memory_bytes: 3600
def lower_bound(li,a):
  l,r=-1,len(li)
  while r-l!=1:
    t=(l+r)//2
    if li[t]>=a:
      r=t
    else:
      l=t
  return r

n,m=map(int,input().split())
a=list(map(int,input().split()))
q=[]
for i in range(m):
  b,c=map(int,input().split())
  q.append((c,b))

a.sort()
q.sort()
q.reverse()

t=0
sm=0
for i in q:
  s=max(min(lower_bound(a,i[0]),t+i[1]),t)
  sm+=(s-t)*i[0]
  t=s
sm+=sum(a[t:])
print(sm)
  
  

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

key_list = make_divisors(n)
ans = 10000000000000
for value in key_list:
    key = value + n//value - 2
    if key < ans:
        ans = key
print(ans)

Measured memory_bytes: 3364
(
    (stdin.ReadLine() |> int),
    (stdin.ReadLine() |> Seq.map string |> Seq.toList)
)
|> fun (n, s) ->
  s.[1..(n - 1)]
  |> Seq.fold (fun (prev, prevRet, ret) cur ->
    (
        (if prev = "E" then  0 else 1),
        (if cur  = "E" then -1 else 0)
    )
    |> (fun (a, b) -> prevRet + a + b)
    |> (fun newPrevRet ->
        (cur, newPrevRet, min ret newPrevRet)
    )
  ) (
    s.[1..(n - 1)]
    |> Seq.filter (fun x -> x = "E") 
    |> Seq.length
    |> fun x -> (s.[0], x, x)
  )
  |> (fun (_, _, ret) -> ret)
  |> printfn "%d"


Measured memory_bytes: 57012
class PriorityQueue

  def initialize(heap=[])
    @size = heap.size
    @heap = heap.sort
  end

  # log( log n )
  def push x
    i = @size
    @size += 1
    while i > 0
      par = ( i - 1 ) / 2
      break if @heap[par] <= x
      @heap[i] = @heap[par]
      i = par
    end
    @heap[i] = x
  end

  # log( log n )
  # return nil if @size == 0
  def pop

    ret = @heap[0]
    x = @heap[@size-=1]
    # @heap.delete_at(-1)

    i = 0
    while (child = i * 2 + 1) < @size
      child_1 = i * 2 + 2
      child = child_1 if child_1 < @size && @heap[child_1] < @heap[child]
      break if @heap[child] >= x
      @heap[i] = @heap[child]
      i = child
    end

    @heap[i] = x
    @heap.delete_at(-1)
    ret
  end

  def size
    @heap.size
  end

  def top
    @heap[0]
  end

  def any?
    @size > 0
  end

  def empty?
    @size == 0
  end

  def all
    @heap
  end

  def first
    @heap[0]
  end

  def second
    @size < 3 ? @heap[1] : [@heap[1], @heap[2]].min
  end

  def third
    @size < 3 ? nil : [@heap[1], @heap[2]].max
  end
  
  def sum
    @heap.reduce(0){|s,t| s+t }
  end
  
  def update
    if second && (-top) / 2 < -second
      push( -( -pop / 2 ))
    else
      @heap[0] = -( -@heap[0] / 2 )
    end
    @heap
  end
end

class Array

  include Comparable

  def to_pq
    PriorityQueue.new(self)
  end
  
  def -@
    map{|e| -e.to_i }
  end
end

n, m = gets.to_s.split.map{|t|  t.to_i }
a    = gets.to_s.split.map{|t| -t.to_i }
# 大きい順に見たいが、PriorityQueueが小さいのが優先なので、マイナスをつけていく。

q = PriorityQueue.new(a)

m.times do
  q.update
end
# p q.all
puts -q.sum

Measured memory_bytes: 11912
#include <iostream>

int main()
{
	int N;
	int S[4] = {0};
	char str[4];

	std::cin >> N;
	for( int i = 0; i < N; i++ ){
		std::cin >> str;
		S[0] += !!(str[0]=='A');
		S[1] += !!(str[0]=='W');
		S[2] += !!(str[0]=='T');
		S[3] += !!(str[0]=='R');
	}

	std::cout << "AC x " << S[0] << '\n'
			  << "WA x " << S[1] << '\n'
			  << "TLE x " << S[2] << '\n'
			  << "RE x " << S[3]	<< std::endl;
}

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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans=1;
  for(int i=0; i<N-1; i++){
    if(S.at(i)!=S.at(i+1)){
      ans++;
    }
  }
  cout << ans << endl;
}

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

void solve(){
	long long n,W;
	cin>>n>>W;
	vector<long long> v(n);
	vector<long long> w(n);
	for(long long i=0;i<n;i++)
	{
			cin>>w[i];
		cin>>v[i];
	
	}
	unordered_map<long long,unordered_map<long long,long long>>dp;
	for(long long i=0;i<n;i++){
		for(long long j=0;j<=W;j++){
			if(j-w[i]>=0){
			
			dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
		}
		else{
			dp[i][j]=dp[i-1][j];
		}
		}
		
	}
	cout<<dp[n-1][W];
	
}



int main() {
solve();


}



Measured memory_bytes: 415688
#include <iostream>
#include <algorithm>
#include <queue>

#define rep(i,n) for (int i=0; i < (n); ++i)
using ll = long long ;
using namespace std;
const int INF = 1001001001;

int main() {

    int d,t,s ;
    cin >> d >> t >> s ;

    int ans = (d+s-1)/s ;
    if(ans>t)
     cout << "No" << endl ;
    else
     cout << "Yes" << endl ;     

    
    return 0 ;
}

Measured memory_bytes: 3584
/**
 *    Created By:  PeekyBlinders
 **/
#include <bits/stdc++.h>

using namespace std;

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define double long double
#define endl '\n'

template <typename T>
class Segtree {
public:
    struct node_t {
        T sumv;
        node_t() {
            sumv = (T) 0;
        };
        node_t(T value) {
            sumv = value;
        }
        
        void operator+= (const T other) {
            sumv += other;
        }
        
        friend ostream& operator<<(ostream &os , const node_t node) {
            return os << "[ " << node.sumv << " ]";
        }
    };
    
    int n;
    vector<node_t> t;
    vector<T> lazy;
    const int INF = (int) 1e9 + 7;
    node_t defaultValue = { (T) 0 };
    Segtree(int n) : n(n) {
        t.resize(4 * n);
        lazy.resize(4 * n);
    }
    
    node_t merge(node_t left , node_t right) {
        node_t mergedNode;
        mergedNode.sumv = left.sumv + right.sumv;
        return mergedNode;
    }
    
    void push(int id , int L , int R) {
        if(lazy[id] == 0) {
            return;
        }
        t[id] += (R - L + 1) * lazy[id];
        if(L != R) {
            lazy[id << 1] += lazy[id];
            lazy[id << 1 | 1] += lazy[id];
        }
        lazy[id] = 0;
    }
    
    /* Range Addition */
    void update(int id , int L , int R , int queryL , int queryR , T value) {
        if(L > queryR or R < queryL) return;
        push(id , L , R);
        if(L >= queryL and R <= queryR) {
            lazy[id] += value;
            push(id , L , R);
            return;
        }
        int mid = (L + R) >> 1;
        update(id << 1 , L , mid , queryL , queryR , value);
        update(id << 1 | 1 , mid + 1 , R , queryL , queryR , value);
        t[id] = merge(t[id << 1] , t[id << 1 | 1]);
    }
    
    /* Range Query */
    node_t get(int id , int L , int R , int queryL , int queryR) {
        if(L > queryR or R < queryL) {
            return defaultValue;
        }
        push(id , L , R);
        if(L >= queryL and R <= queryR) {
            return t[id];
        }
        int mid = (L + R) >> 1;
        node_t getL = get(id << 1 , L , mid , queryL , queryR);
        node_t getR = get(id << 1 | 1 , mid + 1 , R , queryL , queryR);
        return merge(getL , getR);
    }
};

signed main() {
    fio;
    int n , d , a; cin >> n >> d >> a;
    vector<int> x(n);
    map<int , int> health;
    for(int i = 0 , h; i < n; i++) {
        cin >> x[i] >> h;
        health[x[i]] = h;
    }
    sort(x.begin() , x.end());
    int answer = 0 , R = 0;
    Segtree<int> segtree(n);
    for(int i = 0; i < n; i++) segtree.update(1 , 0 , n - 1 , i , i , health[x[i]]);
    for(int L = 0; L < n; L++) {
        while(R < n and x[R] - x[L] <= 2 * d) {
            R++;
        }
        int left = segtree.get(1 , 0 , n - 1 , L , L).sumv;
        if(left <= 0) {
            continue;
        }
        int bombs = (left + a - 1) / a;
        answer += bombs;
        segtree.update(1 , 0 , n - 1 , L , R - 1 , -bombs * a);
    }
    
    cout << answer << endl;

    return 0;
}



Measured memory_bytes: 26880
import sys
'''
	??\?????????????????????
'''
_allinput = []
for inp in sys.stdin:
	_allinput += inp.strip().split(" ")
def _input():
	for put in _allinput:
		yield put
_obj = _input();
def __input():
	return _obj.__next__()
def nextInt():
	return int(__input())

def check(lst,L):
	tot = 1
	curSum = 0
	for i in lst:
		if curSum + i <= L:
			curSum += i
		else:
			curSum = i
			tot += 1
	return tot

def solve(lst,m):
	l,r = max(lst), 100000 * 10000
	while l != r:
		mid = int((l+r)/2)
		if check(lst,mid) <= m:
			r = mid
		else:
			l = mid + 1
	return l


n,m = nextInt(),nextInt()
if m > 0 or n > 0:
	lst = [nextInt() for i in range(0,n)]
	print(solve(lst,m))

Measured memory_bytes: 17968
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 81

char equation[NUM],buf[5];
int value[4];

int getNUM(char ch){
	return ch - 'a';
}

int calc_Hash(int left,int right){

	if(equation[left] != '['){ //letter
		return value[getNUM(equation[left])];
	}

	//[カッコ]で囲まれている場合

	char op = equation[left+1];
	int left_value,right_value,ret;

	if(equation[left+2] == '['){

		int depth = 0;
		int close_pos;

		for(int i = left+2; i <= right; i++){

			if(equation[i] == '['){

				depth++;

			}else if(equation[i] == ']'){

				depth--;

				if(depth == 0){

					close_pos = i;
					break;
				}
			}
		}

		left_value = calc_Hash(left+2,close_pos);
		right_value = calc_Hash(close_pos+1,right-1);

	}else{ //equation[left+2] == letter

		left_value = calc_Hash(left+2,left+2);
		right_value = calc_Hash(left+3,right-1);
	}

	switch(op){
	case '+':
		ret = left_value|right_value;
		break;
	case '*':
		ret = left_value&right_value;
		break;
	case '^':
		ret = left_value^right_value;
		break;
	}

	return ret;
}

void func(){

	scanf("%s",buf);

	for(int i = 0; i < 4; i++){

		value[i] = buf[i]-'0';
	}

	int length;

	for(length = 0; equation[length] != '\0'; length++);

	int first_value = calc_Hash(0,length-1);
	int count = 0;

	for(int a = 0; a <= 9; a++){
		for(int b = 0; b <= 9; b++){
			for(int c = 0; c <= 9; c++){
				for(int d = 0; d <= 9; d++){

					value[0] = a;
					value[1] = b;
					value[2] = c;
					value[3] = d;

					if(calc_Hash(0,length-1) == first_value){
						count++;
					}
				}
			}
		}
	}

	printf("%d %d\n",first_value,count);
}

int main(){

	while(true){
		scanf("%s",equation);
		if(equation[0] == '.')break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3204
N = int(input())
strX = input()

#10進数に変換
decX = int(strX,2)

#1の数をカウント
pop_c = strX.count('1')

# X % popcount+1
f_p = decX % (pop_c + 1)

# X % popcount-1(0になる時は0)
if pop_c == 1:
  f_m = 0
else:
  f_m = decX % (pop_c - 1)

for i in range(0,N):
  if strX[i] == '0':
    pop_a = (f_p + pow(2,(N-1-i),(pop_c + 1))) % (pop_c + 1) 
    Ans = 1
    
  elif pop_c == 1:
    pop_a = 0
    Ans = 0
    
  else:
    pop_a = f_m - (pow(2,(N-1-i),(pop_c - 1)))
    if pop_a < 0:
      pop_a = pop_a + pop_c - 1
    Ans = 1
  
  while pop_a > 0:
    wkpop = bin(pop_a).count('1')
    pop_a = pop_a % wkpop
    Ans += 1
  
  print(Ans)

Measured memory_bytes: 9452
#include<bits/stdc++.h>
using namespace std;
int n,k;
long long ans=0;
int main()
{
    //freopen("ce.in","r",stdin);
    scanf("%d%d",&n,&k);
    for(int b=k+1;b<=n;++b)
    {
        int num=(n+1)/b;
        ans+=1LL*num*(b-k);
        int left=n+1-num*b;
        --left;
        ans+=max(0,left-k+1);
        if(k==0) --ans;
    }
    printf("%lld\n",ans);
    return 0;
}


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

import sys

#def xcheck(n):
#	
#    m = int(n**.5)
#    return 1 if abs(m*m - n) < 1e-6 else 0
#	if(1):
#		#兵法数なら
#		return 1
#	return 0

n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

ans =[0] * n

###
#print(hoge)

sum = 0
for i in range(n):
#	print(i)
#	print(hoge[i])
	if(i%2 == 0):
		sum+=hoge[i]
	else:
		sum-=hoge[i]
#print(sum)
#ans[0]=sum//2
ans[0]=sum

#print(ans)

for i in range(1,n):
	ans[i]=(hoge[(i-1)] - ans[i-1]//2)*2
#	print((hoge[(i-1)] - ans[i-1]//2)*2)
#	print(i)



#print(ans)

tout=""

tout+=str(ans[0])
#print(tout)

for i in range(1,n):
	tout+=" "
	tout+=str(ans[i])

print(tout)





#	listx[i][j] = hoge[j]
#print(hoge[0])
#print(hoge[2])



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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    string S;
    cin >> S;
    int n = 0;
    REP(i, S.length())
    {
        n += (int)(S[i] - '0');
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define ll long long 
#define de() cout<<"test"<<"\n" 
using namespace std;
const int maxn=2e6+10;
const int mod=1000000007;
inline int read() {
	int data=0,f=1;char c=getchar();
	while('0'>c||c>'9') {
		if(c=='-') f=-1;c=getchar();
	}while('0'<=c&&c<='9') {
		data=data*10+c-'0';c=getchar();
	}return data*f;
}

int a[maxn],cnt[maxn],n,z1[maxn];
ll z2[maxn];
int lb(int x) { 
	return x&(-x);
}
void add(int x,int w) {
	for(int i=x;i<=n;i+=lb(i)) {
		z1[i]++;z2[i]=(z2[i]+w)%mod;
	}
}
ll sum1(int x) {
	ll ans=0;
	for(int i=x;i;i-=lb(i)) ans+=z1[i];
	return ans;
}
ll sum2(int x) {
	ll ans=0;//cout<<x<<"\n";
	for(int i=x;i;i-=lb(i)) ans=(ans+z2[i])%mod;
	return ans;
}
ll poww(ll x,ll k) {
	ll ans=1;
	while(k) {
		if(k&1) ans=ans*x%mod;
		x=x*x%mod;
		k>>=1;
	}
	return ans;
}
ll tot=1,D[maxn],invD[maxn],ans,inv2;
int s[maxn],ze[maxn];

int main() 
{
	scanf("%d",&n);inv2=poww(2,mod-2);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]),cnt[a[i]]++;
	for(int i=n;i;i--) cnt[i]+=cnt[i+1];
	for(int i=n;i;i--) tot=tot*(cnt[i]-(n-i))%mod,cnt[i]-=(n-i);
	D[0]=s[0]=1;
	if(tot==0) {
		puts("0");return 0;
	}
	for(int i=1;i<=n;++i) { 
		ll x=1ll*(cnt[i]-1)*poww(cnt[i],mod-2)%mod; 
		if(!x) { 
			s[ze[i]=ze[i-1]+1]=i;D[i]=D[i-1];
		} else ze[i]=ze[i-1],D[i]=D[i-1]*x%mod;
		invD[i]=poww(D[i],mod-2);
	}
	//for(int i=1;i<=n;++i) cout<<ze[i]<<"*\n";
	//puts("");
	for(int i=1;i<=n;++i) { 
		ans=(ans+(sum2(a[i])-sum2(s[ze[a[i]]]-1)+mod)*D[a[i]]%mod*tot%mod*inv2%mod)%mod;
		add(a[i],invD[a[i]]);  
	} 
	for(int i=0;i<=n;++i) z1[i]=z2[i]=0;
	for(int i=n;i;i--) { 
		ans=(ans-(sum2(a[i]-1)-sum2(s[ze[a[i]]]-1)+mod)*D[a[i]]%mod*tot%mod*inv2%mod+mod)%mod; 
		ans=(ans+1ll*tot*sum1(a[i]-1)%mod)%mod;
		add(a[i],invD[a[i]]);
	}
	cout<<ans<<"\n";
	return 0;
} 

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

int sum_max(int a, int b, int c, int k){
  if(a >= k) return k;
  if(b >= k - a) return a;
  return a + (k - a - b) * -1;
}

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  cout << sum_max(A, B, C, K) << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int N;
	getint(N);
	LLONG M;
	getint(M);
	int V, P;
	getint(V, P);

	std::vector<LLONG> ai(N);
	for (int i = 0; i < N; i++) {
		getint(ai[i]);
	}
	std::sort(ai.begin(), ai.end(), std::greater<LLONG>());
	
	int ans = 0;
	int start = P;
	int end = N - 1;
	while (1) {
		bool lower = false;
		int idx = (start + end) / 2;

		if (ai[idx] + M < ai[P - 1]) {
			lower = true;
		}
		else {
			LLONG pt = 0;
			for (int i = P - 1; i < idx; i++) {
				pt += (ai[idx] + M) - ai[i];
			}
			pt += M * (P - 1) + M * (N - idx);
			if (pt < (M * V)) {
				lower = true;
			}
		}

		if ((end - start) <= 1) {
			if (lower) {
				ans = idx;
			}
			else {
				if (idx != end) {
					idx = end;
					LLONG pt = 0;
					if (ai[idx] + M < ai[P - 1]) {
						lower = true;
					}
					else {
						for (int i = P - 1; i < idx; i++) {
							pt += (ai[idx] + M) - ai[i];
						}
						pt += M * (P - 1) + M * (N - idx);
						if (pt < (M * V)) {
							lower = true;
						}
					}
					if (lower) ans = idx;
					else ans = idx + 1;
				}
				else {
					ans = idx + 1;
				}
			}
			break;
		}

		if (lower) {
			end = idx;
		}
		else {
			start = idx;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 4056
/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int n,k;
int a[300000+20];
const int N=1<<19;
struct SEGMENT_TREE{
	int tree[N+N]={0};
	int query(int a,int b,int now=1,int l=1,int r=N+1){
		if(r<=a||l>=b){
			return 0;
		}
		if(r<=b&&l>=a){
			return tree[now];
		}
		int mid=(l+r)>>1;
		return max(query(a,b,now<<1,l,mid),query(a,b,now<<1|1,mid,r));
	}
	void modify(int index,int val){
		index+=N-1;
		check_max(tree[index],val);
		index>>=1;
		while(index){
			tree[index]=max(tree[index<<1],tree[index<<1|1]);
			index>>=1;
		} 
	}
}sgt;
int main(){
	fastio;
	R2(n,k);
	rb(i,1,n) R(a[i]),a[i]++;
	rb(i,1,n){
		int l,r;
		l=max(1,a[i]-k);
		r=min(N,a[i]+k);
		sgt.modify(a[i],sgt.query(l,r+1)+1); 
	}
	cout<<sgt.tree[1]<<endl;
	return 0;
}
/** 程序框架：
  *
  *
  *
  *
  **/


Measured memory_bytes: 7212
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> A(n+1), B(n+1);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        if(a == 1) {
            A[b] = true;
        }

        if(a == n) B[b] = true;
        if(b == n) B[a] = true;
    }

    for(int i = 1; i <= n; i++) {
        if(A[i] && B[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define gcd(a,b) __gcd(a,b)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define pb(n) push_back(n)
#define pp pop_back()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define type(a) typeid(a).name();
#define print(arr) cout << "[" ;for(unsigned int i=0;i<(unsigned int) arr.size();i++){ (i==arr.size()-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define Arr(arr,l) cout << "[" ;for(unsigned int i=0;i<(unsigned int) l;i++){ (i==l-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define console(arr) cout << "["<<endl; for(ll i=0;i<(ll)arr.size();++i){cout << " [";for(ll j=0;j<(ll)arr[i].size();++j){(j==(int)arr[i].size()-1)?cout << arr[i][j]:cout << arr[i][j] << ",";}cout << "]"<<endl;} cout << "]"<<endl
#define starting() auto start = high_resolution_clock::now()
#define ending() auto stop = high_resolution_clock::now();auto duration = duration_cast<microseconds>(stop - start);cout << endl << endl << "Execution Time : "<<duration.count()/1000 << " ms" << endl
 
template <typename T1,typename T2>
void mapped(map<T1,T2>m){for(auto ite=m.begin();ite!=m.end();++ite){cout << "'" << ite->first << "'"<<" : "<<ite->second <<endl;}}
 
template <typename T1 , typename T2>
void mappedArr(map<T1,vector<T2>>m){for(auto ity=m.begin();ity!=m.end();++ity){cout << "'"<< ity->first <<"'"<<" : "<<"[";
for(int i=0;i<(int)ity->second.size();++i){(i==(int)ity->second.size()-1)?cout << ity->second[i]:cout << ity->second[i] << ",";}cout << "]"<<endl;}}
 
string int_to_string(int x){ stringstream ss; ss << x; string ni = ss.str(); return ni;}
int char_to_int(char c){ int n = (int)c - 48; return n; }
int string_to_int(string x){ int n; stringstream s(x); s >> n; return n; }
char upperCase(char a){int d = (int)a - 97 + 65;char c = (char)d;return c;} 
char lowerCase(char a){int d = (int)a - 65 + 97;char c = (char)d;return c;}  
bool isInt(char a){int d = (int)a - 48;if(d>=0 && d<=9){return true;}return false;}
//string char_to_string(char a){string d = (1,a);return d;}
 
template <typename T1,typename T2>
void ArrPair(vector<pair<T1,T2>>vp){for(int i=0;i<(int)vp.size();++i){
cout << "(" << vp[i].first << "," << vp[i].second << ")"<<endl ;}}
 
const int MOD = 1e9 + 7;
const ll INF = 1e18L + 5;
 
unordered_map<int,int> um;
unordered_set<int> us;
set<int> s;
// v.front() gives the first element of vector 
// v.back()  gives the last element of vector
// insert erase substr

//bool bySecond(pair<int,int> a,pair<int,int> b){
//  return a.second < b.second;
//} 

bool f(vector<ll> a,vector<ll> b){
	return a[1] > b[1];
}

 
 
int main(){
	string s;
	cin >> s;
	if(s=="SUN"){
		cout << 7;
	}else if(s=="MON"){
		cout << 6;
	}
	else if(s=="TUE"){
		cout << 5;
	}
	else if(s=="WED"){
		cout << 4;
	}
	else if(s=="THU"){
		cout << 3;
	}
	else if(s=="FRI"){
		cout << 2;
	}
	else{
	   cout << 1;	
	}           
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair <int,int> pii;
typedef vector <pii> vpii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef long long int lli;
typedef vector <lli> vlli;
typedef vector <vlli> vvlli;
typedef vector <string> vs;
typedef vector <bool> vb;

#define rep(i, n) for( i = 0; i < (n); ++i)
#define repA(i, a, n) for( i = a; i <= (n); ++i)
#define repD(i, a, n) for( i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sortr(x) sort(x.begin(),x.end(),greater <int> ())
#define mod 1000000007
#define ff first
#define ss second
#define fill(a,c)  memset(a, c, sizeof (a))
#define formap(i,v) for(auto &i: v)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it<<endl;} cerr<<endl
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it.first<<" , "<<it.second<<endl;} cerr<<endl
#define PI  3.14159265358979323846
#define pb push_back


int main() {
	cin.sync_with_stdio(0);cin.tie(0);
    cin.exceptions(cin.failbit);
    
   int n,ans,i,k;
   cin>>n;
   n=n%1000;
   if (n==0)n=1000;
   cout<<1000-n;
    
    
    
   
   
   
   
   
   
	return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>

int main(void){
	int W, H, x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if (((0 <= (x - r)) && ((x + r) <= W)) &&
	 ((0 <= (y - r)) && ((y + r) <= H))) {
			printf("Yes\n");
	}
	else printf("No\n");

	return 0;
}

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

#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");

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

  vector<int> height(n);
  for (int i = 0; i < n; i++) cin >> height[i];

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int h = height[i];
    bool flg = true;
    for (auto v : Graph[i]) if (h <= height[v]) flg = false;
    if (flg) ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8752
#include<stdio.h>

int main(void){
  int N,odd=0,even=0,tmp;
  scanf("%d",&N);
  while(N--){
    scanf("%d",&tmp);
    if(tmp%2) odd++;
    else even++;
  }
  puts(odd%2?"NO":"YES");
  return 0;
}

      
  


Measured memory_bytes: 128
<>;for(glob<>){
	$x+=$_;
	$y+=$_;
	$X+=$-=1+(--$|?-$x:$x);
	$-&&($x=2*$|-1);
	$Y+=$-=1+($|?$y:-$y);
	$-&&($y=1-2*$|);
}
print$X<$Y?$X+0:$Y+0

Measured memory_bytes: 21632
n1, n2 = [int(i) for i in input().split()]

n3 = []
n4 = []

t1 = 0
t2 = 0
for i1 in range(n2):
    t1, t2 = ([int(i) for i in input().split()])
    n3.append(t1)
    n4.append(t2)

m1 = max(n3)
m2 = min(n4)

r1 = m2 - m1 + 1

if r1 < 0:
    r1 = 0

print(r1)

Measured memory_bytes: 10996
#include <iostream>
#include <cstdio>
using namespace std;
int k,s,cnt;

int main(){
	cin>>k>>s;
	
	for(int x = 0; x <= k; ++ x){
		for(int y = 0; y <= k; ++ y){
			int z = s - x - y;
			if(0 <= z && z <= k)
				++ cnt;
		}
	}
	cout<<cnt<<endl;	
}

Measured memory_bytes: 3564
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

int main()
{
	int a, b;
	cin >> a >> b;

	if (a <= 5) b = 0;
	else if (6 <= a && a <= 12) b /= 2;
	cout << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000; //10^9

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(M);
    for(int i = 0; i < M; i++){
        cin >> A.at(i);
    }
    int cost1 = 0;
    int cost2 = 0;
    for (int j = 0; j < M; j++)
    {
        if(X > A.at(j)){
            cost1++;
        }else{
            cost2++;
        }
    }
    cout << min(cost1, cost2) << endl;
}



Measured memory_bytes: 256
N, K = map(int, input().split())
list_h = list(map(int, input().split()))

list_h.sort()
list_h.insert(0, 0)
list_h.append(500)

L, R = 0, N + 1
while R - L > 1:
    C = (L + R) // 2
    if list_h[C] >= K:
        R = C
    else:
        L = C

print(len(list_h[R:-1]))


Measured memory_bytes: 11912