akhauriyash/Code-Regression huggingface dataset:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    n = I()
    a = [LI_() for _ in range(n)]
    r = 0
    c = collections.defaultdict(int)
    q = list(range(n))
    t = [0] * n
    while q:
        r += 1
        nq = []
        for i in q:
            j = a[i][t[i]]
            k = i
            if k < j:
                j,k = k,j
            c[(j,k)] += 1
            if c[(j,k)] == 2:
                t[j] += 1
                t[k] += 1
                if t[j] < n-1:
                    nq.append(j)
                if t[k] < n-1:
                    nq.append(k)
        q = nq

    for tt in t:
        if tt != n-1:
            return -1

    return r


print(main())



Measured memory_bytes: 96852
x, y = gets.chomp.split.map(&:to_i)
res = 0

cnt = (y.abs - x.abs).abs
res += cnt
if x.abs < y.abs
  if x < 0
    x *= -1
    res += 1
  end
  x += cnt
elsif x.abs > y.abs
  if x > 0
    x *= -1
    res += 1
  end
  x += cnt
end

if x * y < 0
  res += 1
end
puts res

Measured memory_bytes: 14316
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N; cin >> N;
	vector<int>A(N);
	int Min = 3000, Max = 0;
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		Min = min(Min, A.at(i));
		Max = max(Max, A.at(i));
	}
	if (Min == Max) cout << 0 << endl;
	else {
		int sum = 0, ans = 9999;
		for (int j = Min; j <= Max; j++) {
			sum = 0;
			for (int k = 0; k < N; k++) {
				sum = max(sum, abs(A.at(k) - j));
			}
			ans = min(ans, sum);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define MOD 1000000007

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

    int k,a,b;
    cin>>k>>a>>b;
    
    int r = a%k;
    if(((a + k) - r >= a &&(a + k) - r<=b)|| r == 0){
        cout<<"OK\n";
    }else{
        cout<<"NG\n";
    }
}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  long long sum = 0;
  long long r_num = 0;
  long long g_num = 0;
  long long b_num = 0;
  for (long long i = 0; i < N; i++) {
    if (S[i] == 'R') {
      r_num++;
    } else if (S[i] == 'G') {
      g_num++;
    } else {
      b_num++;
    }
  }
  sum = r_num * g_num * b_num;

  for (long long i = 0; i < N - 2; i++) {
    for (long long j = i + 1; j < N - 1; j++) {
      if (2 * j - i < N) {
        if (S.at(i) != S.at(j) && S.at(i) != S.at(2 * j - i) &&
            S.at(j) != S.at(2 * j - i)) {
          sum--;
        }
      }
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

typedef long long llint;
typedef pair<int, int> pii;

int n;
llint A, B, C, D;

int main(void) {
  scanf("%d", &n);
  scanf("%lld%lld%lld%lld", &A, &B, &C, &D);

  for (int i = 0; i <= n - 1; ++i) {
    llint l = A - (llint) i * D, r = A - (llint) i * C;
    l += (llint) (n - 1 - i) * C;
    r += (llint) (n - 1 - i) * D;
    if (l <= B && r >= B) {
      printf("YES\n");
      return 0;
    }
  }

  printf("NO\n");
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::vector<int> a(3);
	for(int i = 0; i < 3; i++) scanf("%d", &a[i]);
	sort(begin(a), end(a));
	printf("%d\n", a[0] + a[1]);
	return 0;
}


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

int main()
{
  ll n, sum = 0;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  for (ll i = 0; i < n; i++)
  {
    cin >> a[i];
    b[i] = a[i] - (i + 1);
  }
  sort(b.begin(), b.end());

  for (ll i = 1; i <= n; i++)
  {
    sum += abs(a[i - 1] - (b[n / 2] + i));
  }
  cout << sum << endl;
}

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

int main(){
  int n,i,j,C[10001];
  int *A,*B;
  scanf("%d",&n);
  A = malloc(sizeof(int)*n+1);
  B = malloc(sizeof(int)*n+1);

  for(i=0 ; i<=10000 ; i++){C[i]=0;}
  for(i=1 ; i<=n ; i++){
    scanf("%d",&A[i]);
    C[A[i]]++;
  }
  for(i=1;i<=10000;i++){C[i]+=C[i-1];}
  for (j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<n;i++){printf("%d ",B[i]);}
  printf("%d\n",B[n]);

  return 0;
}


Measured memory_bytes: 17356
const main = N => {
    var wei = 0
    var weiwei = N
    const end = Math.floor(Math.sqrt(N))+1
    for(var i =1;i<end;i++) {
        if(N % i === 0) {
                wei= i
                weiwei = N/i
        }
    }
    return wei+weiwei-2
}
const input = require('fs').readFileSync("/dev/stdin","utf8").split("\n")[0]
const N = parseInt(input,10)
console.log(main(N))



Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
int a, b;
int main() {
    DAU
    cin >> a >> b;
    if (a < 10)
        cout << b + 100 * (10 - a);
    else cout << b;
    PLEC
}


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

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main() {
  ll H, W, M;
  cin >> H >> W >> M;
  vector<ll> h(M), w(M);
  rep(i,M) cin >> h[i] >> w[i];
  rep(i, M) {
    h[i]--;
    w[i]--;
  }

  vector<ll> lon(H,0);
  vector<ll> lat(W,0);
  rep(i, M) {
    lon[h[i]]++;
    lat[w[i]]++;
  }
  ll maxlon = 0;
  rep(i, H) {
    maxlon = max(maxlon, lon[i]);
  }
  vector<ll> lons;
  rep(i, H) {
    if(lon[i] == maxlon) lons.push_back(i);
  }

  ll maxlat = 0;
  rep(i, W) {
    maxlat = max(maxlat, lat[i]);
  }
  vector<ll> lats;
  rep(i, W) {
    if(lat[i] == maxlat) lats.push_back(i);
  }

  ll bombcount = 0;
  rep(i, M) {
    auto lonitr = lower_bound(all(lons), h[i]);
    auto latitr = lower_bound(all(lats), w[i]);
    if(*lonitr == h[i] && *latitr == w[i]) {
       bombcount++;
      cerr << h[i] << " " << w[i] << endl;
    }
  }
  cerr << bombcount <<" "<< lons.size() * lats.size() << endl;
  ll ans = 0;
  if(bombcount == lons.size() * lats.size()) {
    ans = maxlat + maxlon - 1;
  }
  else {
    ans = maxlat + maxlon;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 21000
#pragma GCC optimize ("O3")
    #pragma GCC optimize ("unroll-loops")
    #pragma comment(linker, "/STACK:2000000")

    #include "bits/stdc++.h"

    using namespace std;

    #define pb push_back
    #define F first
    #define S second
    #define f(i,a,b)  for(int i = a; i < b; i++)
    // #define endl '\n'
    using ll = long long;
    using db = long double;
    using ii = pair<int, int>;

    const int N = 2e5+5, LG = 19, MOD = 998244353;
    const int SQ =320;
    const long double EPS = 1e-7;
    int  g[205][205];
    int32_t main(){
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(0);
        cin.tie(0);
    #endif

      f(i,1,205)
        f(j,1,205)
          g[i][j]=__gcd(i,j);

      int k ;
      cin >> k;
      int ans = 0;
      f(i,1,k+1)
        f(j,1,k+1)
          f(k1,1,k+1)
            ans+=g[i][g[j][k1]];

      cout<<ans<<'\n';

      return 0;
    }


Measured memory_bytes: 3804
#include<iostream>

using namespace std;

int main()
{
    int n[1000],x[1000],N[1000]={0};

    for(int i=0;;i++){
        cin>>n[i]>>x[i];
        if(n[i]==0 && x[i]==0)  break;
    }

    for(int i=0;;i++){
        if(n[i]==0 && x[i]==0)  break;

        for(int j= (x[i]-n[i]<3 ? x[i]-3:n[i]);j>x[i]/3;j--){
            int y=0;
            y = x[i] - j;
            for(int k=(y<j ? y-1:j-1);k>y/2;k--){
                if(k!=y-k && j!=k && j!=y-k )  N[i]++;
            }
        }
    }
    for(int i=0;;i++){
        if(n[i]==0 && x[i]==0)  break;
        cout<<N[i]<<'\n';
    }

}



Measured memory_bytes: 3104
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    lli N, K;
    cin >> N >> K;
    vector<lli> H;
    lli tmp;
    for (lli i = 0; i < N; i++)
    {
        cin >> tmp;
        H.push_back(tmp);
    }
    sort(H.begin(), H.end());
    lli sum = 0;
    if (N > K)
    {
        for (lli i = 0; i < N-K; i++)
        {
            sum += H[i];
        }
        cout << sum << endl;
    }
    else
    {
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define Pct puts("------ Yes ------");
#define rep(a, b, c) for(int a = (b); a <= (c); ++ a)
#define per(a, b, c) for(int a = (b); a >= (c); -- a)
#define fir first
#define sec second
#define ls son[u][0]
#define rs son[u][1]
#define eps 1e-8
#define PI acos(-1.0)
using namespace std;
template <class T> void rd(T &x){ x = 0; int f = 1; char ch = getchar(); while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar(); x *= f; }

typedef long long ll;
const int maxn = 305;
const int mod = 998244353;
int n, m;
int mat[maxn][maxn];

int qpow(int x, int n){ int y = 1; while(n){ if(n & 1) y = (ll) y * x % mod; x = (ll) x * x % mod; n >>= 1; } return y; }

int gauss(int n, int m){
	int r = 1, c = 1;
	for(; r <= n && c <= m; r ++, c ++){
		int p = -1;
		rep(i, r, n) if(mat[i][c]){ p = i; break; }
		if(p == -1){ r --; continue; }
		if(p != r) swap(mat[r], mat[p]);
		rep(i, r + 1, n) if(mat[i][c])
			per(j, m, c) mat[i][j] ^= mat[r][j];
	}
	return -- r;
}

int main(){
	rd(n), rd(m);
	rep(i, 1, n) rep(j, 1, m) rd(mat[i][j]);
	printf("%d\n", (qpow(2, n + m - 1) - qpow(2, n + m - 1 - gauss(n, m)) + mod) % mod);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,q;
  cin >> n >> k >> q;
  int a[q],b[n];
  for(int i=0;i<n;i++){
    b[i] = k-q;
  }
  for(int i=0;i<q;i++){
    cin >> a[i];
    a[i]--;
    b[a[i]]++;
  }
  for(int i=0;i<n;i++){
    if(b[i]>0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}

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

int main() {
    map<char, bool> r;
    string S;
    cin >> S;

    for (char ch : S) {
        r[ch] = true;
    }
    bool ok = true;
    if (r['N'] ^ r['S']) ok = false;
    if (r['W'] ^ r['E']) ok = false;

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>  
 
using namespace std;  
   
char farm[100][100];  
int W, H;  
const int direction[4][2] = {  
  { -1, 0 },  
  { 1, 0 },  
  { 0, -1 },  
  { 0, 1 },  
};  
   
void dfs(int x, int y, char tree)  
{  
  farm[x][y] = 'x';  
  for (int i = 0; i < 4; ++i)  
  {  
    int nx = x + direction[i][0];  
    int ny = y + direction[i][1];  
    if (nx >= 0 && nx < W && ny >= 0 && ny < H && farm[nx][ny] == tree)  
    {  
      dfs(nx, ny, tree);  
    }  
  }  
}  
   
int main()  
{  
   
  while (cin >> H >> W, W > 0)  
  {  
    int res = 0;  
    int x, y;  
    for (y = 0; y < H; ++y)  
    {  
      for (x = 0; x < W; ++x)  
      {  
        cin >> farm[x][y];  
      }  
    }  
   
    for (y = 0; y < H; ++y)  
    {  
      for (x = 0; x < W; ++x)  
      {  
        if (farm[x][y] != 'x')  
        {  
          dfs(x, y, farm[x][y]);  
          ++res;  
        }  
      }  
    }  
    cout << res << endl;  
  }  
  return 0;  
} 

Measured memory_bytes: 3552
#include <iostream>
#include <cmath>
#include <climits>
using namespace std;

int main(){
    int n;
    int a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    a--;b--;c--;d--;
    int ans=1<<30;
    for(int w=1; w<=n; w++){
        int dx=abs(a%w-b%w) + abs(c%w-d%w);
        int dy=abs(a/w-b/w) + abs(c/w-d/w);
        ans=min(ans,dx+dy);
    }
    cout<<ans<<endl;
}

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

using namespace std;

const long long MaxN = 2e5 + 17;
int arr[MaxN];
int amount[MaxN][2];
vector<int> lst[MaxN];
bool used[MaxN];

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

    string s;
    int n, m;
    cin >> n >> m >> s;

    for(int i = 0; i < n; ++i)
        arr[i] = (s[i] - 'A');

    for(int i = 0; i < m; ++i)
    {
        int x, y;
        cin >> x >> y;

        ++amount[x - 1][arr[y - 1]];
        ++amount[y - 1][arr[x - 1]];

        lst[x - 1].push_back(y - 1);
        lst[y - 1].push_back(x - 1);
    }

    stack<int> ver;

    for(int i = 0; i < n; ++i)
        if(!amount[i][0] || !amount[i][1])
        {
            ver.push(i);
            used[i] = true;
        }

    while(!ver.empty())
    {
        int t = ver.top();
        ver.pop();

        for(int i = 0; i < lst[t].size(); ++i)
        {
            int go = lst[t][i];

            if(!used[go])
            {
                --amount[go][arr[t]];

                if(!amount[go][0] || !amount[go][1])
                {
                    ver.push(go);
                    used[go] = true;
                }
            }
        }
    }

    for(int i = 0; i < n; ++i)
        if(!used[i])
            return cout << "Yes\n", 0;

    cout << "No\n";








}



Measured memory_bytes: 13392
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

vector<int> path[220000];
bool used[110000];
int s[220000];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>m;
	memset(s,-1,sizeof(s));
	for(i=0;i<m;i++){
		cin>>a>>b;
		a--,b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	queue<int> q1;
	q1.push(0);
	while(!q1.empty()){
		a=q1.front(),q1.pop();
		if(used[a])continue;
		used[a]=true;
		for(auto to:path[a]){
			if(s[to]!=-1)continue;
			s[to]=a;
			q1.push(to);
		}
	}
	cout<<"Yes"<<endl;
	for(i=1;i<n;i++){
		cout<<s[i]+1<<endl;
	}
}

Measured memory_bytes: 13768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define OUT(x) cout << (x) << endl;
#define ALL(v) v.begin(), v.end()
#define REP(i, n) for (int i=0; i<(int)(n); ++i)
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};

const int MAX_X=50, 
          MAX_Y=50;
const ll INF = 10e9;

int main() {
    int N; cin >> N;
    string S, T; cin >>S>>T;

    string ans = "";
    for(int i=0;i<N;i++){
        ans = ans +S[i]+T[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    char C;
    intmax_t ans = 0;

    scanf("%c", &C);

    putchar(C + 1);
    putchar('\n');

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define BIT(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector< int > p(N);
  REP(i, N) { cin >> p[i]; }
  int count = 0;
  REPS(i, N - 2) {
    int val = p[i - 1] + p[i] + p[i + 1];
    int maxV = max({p[i - 1], p[i], p[i + 1]});
    int minV = min({p[i - 1], p[i], p[i + 1]});
    if (val - maxV - minV == p[i]) {
      count++;
    }
  }
  cout << count << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  cout << ((s[0]==s[1] && s[2]==s[3] && s[0]!=s[2])||(s[0]==s[2] && s[1]==s[3] && s[0]!=s[1])||(s[0]==s[3] && s[1]==s[2] && s[0]!=s[1])?"Yes":"No")<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
#define MAX 100000
using namespace std;
typedef long long ll;
int store[100000+2],u;
void partition(int n)
{
	int x,i,j,mid;
	x=store[n-1];
	i=0;
	for(j=0;j<n-1;j++)
	{
		if(store[j]<=x){
			mid=store[j];
			store[j]=store[i];
			store[i]=mid;
			i++;
		}
	}
	mid=store[i];
	store[i]=store[n-1];
	store[n-1]=mid;
	u=i;
}
int main(int argc, char *argv[]) {
	int n;
	cin>>n;
	for(int i=0;i<n;i++) cin>>store[i];
	partition(n);
	for(int i=0;i<n;i++)
	{
		if(i==u)
			cout<<"["<<store[i]<<"]"<<" ";
		else if(i==n-1)
			cout<<store[i]<<endl;
		else
			cout<<store[i]<<" ";
	}
	return 0;
}


Measured memory_bytes: 3340
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
   long long N;
   cin >> N;
   long long A,B,C,D;
   cin >> A >> B >> C >> D;
   if(A>B) swap(A,B);
   long long F = B-A;
   N--;
   bool ok = false;
   long long cnt = 0;
   for(int n = N; n >= 0; n-=2){
      long long highest = n*D; 
      long long lowest = n*C;
      highest += cnt*(D-C);
      lowest -= cnt*(D-C);
      //cout << highest <<" - " << lowest << endl;
      if(lowest <=F && F <= highest){
         ok = true;
         break;
      }
      cnt++;
   }
   if(ok){
      cout << "YES" << endl;
   }
   else{
      cout << "NO" << endl;
   }


   return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    int x, n;
    cin >> x >> n;
    set<int> s;
    for (int i = 0; i < n; ++i) {
        int c;
        cin >> c;
        s.insert(c);
    }
    for (int i = 0; i <= 50; ++i) {
        if (s.count(x - i) == 0) return cout << x - i, 0;
        if (s.count(x + i) == 0) return cout << x + i, 0;
    }
}


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

int main(){
    int n;
    cin>>n;
    int ans=0,count=0;
    for(int i=1;i<=n;i++){
        count=0;
        if(i%2!=0){
            for(int j=1;j<=i;j++){
                if(i%j==0)count++;
            }
            if(count==8)ans++;
        }
    }
    cout<<ans;
}


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

//#define int long long
const int MOD = 1e9 + 7;
using ll = long long;
using intpair = pair<int, int>;
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    
    vector<int> visit(n,-1);
    int now = 0;
    bool is_looped = false;
    rep(t,1e9){
        if(visit[now] == -1 || is_looped){
            visit[now] = t;
            now = a[now];
            k--;
        }else{
            k %= t - visit[now];
            is_looped = true;
        }
        if(!k) break;
    }
    
    cout << now+1 << endl;
}

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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    for(int i = A; i <= min(B, A + K - 1); i++) cout << i << endl;
    for(int i = max(B - K + 1, A + K); i <= B; i++) cout << i << endl;
}

Measured memory_bytes: 256
s=list(input())
i=1
w=[s[0]]
while i<len(s)-1:
    if s[i]==w[-1]:
        w.append(s[i]+s[i+1])
        i+=2
    else:
        w.append(s[i])
        i+=1
        
if s[-1]!=w[-1] and i<len(s):
    w.append(s[-1])
print(len(w))


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

#define ar array
#define ll long long int

const ll mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
       ll n, x, t;
       cin >> n >> x >> t;
       ll q = ceil((double) n / x) * t;
       cout << q;
    }

    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
 
using namespace std;
typedef long long int lli;
const int MAX=1e5;
 
int main(){
	lli A,B,C,D,N;
	cin>>A>>B>>C>>D>>N;
  	N=4*N;
	if(2*A<B)B=2*A;
	if(2*B<C)C=2*B;
	if(2*C<D)D=2*C;
	lli a,b,c,d;
	d=N/8;
	c=(N%8)/4;
	b=(N%4)/2;
	a=N%2;
	lli ans=a*A+b*B+c*C+d*D;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n=int(input())
a=[int(input()) for i in range(n)]
if a[0]!=0:
    print(-1)
    exit()

ans=0
for i in range(n)[::-1]:
    if a[i]-a[i-1]>1:
        print(-1)
        exit()
    elif a[i]<=a[i-1]:
        ans+=a[i]
    else:
        ans+=1
print(ans)




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

int main(void){
    int N, j=0;
    cin >> N;
    
    for(int i=0; i<N; i++){
        char S;
        cin >> S;
        if (S=='Y') j++;
    }
    
    if (j==0) cout << "Three" << endl;
    else cout << "Four" << endl;
}


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

int main(void)
{
	double x1,x2,y1,y2;
	double dis;

	scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
	dis=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
	printf("%f\n",sqrt(dis));

	return 0;
}


Measured memory_bytes: 652
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;

int N, M, Q;

vector<vector<int>> sum;
int buildSumTable(vector<int> L, vector<int> R) {
	sum = vector<vector<int>>(N + 1, vector<int>(N + 1, 0));
	for (int i = 0; i < M; i++)
	{
		sum[L[i]][R[i]]++;
	}

	for (int i = 1; i <= N; i++)
	{
		for (int j = 1; j <= N; j++)
		{
			sum[i][j] += sum[i - 1][j];
			sum[i][j] += sum[i][j - 1];
			sum[i][j] -= sum[i - 1][j - 1];
		}
	}
}

int getSumRange(int L, int R) {
	int ans = sum[R][R] - sum[R][L - 1] - sum[L - 1][R] + sum[L - 1][L - 1];
	return ans;
}

int main() {
	cin >> N >> M >> Q;
	vector<int> L(M);
	vector<int> R(M);
	for (int i = 0; i < M; i++)
	{
		scanf("%d %d", L.begin() + i, R.begin() + i);
		//cin >> L[i] >> R[i];
	}
	vector<int> p(Q);
	vector<int> q(Q);
	for (int i = 0; i < Q; i++)
	{
		scanf("%d %d", &p[i], &q[i]);
		//cin >> p[i] >> q[i];
	}
	buildSumTable(L, R);

	for (int i = 0; i < Q; i++)
	{
		int ans = getSumRange(p[i], q[i]);
		//cout << ans << endl;
		printf("%d\n", ans);
	}
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N;
    cin >> N;
    vector<vector<pair<int, int>>> edges(N + 1);
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        edges[a].push_back(make_pair(i, b));
        edges[b].push_back(make_pair(i, a));
    }
    vector<int> color(N - 1, 0);
    int M = 0;
    for(auto i : edges) {
        M = max<int>(M, i.size());
    }
    cout << M << endl;
    queue<pair<int, int>> q;
    for(int i = 0;i < edges[1].size();i++) {
        color[edges[1][i].first] = i + 1;
        q.push(make_pair(i + 1, edges[1][i].second));
    }
    for(;!q.empty();) {
        auto f = q.front();
        q.pop();
        int x = 0;
        for(int i = 0;i < edges[f.second].size();i++) {
            if(color[edges[f.second][i].first] == 0) {
                int c = x + 1 == f.first ? edges[f.second].size() : x + 1;
                color[edges[f.second][i].first] = c;
                q.push(make_pair(c, edges[f.second][i].second));
                x++;
            }
        }
    }
    for(auto i : color) {
        cout << i << endl;
    }
    return 0;
}



Measured memory_bytes: 7040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int num = sc.nextInt();

		int numArrasy[] = new int[num];

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

			numArrasy[i] = sc.nextInt();

		}

		int count = 1;
		int tmp = numArrasy[0];

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

			if (tmp > numArrasy[i]) {
				count++;
			}

			tmp = Math.min(tmp, numArrasy[i]);

		}

		System.out.println(count);

	}

}


Measured memory_bytes: 81156
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[100100];

int main() {
  clr(d,0);
  ll n,m;
  cin>>n>>m;
  rep(i,0,m){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    d[a]++;
    d[b]++;
  }
  int flag = 1;
  rep(i,0,n){
    if(d[i]%2==1)flag = 0;
  }
  if(flag == 1)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 1024
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	p, q, r := nextInt(), nextInt(), nextInt()

	maxf := func(l, m, r int) int {
		v := l
		if v < m {
			v = m
		}
		if v < r {
			v = r
		}
		return v
	}

	max := maxf(p, q, r)
	sum := p + q + r - max
	fmt.Println(sum)

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	long long d=a/(b+c);
	d*=b;
	long long e=a%(b+c);
	if(e>b)d+=b;
	else d+=e;
	cout<<d;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int n;
    cin >> n;
    int field[1010][1010] = {{0}};
    rep(i, n){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        REP(j, y1, y2){
            field[j][x1]++;
            field[j][x2]--;
        }
    }
    rep(j, 1002){
        rep(i, 1002){
            field[j][i+1] += field[j][i];
        }
    }
    int ans = 0;
    rep(j, 1002){
        rep(i, 1002){
            ans = max(ans, field[j][i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7072
a, b = map(int, input().split())

n = 0
    
if a * 12.5 < (b+1) * 10 and b * 10 < (a+1) * 12.5:
    while n < a * 12.5 or n < b * 10:
        n += 1
    else:
        print(n)
else:
    print('-1')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
using namespace std;
typedef vector<int> vi;

int main(){
    long long N, ans = 0;
    cin >> N;
    vector<long long> A(N);
    rep(i, N) cin >> A[i];

    bool flg = true;
    while(flg){
        rep(i, N){
            if(A[i] % 2 == 0){
                A[i] /= 2;
            }else{
                flg = false;
                break;
            }
        }
        ans++;
    }
    
    cout << ans - 1 << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cmath> 
#include <vector> 

using ll = long long;
using namespace std;
 
int main() {
  int N;cin>>N;
  vector<int> w(N);
  int s;s=0;
  int ans;ans=0;
  for(int i=0;i<N;i++){
      cin>>w[i];
      s=s+w[i];
  }
  int s_a;s_a=0;
  int j;j=0;
  while (s_a<double(s/2))
  {
    s_a=s_a+w[j];
    j++;
  }
  ans=s_a*2-s;
  if(s-2*(s_a-w[j-1])<ans){
      ans=s-2*(s_a-w[j-1]);
  }

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

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

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            var culture = System.Globalization.CultureInfo.GetCultureInfo("en-US");

            int n = 0;
            if(str == "SUN")
            {
                n = 7;
            }
            if (str == "MON")
            {
                n = 6;
            }
            if (str == "TUE")
            {
                n = 5;
            }
            if (str == "WED")
            {
                n = 4;
            }
            if (str == "THU")
            {
                n = 3;
            }
            if (str == "FRI")
            {
                n = 2;
            }
            if (str == "SAT")
            {
                n = 1;
            }

            Console.Write(n);

        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;

int main(int argc, char* argv[]){
  long long n;
  // long double a0, a1;
  long long L[87];
  cin >> n;
  // if(n==0){
  //   cout << 2 << endl;
  // }else if(n==1){
  //   cout << 1 << endl;
  // }else{
  //   a0 = ( pow((0.5 + sqrt(5)/2.0), n-1) - pow((0.5 - sqrt(5)/2.0), n-1) ) / sqrt(5) * 2;
  //   a1 = ( pow((0.5 + sqrt(5)/2.0), n) - pow((0.5 - sqrt(5)/2.0), n) ) / sqrt(5) * 1;
  //   cout << long(a0 + a1) << endl;    
  // }
  L[0] = 2;
  L[1] = 1;
  for(int i=2; i<=n; i++){
    L[i] = L[i-1] + L[i-2];
  }
  cout << L[n] << endl; 

  return 0;
}


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


using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}

////////////////////////////////////////

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;cin>>n;
    ll x[n];rep(i,0,n-1)cin>>x[i];
    ll l,q;cin>>l>>q;
    ll dp[n][35];rep(i,0,34)dp[n-1][i]=n-1;
    for(ll i=n-2;i>=0;i--){
        dp[i][0]=upper_bound(x,x+n,x[i]+l)-x-1;
        if(dp[i][0]==n)dp[i][0]=n-1;
        rep(j,1,34){
            dp[i][j]=dp[dp[i][j-1]][j-1];
        }
    }
   /* rep(i,0,n-1){cout<<i<<":";
        rep(j,0,5){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
    while(q--){
        ll a,b;cin>>a>>b;if(a>b)swap(a,b);a--;b--;
        ll ans=0;
        if(b==n-1){
            while(a<b){
                ll t=lower_bound(dp[a],dp[a]+35,b)-dp[a]-1;
                if(t==-1)t++;
                ans+=(ll)pow(2,t);
                a=dp[a][t];
            }
        }else{
            while(a<b){
                ll t=upper_bound(dp[a],dp[a]+35,b)-dp[a]-1;
                if(t==-1)t++;
                ans+=(ll)pow(2,t);
                a=dp[a][t];
            }
        }
        cout<<ans<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 28928
// 最後の手数の決め方がわからない
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

const int MAX_N = 100100;
int du[MAX_N], dv[MAX_N];
vector<int> tree[MAX_N];
bool visited[MAX_N];
int N, u, v;

void dfs_u() {
    for(int i = 0; i < N; ++i) visited[i] = false;
    for(int i = 0; i < N; ++i) du[i] = 1e9;
    stack<int> task;
    visited[u] = true;
    du[u] = 0;
    task.push(u);
    while(!task.empty()){
        int cur = task.top(); task.pop();
        for(int i = 0; i < tree[cur].size(); ++i) {
            int leaf = tree[cur][i];
            if(visited[leaf]) continue;
            visited[leaf] = true;
            du[leaf] = min(du[leaf], du[cur] + 1);
            task.push(leaf);
        }
    }
}

void dfs_v(){
    for(int i = 0; i < N; ++i) visited[i] = false;
    for(int i = 0; i < N; ++i) dv[i] = 1e9;
    stack<int> task;
    visited[v] = true;
    dv[v] = 0;
    task.push(v);
    while(!task.empty()){
        int cur = task.top(); task.pop();
        for(int i = 0; i < tree[cur].size(); ++i) {
            int leaf = tree[cur][i];
            if(visited[leaf]) continue;
            visited[leaf] = true;
            dv[leaf] = min(dv[leaf], dv[cur] + 1);
            task.push(leaf);
        }
    }
}

int main()
{
    scanf("%d %d %d", &N, &u, &v);
    --u, --v;
    for(int i = 0; i < N-1; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        --a, --b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    dfs_u(); dfs_v();
    /*
    printf("du: ");
    for(int i = 0; i < N; ++i) printf("%d ", du[i]);
    printf("\n");
    printf("dv: ");
    for(int i = 0; i < N; ++i) printf("%d ", dv[i]);
    printf("\n");
    */
    int goal = u;
    for(int i = 0; i < N; ++i) if(du[i] < dv[i] && dv[goal] < dv[i]) goal = i;
    printf("%d\n", dv[goal]-1); //なんでこうなるのかわからない
    return 0;
}

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

int main(){
  int map[5000000]={};
  for(int i=2; i<=5000000; ++i){
    for(int j=2; i*j<=5000000; ++j){
      map[i*j] = 1;
      //cout << i*j << endl;
    }
  }
  vector<int> iv;
  for(int i=2; i<500000; ++i){
    if(map[i]==0){iv.push_back(i);}
  }
  /* for(auto i: iv){
    cout << i << endl;
    } */
  int n;
  while(cin >> n,n){
    int ans = 0;
    for(int i=0; i<n; ++i){
      ans += iv[i];
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 22660
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll X;
  cin >> X;

  set<ll> x;
  constexpr ll CEIL = 1000;
  for (ll b = 1; b <= 100; b++) {
    for (ll p = 2; p < 10; p++) {
      const ll e = static_cast<ll>(pow(static_cast<ld>(b), static_cast<ld>(p)));
      if (e <= CEIL) {
        x.emplace(e);
      }
    }
  }
  auto it = lower_bound(ALL(x), X);
  if ((*it) != X)
    --it;
  cout << (*it) << endl;
  return 0;
}


Measured memory_bytes: 3708
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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 <climits>
#include <queue>

using namespace std;

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

//container util
//------------------------------------------
#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())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int N, W, H; cin >> N >> W >> H;

  VI xs(W+1, 0), ys(H+1, 0);
  REP(i,N){
	int x, y, w; cin >> x >> y >> w;
	xs[max(0,x-w)]++, xs[min(W, x+w)]--;
	ys[max(0,y-w)]++, ys[min(H, y+w)]--;	
  }

  bool ans = false;
  int imos = 0;
  int x, y;
  for(x=0;x<W;++x){
	imos += xs[x];
	if(imos == 0) break;
  }
  if(x == W) ans = true;

  imos = 0;
  for(y=0;y<H;++y){
	imos += ys[y];
	if(imos == 0) break;
  }
  if(y == H) ans = true;

  cout <<(ans? "Yes": "No") << endl;
  
  return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(long long n, long long m,string s){
    reverse(ALL(s));
    int now=0;
    Vi ans;
    while(1){
        if(n-now<=m){
            ans.pb(n-now);
            break;
        }

        bool flag=false;
        REPR(i,m,0){
            if(s[now+i]=='0'){
                ans.pb(i);
                now+=i;
                flag=true;
                break;
            }
        }
        if(!flag){cout<<-1<<endl;return;}
    }
    reverse(ALL(ans));
    REP(i,0,ans.size()){
        if(i==ans.size()-1) cout<<ans[i]<<endl;
        else cout<<ans[i]<<" ";
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    string S;
    cin>>S;
    solve(N, M, S);
    return 0;
}


Measured memory_bytes: 1656
import statistics

if __name__ == "__main__":
    N = int(input())
    X = list(map(int, input().split()))
    X_cp = X.copy()
    P = round(statistics.mean(X_cp))
    ret = 0
    for i in X:
        ret += (i - P)**2
        # print((i - P)**2)
    print(ret)


Measured memory_bytes: 6044
n=int(input())
dict = {}
mx=1
for i in range(n):
  s=input()
  if s in dict:
    dict[s]+=1
    mx=max(dict[s],mx)
  else:
    dict[s]=1
v=[]
for s,i in dict.items():
  if i==mx:
    v.append(s)
print(*sorted(v))

Measured memory_bytes: 34012
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N=ri()
X=[0]*N
Y=[0]*N
H=[0]*N
for i in range(N):
    X[i],Y[i],H[i]=rl()
xyh=list(zip(X,Y,H))
xyh.sort(reverse=True,key=lambda x:x[2])
X,Y,H = zip(*xyh)

ans=[-1]*3
for x in range(101):
    if ans[0] != -1:
        break
    for y in range(101):
        if ans[0] != -1:
            break
        rst = H[0]+abs(x-X[0])+abs(y-Y[0])
        for i in range(1,N):
            if H[i] != 0 and rst != H[i]+abs(x-X[i])+abs(y-Y[i]):
                break
            elif H[i] == 0 and rst > H[i]+abs(x-X[i])+abs(y-Y[i]):
                break
            if i == N-1:
                ans = [x,y,rst]

print("{} {} {}".format(ans[0],ans[1],ans[2]))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin>>x;
    for(long long int i=0;i<=177;i++)
    {
        long long int sum=pow(i,5);
        for(int j=i;j<=176;j++)
        {
            long long int s=pow(j,5);
            if(s-sum==x)
            {
                cout<<j<<" "<<i;
                return 0;
            }
        }
    }
   for(long long int i=0;i<=64;i++)
    {
        long long int sum=pow(i,5);
        for(int j=i;j<=64;j++)
        {
            long long int s=pow(j,5);
            if(s+sum==x)
            {
                cout<<j<<" "<<-i;
                break;
            }
        }
    }
    
}
        

Measured memory_bytes: 4028
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,sum=0,max=0;
	char s[105];
	scanf("%d",&n);
	scanf("%s",s);
	for(int i=0;i<n;i++){
		if(s[i] == 'I'){
			sum++;
		}
		else{
			sum--;
		}
		if(sum > max){
			max = sum;
		}
	}
	printf("%d",max);
}

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

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

llint a,b;

void solve(){
  cin >> a >> b;
  int c=1;
  int ans=0;
  while(c<b){
    c+=a-1;
    ans++;
  }
  cout << ans << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

//// UnionFind
struct UnionFind{
	vector<int> v;
	UnionFind(int n) : v(n, -1) {}

	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

int n,m;
PPI ps[22222];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n>>m;
		if(n==0)break;
		rep(i,m){
			cin>>ps[i].fi>>ps[i].se.fi>>ps[i].se.se;
			ps[i].se.fi--; ps[i].se.se--;
		}
		sort(ps,ps+m);
		UnionFind uf(n);
		rep(i,m){
			int s=ps[i].se.fi,d=ps[i].se.se;
			if(uf.same(0,s))uf.unite(s,d);
		}
		cout<<uf.size(0)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3504
# 4-adjacent
N = int(input())
a = list(map(int, input().split()))

b = [a[i]%4 for i in range(N)]

if ( b.count(2)%2 + b.count(1) + b.count(3) > 1 + b.count(0) ):
    print("No")
else:
    print("Yes")

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

int main()
{
  int ans=0;
  string s;
  cin>>s;
  if(s.at(0)=='R')
  {
    ans++;
    if(s.at(1)=='R')
    {
      ans++;
      if(s.at(2)=='R')
      {
        ans++;
      }
    }
  }
  else if(s.at(1)=='R')
  {
    ans++;
    if(s.at(2)=='R')
    {
      ans++;
    }
  }
  else if(s.at(2)=='R')
    ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class question {
public:
	ll N, P;
	int pow(int a, int b) {
		if (b == 0) return 1;
		if (b % 2) return a*pow(a, b - 1);
		int tmp = pow(a, b / 2);
		return tmp*tmp;
	}
	
	void ans() {
		cin >> N >> P;
		if (N == 1) {
			cout << P << "\n";
			return;
		}
		ll Q = P;
		int res = 1;
		for (ll i = 2;i*i <= P;i++) {
			ll tmp = 0;
			while (Q%i == 0) {
				if (++tmp == N) {
					res *= i;
					tmp = 0;
				}
				Q /= i;
			}
		}
		
		cout << res << "\n";
	}
};

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

	question q;
	q.ans();

	return 0;
}

Measured memory_bytes: 256