akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;

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

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}


int main() {
  double x1,y1,x2,y2,x3,y3,x4,y4;
  while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4) {
    P a(x1,y1), b(x2,y2), c(x3,y3), d(x4,y4);
    if(abs(dot(b-a,d-c))<EPS)
      cout <<"YES";
    else
      cout << "NO";
    cout << endl;
  }
}

Measured memory_bytes: 0
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
	        
			int n = sc.nextInt();
			int iti = n%10;
			
			if(iti==2 || iti==4 || iti==5 || iti==7 || iti==9) {
				System.out.println("hon");
			}else if(iti==0 || iti==1 || iti==6 || iti==8) {
				System.out.println("pon");
			}else {
				System.out.println("bon");
			}
			
		}
		
	}


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

int main()
{
    int K;
    scanf("%d",&K);
    
    if( K % 2 == 0 ){
        printf("%d\n",K/2 * K/2);
    }else{
        printf("%d\n",K/2 * ( K/2 + 1 ));
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);
    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int n, m; cin >> n >> m;
    cout << n*(n-1) / 2 + m*(m-1) / 2 << endl;

    return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// Vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
	for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
		s << v[i];
  }
  s << "]";
  return s;
}

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

  string s;
  cin >> s;
  vector<char> cs;
  vector<int64> xs;
  char current = s[0];
  int count = 1;
  for (int i = 1; i < s.length(); i++) {
    if (s[i] == current) {
      count++;
    } else {
      cs.push_back(current);
      xs.push_back(count);
      current = s[i];
      count = 1;
    }
  }
  cs.push_back(current);
  xs.push_back(count);

  // cout << cs << endl;
  // cout << xs << endl;

  int64 sum = 0;
  for (int i = 0; i < cs.size(); i++) {
    if (i + 1 < cs.size() && cs[i] == '<' && cs[i + 1] == '>') {
      int64 x1 = xs[i];
      int64 x2 = xs[i + 1];
      if (x1 >= x2) x2--;
      else x1--;
      sum += x1 * (x1 + 1) / 2;
      sum += x2 * (x2 + 1) / 2;
      i++;
      // cout << "sum (path 1): " << sum << endl;
    } else {
      sum += xs[i] * (xs[i] + 1) / 2;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3352
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;

int main(void)
{
    int n,m;

    cin >>n >>m;

    vector<bool> a(n+1, false);
    for(int i = 0; i < m; i++){
        int tmp;
        cin >>tmp;
        a[tmp] = true;
    }

    vector<int> dp(n+1, 0);
    dp[0] = 1;
    for(int i = 1; i <= n; i++){
        if(a[i]){
            continue;
        }
        if(i-1 >= 0){
            dp[i] += dp[i-1];
            dp[i] = dp[i] % 1000000007;
        }
        if(i-2 >= 0){
            dp[i] += dp[i-2];
            dp[i] = dp[i] % 1000000007;
        }
    }

    printf("%d\n", dp[n]);
    return 0;
}

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

//GOTU
//#GOTU

int main()
{
   ll n,m;
   cin>>n>>m;
   ll broken[n+1]{};
   ll temp;
   for(ll i=0;i<m;i++)
   {
      cin>>temp;
      broken[temp]++;
   }
   ll ways[n+1]{};
   ways[0] = 1;

   if(broken[1] == 0)
      ways[1] = 1;

   for(ll i=2;i<=n;i++)
   {
      if(broken[i] == 0)
      {
         ways[i] = ways[i-1] + ways[i-2];
         ways[i]%=mod;
      }
   }
   cout<<ways[n];
   return 0;
}


Measured memory_bytes: 5188
n,*a=$<.read.split.map &:to_i
c=0
t=1
r=[0]*n
n.times do |i|
  r[c]+=1
  if t>a[i]
    c+=1
    t-=2
  end
  t+=2
end
c=1
t=0
n.times do |i|
  t+=r[i]
  c*=t-i
  c%=10**9+7
end
p c

Measured memory_bytes: 10108
S=str(input())
T=str(input())
SL=len(S)
TL=len(T)
a=[]
 
for i in range(SL-TL+1):
 
    count=0
 
    for j in range(TL):
 
        if S[i+j]=='?' or T[j]=='?' or S[i+j]==T[j]:
            count += 1
 
    if count==TL:
        ans = S[:i].replace('?','a')+T+S[i+TL:].replace('?','a')
        a.append(ans)
 
if len(a)==0:
    print('UNRESTORABLE')
else:
    a.sort()
    print(a[0])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
#define sort(x) sort(x.begin(), x.end())
#define N 1000000007
using namespace std;
void dfs(ll i, ll p, ll d[],ll dist, vector <ll> adj[])
{
    d[i] = dist;
    for(auto j : adj[i])
        if(j != p)
            dfs(j, i, d, dist+1, adj);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,u,v,i,a,b,ans = 0;
    cin>>n>>u>>v;
    vector <ll> adj[n+1];
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    ll d1[n+1], d2[n+1];
    dfs(u,0,d1,0,adj);
    dfs(v,0,d2,0,adj);
    for(i=1;i<=n;i++)
        if(d1[i] < d2[i])
            ans = max(ans, d2[i] - 1);
    cout<<ans;
    return 0;
}


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

ok = "No"
for cake in range(0, 26):
    for daunut in range(0, 15):
        if 4 * cake + 7 * daunut == n:
            # print(f"4 * {cake} + 7 * {daunut} == {n}")
            ok = "Yes"
            break
print(ok)

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	int r;
	cin >> r;
	cout << r * r << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> H >> W;
  if(H%W==0)sum--;
  Out(H/W+sum+1);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var ABCK = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (A, B, C, K) = (ABCK[0], ABCK[1], ABCK[2], ABCK[3]);

        var ans = 0;

        if(A <= K)
        {
            K -= A;
            ans += A;

            if(B <= K)
            {
                K -= B;
                ans += 0;

                if(C <= K)
                {
                    K -= C;
                    ans -= C;
                }
                else
                {
                    ans -= K;
                }
            }
            else
            {
                ans += 0;
            }
        }
        else
        {
            ans += K;
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 28288
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
 
        int x;
        Scanner scanner = new Scanner(System.in);
 
        x = scanner.nextInt();
 
        if(x < 1200){
            System.out.println("ABC");
        }else{
            System.out.println("ARC");
        }
        return;
 
 
    }
}

Measured memory_bytes: 21332
n=int(input())
a,f,b=sorted([list(map(int,input().split())) for i in range(n)],key=lambda x:x[1]),1,0
for i in range(n):
    b+=a[i][0]
    if b>a[i][1]:
        f=0
print('Yes' if f==1 else 'No')

Measured memory_bytes: 55264
A, B, C, X, Y = map(int, input().split(" "))

min_price = 10000000000000000000000000001

for i in range(max(X, Y) + 1) :
    cnt_a = max(0, X - i)
    cnt_b = max(0, Y - i)
        
    min_price = min(min_price, cnt_a * A + cnt_b * B + i * 2 * C)
    # int("DBG : ", cnt_a, cnt_b, i)
print(min_price)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
const int N=2e5+10;
const int M=1LL<<30;
const int inf=1e9+7;
const LL INF=1e18;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int s=0;while(x){s+=BIT[x];x-=x&-x;}return s;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)

int n,m;
string a;
vector<int>g[N];
int num[N][2];
int del[N];
int main(){Accel
	cin>>n>>m>>a;
	int u,v;
	a='0'+a;
	REP(i,m){
		cin>>u>>v;
		g[u].PB(v);
		g[v].PB(u);
		num[u][a[v]=='B']++;
		num[v][a[u]=='B']++;
	}
	queue<int>q;
	FOR(i,1,n)
		if(!num[i][0]||!num[i][1])q.push(i),del[i]=1;
	while(SZ(q)){
		int u=q.front();q.pop();
		for(auto v:g[u])
			if(!del[v]&&!--num[v][a[u]=='B']){
				q.push(v);
				del[v]=1;
			}
	}
	FOR(i,1,n)
		if(!del[i]){
			cout<<"Yes\n";
			return 0;
		}
	cout<<"No\n";
			
}


Measured memory_bytes: 13204
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<double, int> P;

struct edge{
    int to; double cost;
    edge(int to, double cost):to(to), cost(cost){}
};
const int INF = 4 * 1e18;
int n;
double d[1010];
vector<edge> G[1010];

void dijkstra(int s){
    fill(d, d + n, INF);//V, INF
    d[s] = 0.0;
    priority_queue<P, vector<P>, greater<P> > q;
    q.push(P(d[s], s));
    while(!q.empty()){
        P p = q.top(); q.pop();
        int from = p.second;
        double cost = p.first;
        if(d[from] < cost) continue;
        rep(i, 0, G[from].size()){
            edge e = G[from][i];
            int next = e.to;
            double newCost = e.cost + cost;
            if(d[next] - newCost > 1e-10){
                d[next] = newCost;
                q.push(P(newCost, next));
            }
        }
    }
}

double dist(double x1,double y1,double x2,double y2){
	return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

signed main(){
    int m;
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy >> m;
    n = m + 2;
    vector<double> x(n), y(n), r(n);
    x[0] = sx; y[0] = sy;
    x[n - 1] = gx; y[n - 1] = gy;
    rep(i, 1, m + 1){
        cin >> x[i] >> y[i] >> r[i];
    }
    rep(i, 0, n){
        rep(j, i + 1, n){
            double dt = dist(x[i], y[i], x[j], y[j]);
            if(0 < i && i < n - 1) dt -= r[i];
            if(0 < j && j < n - 1) dt -= r[j];
            if(dt < 1e-10) dt = 0.0;
            // cout << i << " " << j << " " << dt << endl;
            G[i]. push_back((edge){j, dt});
            G[j]. push_back((edge){i, dt});            
        }
    }
    dijkstra(0);
    // rep(i, 0, n) cout << i <<" " << d[i] << endl;
    // double ans = sqrt(d[n - 1] * 1.0);
    printf("%.15lf\n", d[n - 1]);
}

Measured memory_bytes: 22768
#include<cstdio>
#include<cstring>
using namespace std;

int n,p,x;
long long f[10010][2];

int main(){
	scanf("%d%d",&n,&p);
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		f[i][0]=f[i-1][0]+f[i-1][x&1];
		f[i][1]=f[i-1][1]+f[i-1][(x&1)^1];
	}
	printf("%lld\n",f[n][p]);
	return 0;
} 

Measured memory_bytes: 128
import itertools
N = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

junretu = [i + 1 for i in range(N)]
cnt = 0
for i in itertools.permutations(junretu, N):
    cnt += 1
    if i == p:
        a = cnt
        #cnt += 1
    if i == q:
        b = cnt
        #cnt += 1
    #cnt += 1
print(abs(a - b))

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

int main() {
	int N;
	cin>>N;
	vector<int> X(N);
	for (int i = 0; i < N; i++){
		cin>>X[i];
	}
	int ans=1000000;
	for (int i = 1; i <= 100; i++){
		int sum=0;
		for (int j = 0; j < N; j++){
			sum+=pow(i-X[j],2);
		}
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        int sum = 0, MAX = 0, MIN = 1100;
        rep(i, 0, n){
            int s;
            cin >> s;
            sum += s;
            MAX = max(MAX, s);
            MIN = min(MIN, s);
        }
        cout << (sum - MAX - MIN) / (n - 2) << endl;
    }
}

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

using namespace std;

int main()
{
    long long a, b, x, l, r, n, m, ans = 0;
    cin >> a >> b >> x;
    if(a % x == 0)
        l = a;
    else {
        l = ((a/x)+1) * x;
    }
    if(b % x == 0)
        r = b;
    else {
        r = (b/x) * x;
    }
    //cout << l << " " << r << endl;
    if(l > r || r < l) {
        cout << ans;
        return 0;
    }
    n = l/x;
    m = r/x;
    ans = m - n + 1;
    cout << ans;
}


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

int main() {
    int N;
    cin >> N;
    vector<long long> L(N), R(N);
    for(int i=0; i<N; ++i) cin >> L[i] >> R[i];

    sort(L.begin(), L.end(), greater<long long>());
    sort(R.begin(), R.end());

    vector<long long> Lsum(N+1, 0);
    vector<long long> Rsum(N+1, 0);
    for(int i=0; i<N; ++i) {
        Lsum[i + 1] = Lsum[i] + L[i];
        Rsum[i + 1] = Rsum[i] - R[i];
    }

    long long res = 0;
    for(int r=0; r<=N; ++r) {
        for(int l=r-1; l<=r+1; ++l) {
            if(l < 0 || l + r > N) continue;
            long long tmp = Lsum[r] + Rsum[l];
            res = max(res, 2LL * tmp);
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	string a[101];
	int n,L;
    cin>>n>>L;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)cout<<a[i];
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] P = new int[M];
        int[] Y = new int[M];
        for (int i = 0; i < M; ++i) {
            P[i] = sc.nextInt();
            Y[i] = sc.nextInt();
        }

        System.out.println(solve(N, P, Y));

        sc.close();
    }

    static String solve(int N, int[] P, int[] Y) {
        String[] result = new String[P.length];
        int[] counts = new int[N + 1];
        int[] sortedIndices = IntStream.range(0, P.length).boxed().sorted((i1, i2) -> Integer.compare(Y[i1], Y[i2]))
                .mapToInt(x -> x).toArray();
        for (int index : sortedIndices) {
            ++counts[P[index]];
            result[index] = String.format("%06d%06d", P[index], counts[P[index]]);
        }

        return String.join("\n", result);
    }
}

Measured memory_bytes: 76536
#include<stdio.h>

struct Node{
  int p;
  int l;
  int r;
};
struct Node T[200002];

int getdepth(int a){
  if(T[a].p == -1){
    return 0;
  }
  return getdepth(T[a].p)+1;
}

int main(){
  int i,j,k,n,id,c,tmp;

  scanf("%d",&n);
  int depth[n];
  for(i=0;i<n;i++){
    T[i].p = T[i].l = T[i].r = -1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      if(j==0){
        T[id].l=c;
        T[c].p=id;
        tmp=c;
      }
      else{
        T[tmp].r=c;
        T[c].p=id;
        tmp=c;
      }
    }
   }
    for(i=0;i<n;i++){
      depth[i]=getdepth(i);
    }
    for(i=0;i<n;i++){
      printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth[i]);
      if(T[i].p==-1){
        printf("root, [");
      }
      else if(T[i].l==-1){
        printf("leaf, [");
      }
      else{
        printf("internal node, [");
      }
      if(T[i].l != -1){
        printf("%d",T[i].l);
        tmp = T[i].l;
        while(1){
          if(T[tmp].r==-1) break;
          printf(", %d",T[tmp].r);
          tmp = T[tmp].r;
        }
       }
          printf("]\n");
      }
  return 0;
}



Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool chmax(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

const int MAXN = 100100;
int prime[MAXN]; // n 以下の素数のうち i 番目の素数
int prime2[MAXN]; // n 以下の素数のうち i 番目の素数
bool is_prime[MAXN]; // 整数 i が素数であるかどうか
bool is_prime2[MAXN]; // 整数 i が素数であるかどうか
int sieve(int n) {
  int res = 0;
  fill(is_prime, is_prime + MAXN, true);
  is_prime[0] = is_prime[1] = false; // 0 と 1 は素数ではない。
  reps(i,2,n+1) {
    if(!is_prime[i]) continue;
    prime[res++] = i;
    for(int j = 2*i ; j<=n ; j+=i ) is_prime[j] = false; // 素数 i の倍数は素数ではない (ふるい(篩)にかける)
    if(i*2-1<n+1) is_prime2[i*2-1] = true;
  }
  return res;
}

void Main(){

  int Q;
  cin>>Q;
  sieve(100010);

  int ct=0;
  rep(i,100010){
    if(is_prime[i] and is_prime2[i]) ++ct;
    prime2[i]=ct;
  }

  rep(i,Q){
    int l,r; cin>>l>>r;
    cout<< prime2[r]-prime2[l-1]<<"\n";
  }
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

const int MAX = 2e5 + 1;

int n;
int a[MAX];
void solve(){
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) a[i] = 0;
	for (int i = n-2, x; ~i; --i) scanf("%d", &x), ++a[x-1];
	for (int i = 0; i < n; ++i) printf("%d\n", a[i]);
}

int main(){

	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	solve();
	return 0;
}

Measured memory_bytes: 4628
from math import sqrt


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return map(int, input().split())


def main():
    s = input()
    n = len(s) - 1
    for k in range(2 ** n):
        ops = list(("{0:{fill}%db}" % n).format(k, fill="0").replace("0", "+").replace("1", "-"))
        ops.append("")
        q = ""
        for a, b in zip(s, ops):
            q += a + b
        v = eval(q)
        if v == 7:
            print(q + "=7")
            break


main()


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, W;
    cin >> N >> W;

    vector<vector<ll>> vec(4);
    ll basew = 0;
    rep (i, N) {
        ll w, v;
        cin >> w >> v;
        if (i == 0) {
            basew = w;
        }
        vec[w-basew].push_back(v);
    }

    rep (i, 4) {
        sort(vec[i].rbegin(), vec[i].rend());
    }
    rep (i, 4) {
        vec[i].insert(vec[i].begin(), 0);
    }

    ll ans = 0;
    rep (i, vec[0].size()) {
        rep (j, vec[1].size()) {
            rep (k, vec[2].size()) {
                rep (l, vec[3].size()) {
                    if (basew*i + (basew+1)*j + (basew+2)*k + (basew+3)*l <= W) {
                        ll value = 0;
                        rep (m, i+1) {
                            value += vec[0][m];
                        }
                        rep (m, j+1) {
                            value += vec[1][m];
                        }
                        rep (m, k+1) {
                            value += vec[2][m];
                        }
                        rep (m, l+1) {
                            value += vec[3][m];
                        }
                        ans = max(ans, value);
                    }
                }
            }
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;cin>>k;
  map<int,int>mod;
  int ans=1;
  int tmp=7%k;
  while(tmp){
    ans++;
    tmp*=10;
    tmp%=k;
    tmp+=7;
    tmp%=k;
    if(mod.count(tmp)){
      cout<<-1<<endl;
      return 0;
    }
    else mod[tmp]=1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 50480
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
sum = 0

for i in range(1, K+1):
  for j in range(i+1, K+1):
    for k in range(j+1, K+1):
      sum = sum + 6*(gcd(i, j, k))
      # print(i, j, k, gcd(i, j, k))

for i in range(1, K+1):
  for j in range(i+1, K+1):
    # print(i, j,  gcd(i, j))
    sum = sum + 6 * (gcd(i, j))

for i in range (1, K+1):
  # print(i)
  sum = sum + i

print(sum)

Measured memory_bytes: 75232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    for (int i = N-1; i >= 0; i--){
        if(i == 0){
            cout << v[i] << endl;
        } else {
            cout << v[i] << " ";
        }
    }
}



Measured memory_bytes: 3116
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner input_line = new Scanner(System.in);
		String input = input_line.nextLine();
		String[] Array = input.split(" ");
		int a = Integer.parseInt(Array[0]);
		int b = Integer.parseInt(Array[1]);
		int c = Integer.parseInt(Array[2]);
		int num;
		int count = 0;
		for(num = a; num <=b ; num++){
			if(c%num == 0){
				count = count + 1;
			}
		}
		System.out.println(count);	
	}
}

Measured memory_bytes: 25948
import java.util.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String[] first = br.readLine().split(" ", 2);
		int n = Integer.parseInt(first[0]);
		int m = Integer.parseInt(first[1]);
		long[] score = new long[n + 2];
		Arrays.fill(score, Long.MAX_VALUE / 10);
		PriorityQueue<Path> queue = new PriorityQueue<>();
		for (int i = 0; i < m; i++) {
		    String[] line = br.readLine().split(" ", 3);
		    int a = Integer.parseInt(line[0]);
		    int b = Integer.parseInt(line[1]);
		    int c = Integer.parseInt(line[2]);
		    queue.add(new Path(a, b, c));
		}
		score[1] = 0;
		while (queue.size() > 0) {
		    Path p = queue.poll();
		    int left = p.from;
		    int right = n + 1;
		    while (right - left > 1) {
		        int mm = (left + right) / 2;
		        if (score[mm] > score[p.from] + p.value) {
		            right = mm;
		        } else {
		            left = mm;
		        }
		    }
		    for (int i = right; i <= p.to; i++) {
		        score[i] = Math.min(score[i], score[p.from] + p.value);
		    }
		}
		if (score[n] >= Long.MAX_VALUE / 10) {
		    System.out.println(-1);
		} else {
		    System.out.println(score[n]);
		}
	}
	
	static class Path implements Comparable<Path> {
	    int from;
	    int to;
	    int value;
	    
	    public Path(int from, int to, int value) {
	        this.from = from;
	        this.to = to;
	        this.value = value;
	    }
	    
	    public int compareTo(Path another) {
	        return from - another.from;
	    }
	}
}


Measured memory_bytes: 48424
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    const d = [1,2,3].filter((v)=>{
     	return !input.includes(v);
    })
	//出力
	console.log('%d',d[0]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int pow_m1(long long int num){
	long long int pow_num = MOD - 2;
	long long int mod_num = MOD;
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

long long int fact[210000], factm[210000], p2m[210000];

int main(){
    fact[0] = factm[0] = p2m[0] = 1;
    for(int i = 1; i < 210000; i++){
        fact[i] = fact[i - 1] * i;
        fact[i] %= MOD;
    }
    for(int i = 1; i < 210000; i++){
        factm[i] = factm[i - 1] * pow_m1(i);
        factm[i] %= MOD;
    }
    for(int i = 1; i < 210000; i++){
        p2m[i] = p2m[i - 1] * factm[2];
        p2m[i] %= MOD;
    }
    long long int B, W;
    cin >> B >> W;
    long long int p1 = 0, p2 = 0;
    for(int i = 0; i < B + W; i++){
        if(i >= B){
            p1 += fact[i - 1] * factm[B - 1] % MOD * factm[i - B] % MOD * p2m[i] % MOD;
            p1 %= MOD;
        }
        if(i >= W){
            p2 += fact[i - 1] * factm[W - 1] % MOD * factm[i - W] % MOD * p2m[i] % MOD;
            p2 %= MOD;
        }
        cout << (p2 + ((1 - p1 - p2 + MOD * 3) % MOD * p2m[1] % MOD)) % MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
string s;
int main(){
	cin>>n>>s;
	int all = 0,cur = 0,cur2 = 0;
	rep(i,n) all += (s[i]=='E');
	int ans =INF;
	rep(i,n){
		cur += (s[i]=='E');
		ans = min(ans,cur2+all-cur);
		cur2 += (s[i]=='W');
	}
	cout<<ans<<endl;
}

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

int main(){
	int a,b; cin>>a>>b;
	for(int i=0; i<=a; i++){
		for(int j=0; j<=a; j++){
			if(i*2+j*4==b){
              if(i+j==a){cout << "Yes" << endl; return 0;}
            }
		}
	}
	cout << "No" << endl;	
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int H, W, M;
	cin >> H >> W >> M;
	vector<pair<int, int> > pair;
	int HTarget[300300];
	int WTarget[300300];
	for(int i = 0; i < 300300; i++){
		HTarget[i] = 0;
		WTarget[i] = 0;
	}
	for(int i = 0; i < M; i++){
		int h, w;
		cin >> h >> w;
		HTarget[h]++;
		WTarget[w]++;
		pair.push_back(make_pair(h, w));
	}
	
	int HMax = 0;
	int WMax = 0;
	for(int i = 0; i < 300300; i++){
		HMax = max(HTarget[i], HMax);
		WMax = max(WTarget[i], WMax);
	}
	set<int> HMaxList;
	set<int> WMaxList;
	for(int i = 0; i < 300300; i++){
		if(HMax == HTarget[i]){
			HMaxList.insert(i);
		}
		if(WMax == WTarget[i]){
			WMaxList.insert(i);
		}
	}
	
	int count = 0;
	for(int i = 0; i < pair.size(); i++){
		if(HMaxList.find(pair[i].first) != HMaxList.end() && WMaxList.find(pair[i].second) != WMaxList.end()){
			count++;
		}
	}
	ll ans = 0;
	if(count == HMaxList.size() * WMaxList.size()){
		ans = HMax + WMax - 1;
	}else{
		ans = HMax + WMax;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 36188
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

template<int mod=1000000007>
class ModInt {
  int x;
public:
  ModInt() : x(0) {}
  ModInt(const ModInt &y): x(y.x) {}
  ModInt(int64_t y){ x = y % mod; if(x < 0) x += mod; }
  ModInt &operator += (const ModInt &p){ x += p.x; if(x >= mod) x -= mod; return *this; }
  ModInt &operator -= (const ModInt &p){ x -= p.x; if(x < 0) x += mod; return *this; }
  ModInt &operator *= (const ModInt &p){ x = (int) (1LL * x * p.x % mod); return *this; }
  ModInt &operator /= (const ModInt &p){ *this *= p.inverse(); return *this; }
  ModInt operator -() const { return ModInt(-x); }
  ModInt operator + (const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator - (const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator * (const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator / (const ModInt &p) const { return ModInt(*this) /= p; }
  ModInt operator ^ (const int64_t y) const { return pow(y); }
  bool operator == (const ModInt &p) const { return x == p.x; }
  bool operator != (const ModInt &p) const { return x != p.x; }
  ModInt operator = (const int64_t y) { return *this = ModInt(y); }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0){
      t = a/b; a -= t*b; swap(a, b);
      u -= t*v; swap(u, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t y) const {
    if(x==0) return ModInt(0);
    int64_t r = 1, t = x;
    while(y > 0){
      if(y&1) r = r*t%mod;
      t = t*t%mod; y >>= 1;
    }
    return ModInt(r);
  }
  friend ostream &operator << (ostream &os, const ModInt<mod> &p) { return os<<p.x; }
  friend istream &operator >> (istream &is, ModInt<mod> &a) { int64_t x; is>>x; a = ModInt<mod>(x); return is; }
};
using Int = ModInt<>;

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;

  vector<Int> dp(n, 1);
  rep(i,n-1){
    vector<Int> nxt(n, 0);
    if(s[i] == '<'){
      Int acc = 0;
      for(int j=n-1; j>=0; j--) {
        nxt[j] = acc;
        acc += dp[j];
      }
    } else {
      Int acc = 0;
      rep(j,n-i-1){
        acc += dp[j];
        nxt[j] = acc;
      }
    }
    swap(dp, nxt);
  }

  cout << dp[0] << endl;

  return 0;
}


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

using namespace std;

#define ll long long int 
int gcd(int p, int q) 
{ 
    if (p == 0) 
        return q; 
    return gcd(q % p, p); 
} 

int main (){
    ll K,sum=0;
    ll a=1,b=1,c=1;
    cin>>K;
    
    for(a=1; a<=K;a++){
        for(b=1; b<=K; b++){
            for(c=1; c<=K; c++){
                sum= sum+ gcd(a, gcd(b,c));
            }
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3636
import java.io.*;
import java.util.*;
public class Main{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}
        int nextInt(){return Integer.parseInt(next());}
        long nextLong(){return Long.parseLong(next());}
        double nextDouble(){return Double.parseDouble(next());}
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}
    }
    static int getGcd(int n1,int n2){
        while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        }
        return n1;
    }
    static boolean isSorted(int[] arr, int n){
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        }
        return true;
    }
    static boolean isPrime(long n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static boolean isPrime(int n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        //System.out.println();
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader s=new FastReader();
        int t = s.nextInt();
//        int n;
//        String str;
//        while(t-- > 0){
//
//        }
        if(t>=30) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 25336
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define PI pair<int , int>
#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

//#define max(a,b) a>b?a:b
//#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s;cin>>s;
    if(s[0] == s[1] && s[1] == s[2] && s[0] == 'R') std::cout << 3 << "\n";
    else if(s[0] == s[1] && s[1] != s[2] && s[0] == 'R') std::cout << 2 << "\n";
    else if(s[0] != s[1] && s[1] == s[2] && s[1] == 'R') std::cout << 2 << "\n";
    else if(s[0] == 'R' || s[1] == 'R'||s[2] == 'R')cout<<1;
    else{
        std::cout << 0 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


void solve()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(abs(a - b) <= d && abs(c - b) <= d){
		cout << "Yes";
	}
	else if(abs(a - c) <= d) cout << "Yes";
	else cout << "No"; 
}


 // a b c a b c a b c a b c
 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	//cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int N, K, A[105];
bool DP[100005], visited[100005];

bool Calc(int turn){
  if (visited[turn] == true) return DP[turn];
  visited[turn] = true;
  if (turn == 0) return DP[0] = false;

  bool ans = false;
  for (int i = 0; i < N; i++){
    if (turn - A[i] < 0) continue;
    if (!Calc(turn - A[i])) ans = true;
  }
  return DP[turn] = ans;
}

int main(){
  scanf("%d%d",&N,&K);
  for (int i=0;i<N;i++)scanf("%d",&A[i]);


  if (Calc(K)) cout << "First" << endl;
  else cout << "Second" << endl;

  return 0;
}


Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define vl vector<ll>
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {

    ld A;
    ld B;
    cin >> A >> B;
    
    cout << (ll)floor(A*B) << endl;

    return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

bool f(const vector<int>& a, int k, int x){
    int sum = 0;
    for(int i=0;i<a.size();++i){
        if(a[i] <= x) return true;
        if(a[i] > x){
            sum += dup(a[i], x) - 1;
        }

        if(sum > k) return false;
    }
    return true;
}

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

    sort(a.rbegin(), a.rend());

    int l=0, r=a[0] + 1;
    while(r - l > 1){
        int c = (r + l) / 2;
        if(f(a, k, c)){
            r = c;
        }else{
            l = c;
        }
    }

    cout << r << endl;
}

Measured memory_bytes: 4040
#include <iostream>
#include <cmath>
#include <climits>

using namespace std;

int main(void) {
  int N, L, sum = 0;
  int min = INT_MAX, tmp;
  
  cin >> N >> L;
  for (int i = 1; i <= N; i++) {
    tmp = L + i - 1;
    sum += tmp;
    if (abs(tmp) < abs(min)) {
      min = tmp;
    }
    //cout << i << " , " << tmp << " , " << min << ", " << sum << endl;
  }
  sum -= min;
  cout << sum << endl;
  
  return 0;
}
  

Measured memory_bytes: 256
while 1:
  c=[0,1,1]+[0]*98
  while 1:
    try:a,b=map(int,raw_input().split())
    except:exit()
    if a==0==b:break
    c[a]=1-c[a]
    c[b]=1-c[b]
  print["NG","OK"][sum(c)==0]

Measured memory_bytes: 4216
#include <set>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996);
using namespace std;
const vector<int> dir = { 0, 1, 0, -1 };
int H, W;
int main() {
	cin >> H >> W;
	vector<vector<int> > v(H, vector<int>(W));
	vector<int> x(H * W), y(H * W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> v[i][j]; v[i][j]--;
			x[v[i][j]] = j;
			y[v[i][j]] = i;
		}
	}
	vector<int> dp(H * W, -1);
	for (int i = 0; i < H * W; i++) {
		vector<int> s;
		for (int j = 0; j < 4; j++) {
			int dx = dir[j], dy = dir[j ^ 1];
			int tx = x[i] + dx, ty = y[i] + dy;
			if (0 <= tx && tx < W && 0 <= ty && ty < H && v[ty][tx] < i) {
				s.push_back(dp[v[ty][tx]]);
			}
		}
		sort(s.begin(), s.end());
		s.erase(unique(s.begin(), s.end()), s.end());
		if (s.size() == 0) dp[i] = i;
		else if (s.size() > 1 || s.back() == 999999999) dp[i] = 999999999;
		else dp[i] = s[0];
	}
	int ret = 0;
	for (int i = 0; i < H * W; i++) ret += (dp[i] == 999999999 ? 1 : 0);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 18400