akhauriyash/Code-Regression huggingface dataset:
//confilm 0LL and 1LL
//confilm cornercase such as 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n, d;
	cin >> n >> d;
	vector<Vec> x(n, Vec(d));
	rep(i, n){
		rep(j, d) cin >> x[i][j];
	}

	ll ans = 0;
	rep(i, n-1){
		REP(j, i+1, n){
			double dist = 0;
			rep(k, d) dist += pow(x[i][k]-x[j][k], 2);
			dist = sqrt(dist);
			ll a = dist+EPS;
			if(abs(dist-a) <= EPS) ans++;
		}
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll n;
  cin >> n;
  vector<ll> a1(n), a2(n);
  rep(i, 0, n) cin >> a1[i];
  rep(i, 0, n) cin >> a2[i];

  ll ans = 0;
  rep(i, 0, n){
    ll suma = 0, sumb = 0;
    rep(j, 0, i+1){
      suma += a1[j];
    }
    rep(j, i, n){
      sumb += a2[j];
    }
    chmax(ans, suma + sumb);
  }
  cout << ans << endl;
  return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define T true
#define F false 

vector<ll> y_vec = {0, 0, -1, +1};  // 進む方向の簡便化，テクニックとして覚えておく．
vector<ll> x_vec = {-1, +1, 0, 0};  // ループで回すことで上下左右に移動できるようになっている

struct Corr{
	ll y;
	ll x;
	ll depth;
};

ll x, y, depth;
queue<Corr> q;

ll H, W;
vector<vector<bool>> S(20,vector<bool>(20,false)), vec(20,vector<bool>(20));

ll bfs(){
	ll max_path = -1;

	while(!q.empty()){
		Corr now = q.front(); q.pop();
		y = now.y; x = now.x; depth = now.depth;

		// cout << y << x << depth << "\n";

		REP(i,4){
			Corr next = {y + y_vec[i], x + x_vec[i], depth+1};
			if(0 <= next.y && next.y <= H-1 && 0 <= next.x && next.x <= W-1 && vec[next.y][next.x] == T){
				vec[next.y][next.x] = false;
				q.push(next);
				max_path = max(max_path, next.depth);
			}
		}
	}

	return max_path;
}

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述
	cin >> H >> W;

	string temp;
	for(int i=0; i<H; i++){
		cin >> temp;
		REP(j,W){
			if(temp[j] == '.'){
				S[i][j] = T;
			}
			else{
				S[i][j] = F;
			}
		}
	}

	ll ans = 0;

	REP(i,H){
		REP(j,W){
			if(S[i][j] == F){
				continue;
			}
			else{
				vec = S;
				Corr start = {i, j, 0};
				vec[start.y][start.x] = false;
				q.emplace(start);
				ans = max(ans,bfs());
			}
			// cout << ans << "\n";
		}
	}

	cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
typedef long long ll;
using namespace std;
int d,k,L,i,j,ten[15],a[25];
int s[25],mx,f[25];ll ans,an;
void dfs(int x,ll now){
	if (L-x>=k-1&&abs(now)>=10) return;
	int i;
	if (x>mx){
		an=a[s[1]+9]-(s[1]<=0);
		if (L&1) an*=10-(L==1);
		s[L]=-s[1];
		fo(i,2,mx) an*=a[s[i]+9],s[L-i+1]=-s[i];
		ll p=0;
		fd(i,L,1){
			p=p*10+s[i];
			if (p>d||p<0) return;
		}if (p==d) ans+=an;
		return;
	}
	fo(i,-9,9) s[x]=i,dfs(x+1,now*10-i);
}
int main(){
	ten[0]=1;
	fo(i,1,9) ten[i]=ten[i-1]*10;
	scanf("%d",&d);
	fo(i,1,9) if (d<ten[i]) break;
	k=i+1;
	fo(i,0,9)
	fo(j,0,9) a[i-j+9]++;
	fo(L,2,k<<1){
		mx=L>>1;
		memset(s,0,sizeof(s));
		dfs(1,0);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.first << ' ' << p.second << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define NMAX 100005
const long double PI = acos(-1);

int n,v[NMAX];
ll dp[NMAX];

int main(){
  ios::sync_with_stdio(false);
  cin >> n;
  memset(dp,0x3f,sizeof dp);
  dp[1] = 0;
  for (int i=1;i<=n;i++){
  	cin >> v[i];
  	if (i > 1){
  		dp[i] = min(dp[i], dp[i-1] + abs(v[i] - v[i-1]));
  	}
  	if (i > 2){
  		dp[i] = min(dp[i], dp[i-2] + abs(v[i] - v[i-2]));
  	}
  }

  cout << dp[n] << '\n';
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){

  int a[3];
  for(int i=0; i<3;i++) cin >>a[i];
  sort(a,a+3);
  
  if(a[0] == 5 &&a[1] == 5&&a[2] == 7) cout <<"YES" <<endl;
  else cout <<"NO" <<endl;
  
}

Measured memory_bytes: 256
import numpy as np
n,k = map(int, input().split())
a = input().split()
flag = np.zeros((n))
now = 1
memory = []
for i in range(k):
    if flag[now-1] != 1:
        flag[now-1] = 1
        memory.append(now)
        now = int(a[now-1])        
    else :
        index = memory.index(now)
        num = len(memory) - index
        rest = k - i
        shorten = rest % num
        now = memory[index+shorten]
        break
print(now)

Measured memory_bytes: 49352
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e,f,g,h,x,y;
    cin >>a>>b>>c>>d;
    cin >>e>>f>>g>>h;
    x=a+b+c+d;
    y=e+f+g+h;
    
    if (x<y){
        cout << y;
    }
    else {
        cout <<x;
    }
    cout << endl;
}



Measured memory_bytes: 3092
from math import atan,pi
a,b,x=map(int,input().split())
if a**2*b>=2*x:
    try:
        print(90-atan(2*x/(a*b**2))*180/pi)
    except: print(0)
else:
    try:
        print(90-atan(a**3/(2*a**2*b-2*x))*180/pi)
    except: print(0)

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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    int n;
    cin >> n;
    vi a(n - 1);
    vi ans(n, 0);
    rep(i, n - 1) cin >> a[i];
    rep(i, n - 1) a[i]--;

    rep(i, n - 1) ans[a[i]]++;
    rep(i, n) out(ans[i]);
    return 0;
}


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

#define NUMALPHA 26

using namespace std;

int INF = 1 << 20;

int main() {
    int n;
    scanf("%d", &n);
    char str[n+1];
    scanf("%s", str);
    for(int i = 0; i < n; i++) {
        str[i] -= 'a';
    }

    set<int> poses[NUMALPHA];

    for(int i = 0; i < NUMALPHA; i++) {
        poses[i].insert(INF);
    }

    for(int i = 0; i < n; i++) {
        poses[(int)str[i]].insert(i);
    }

    int queries_count;
    scanf("%d", &queries_count);

    int queries[queries_count][3];
    char temp;
    for(int i = 0; i < queries_count; i++) {
        scanf("%d", &queries[i][0]);
        if(queries[i][0] == 1) {
            scanf("%d %c", &queries[i][1], &temp);
            queries[i][1]--;
            queries[i][2] = temp - 'a';
        }else {
            scanf("%d %d", &queries[i][1], &queries[i][2]);
            queries[i][1]--;
        }
    }

    for(int i = 0; i < queries_count; i++) {
        if(queries[i][0] == 1) {
            int pos = queries[i][1];
            poses[(int)str[pos]].erase(pos);
            poses[queries[i][2]].insert(pos);
            str[pos] = queries[i][2];
        }else {
            int type_count = 0;
            int start = queries[i][1];
            int end = queries[i][2];
            for(int j = 0; j < NUMALPHA; j++) {
                int start_it = *poses[j].lower_bound(start);
                int end_it = *poses[j].lower_bound(end);
                if(start_it < end_it) type_count++;
            }
            printf("%d\n", type_count);
        }
    }
}

Measured memory_bytes: 24448
n, x, M = gets.split.map(&:to_i)

visited = [nil] * M
chain = []

seconds = 0
while visited[x].nil?
    chain << x
    visited[x] = seconds
    x = x * x % M
    seconds += 1
end

start = visited[x]
length = seconds - start

chain_sum = [0]
for e in chain
    chain_sum << chain_sum[-1] + e
end

answer = 0
if n < start
    answer += chain_sum[n]
    n = 0
else
    answer += chain_sum[start]
    n -= start
end

answer += (chain_sum[seconds] - chain_sum[start]) * (n / length)
answer += chain_sum[start + (n % length)] - chain_sum[start]
puts answer



Measured memory_bytes: 16108
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator> 
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);


#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//~ const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

int v[100007];
int main() {
	int n; cin>> n;
	long double prod = 1;
	long double maxi = pow(10,18);
	bool ok = false;
	bool yes = false;
	for (int i = 1; i <= n; i++) {
		double a;
		cin>> a;
		if (a == 0)
			yes = true;
		if (!ok)
			prod *= a;
		//~ cout<<i<<":"<<a<<"*"<<prod<<"=:"<<prod<<endl;
		if (prod > maxi) {
			ok = true;
		}
	}
	if (yes) {
		cout<< 0;
		return 0;
	}
	if (!ok)
		cout<< ll(prod);
	else 
		cout<<-1;
	return 0;
} 

/*
int main() {
	cout<<1e18<<endl;
	int n; cin>> n;
	ll prod = 1;
	ll maxi = pow(10,18);
	for (int i = 1; i <= n; i++) {
		double a;
		cin>> a;
		prod *= a;
		cout<<"prod:"<<prod<<endl;
		if (prod > maxi) {
			cout<< -1;
			return 0;
		}
	}
	cout<< prod;
  return 0; 
} 
*/




Measured memory_bytes: 3772
from collections import deque
n,m = map(int, input().split())
G = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    a-=1
    b-=1
    G[b].append(a)
    G[a].append(b)

dist = [-1]*n
que = deque()
cnt = 0

for i in range(n):
    if dist[i]!=-1:
        continue
    dist[i]=0
    que.append(i)
    while len(que):
        v = que.pop()
        s = G[v]
        for j in s:
            if dist[j]!=-1:
                continue
            dist[j]=0
            que.append(j)
    cnt += 1

print(cnt-1)

Measured memory_bytes: 26648
import java.util.*;
class Main{
 static public void main(String[] args){
  Scanner sc=new Scanner(System.in);
   String s1=sc.next(),s2=sc.next(),s3=sc.next();
   System.out.print(s1.charAt(0));
   System.out.print(s2.charAt(1));
   System.out.print(s3.charAt(2));
   sc.close();
 }
}


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

const int MOD = 10007;

int N;
char buf[114514];
int dp[114514][8];
map<char, int> rev;

int main() {
  scanf("%d", &N);
  scanf("%s", buf);
  rev['J'] = 0;
  rev['O'] = 1;
  rev['I'] = 2;
  dp[0][1] = 1;
  int lim = 1 << 3;
  for (int i=0; i<N; i++) {
    for (int st=0; st<lim; st++) {
      for (int nst=1; nst<lim; nst++) {
        if (!(nst >> rev[buf[i]] & 1)) continue;
        if (!(st & nst)) continue;
        dp[i+1][nst] += dp[i][st];
        dp[i+1][nst] %= MOD;
      }
    }
  }

  int ans = 0;
  for (int st=0; st<lim; st++) {
    ans += dp[N][st];
    ans %= MOD;
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const int INF = 100100100;
using namespace std;

int main()
{
  int A, B;
  int res=0;
  cin >> A >> B;

  if(A*B%2==0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

#define MaxN 1005
#define INF 2140000000
#define eps 1e-9
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795

using namespace std;

long long N,A,B,C,D,Delta,Total;
int main()
{
    cin>>N>>A>>B>>C>>D;
    N--;
    Delta=abs(C-D);
    Total=abs(A-B);
    for(int i=1;i<=N;i++)
    {
        long long Beta=Total-C*(2*i-N);
        if(Beta>=-Delta*(N-i)&&Beta<=Delta*i)
        {
            cout<<"YES\n";
            return 0;
        }
    }
    cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    // make cin faster
    ios_base::sync_with_stdio(0);
    cin.tie();
    //
    string S;
    cin >> S;
    const int MOD = 2019;
    const int size = S.size();
    int answer = 0; //1817181712114
    int power = 1;
    int index = 0;
    vector<int> counts(MOD);
    for (int i=size-1; i>=0; i--){
        int digit = S[i] - '0';
        index = (index + (digit * power)) % MOD;
        power *= 10; power %= MOD;
        answer += counts[index];
        if (index == 0) answer++;
        counts[index]++;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(ll i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    ll d = B-A;
    rep2(i, 0, N-1){
        ll M = D*i-C*(N-1-i);
        ll m = C*i-D*(N-1-i);
        if(m <= d && d <= M) {cout << "YES" << endl; return 0;}
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
const int depth = 13;
struct edge {
	int a, b, c;
};
int main() {
	int L;
	cin >> L;
	vector<edge> ans;
	int mul = 1;
	for (int i = 0; i < depth - 1; ++i) {
		ans.push_back(edge{ i, i + 1, mul * 0 });
		ans.push_back(edge{ i, i + 1, mul * 1 });
		ans.push_back(edge{ i, i + 1, mul * 2 });
		mul *= 3;
	}
	int sum = 0;
	for (int i = depth - 1; i >= 0; --i) {
		for (int j = 0; j < L / mul % 3; ++j) {
			ans.push_back(edge{ i, depth, sum });
			sum += mul;
		}
		mul /= 3;
	}
	cout << depth + 1 << ' ' << ans.size() << endl;
	for (edge e : ans) {
		cout << e.a + 1 << ' ' << e.b + 1 << ' ' << e.c << endl;
	}
	return 0;
}

Measured memory_bytes: 504
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    lis = []
    for _ in range(n):
        x, l = LI()
        lis.append((x + l, x - l))
    lis.sort()
    ans = 0
    now = -inf
    for r, l in lis:
        if now <= l:
            now = r
            ans += 1
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 50140
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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 n;
  cin >> n;
  int ans = 0, h = 0;
  rep(i,n){
    int hi;
    cin >> hi;
    if(hi>=h){
      ++ans;
      h = hi;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(v) v.begin(),v.end()
#define mod 1000000007


int main(){
  ll a,b,c,n;

  cin >> a>> b>>c;
  ll ans;
  if(a==b&&b==c)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
ll N,r;
vector<vector<pair<ll,ll>>> G(100010);
vector<ll> d(100010,INF);
void dijkstra(){
    
    d[r] = 0;
    priority_queue<Pi,vector<Pi>,greater<Pi>> pque;
    pque.push(mp(0,r));
    while(!pque.empty()){
        Pi p = pque.top();
        pque.pop();
        ll pos=p.second,cost=p.first;
        if( cost > d[pos] )continue;
        rep(i,G[pos].size()){
            ll  to = G[pos][i].first;
            ll newcost = cost + G[pos][i].second;
            if(newcost < d[to]){
                d[to] = newcost;
                pque.push(mp(d[to],to));
            }
        }

    }

}

int main() {
    
    cin >>N;
    rep(i,N-1){
        ll a,b,c;
        cin >>a>>b>>c;
        a--;b--;
        G[a].pb(make_pair(b,c));
        G[b].pb(make_pair(a,c));
    }
    dijkstra();

    rep(i,N){
        cout<<(d[i]%2)<<endl;
    }



    return 0;
    

}

Measured memory_bytes: 11352
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
train = []

for i in range(N - 1):
    c, s, f = getNM()
    train.append([c, s, f])

# sta~Nまで行くのにかかる時間を求める関数
def gotowest(sta):
    # 1 ~ 2まで
    time = train[sta][0] + train[sta][1]
    for j in range(sta + 1, N - 1):
        if time <= train[j][1]:
            time = train[j][0] + train[j][1]
                # 一本目の列車出発後
        else:
            # 最初の一本から数えてwait本目の列車に乗る
            wait = ((time - train[j][1]) + train[j][2] - 1) // train[j][2]
            time = train[j][1] + (train[j][2] * wait) + train[j][0]
    return time
    
ans = []
for i in range(N - 1):
    ans.append(gotowest(i))
# N~Nまで（０分）
ans.append(0)
for i in ans:
    print(i)

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

int main() {
  int n, k, sum;
  cin >> n >> k;
  sum = 1;
  
  rep(i, n){
  	if (2*sum < sum+k) {
    	sum *= 2;
    }
  	else {
    	sum += k;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int sum_digit(int n) {
    int s = 0;
    while(n > 0){
        s += n % 10;
        n /= 10;
    }
    return s;
}

int main(){
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);

    int i, s;
    int ans = 0;
    for(i = 1; i <= n; ++i){
        s = sum_digit(i);
        if (a <= s && s <= b){
            ans += i;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
char p[6010], q[6010];
int n;
int main() {
	int i, j;
	vector<int>P, Q;
	scanf("%d", &n);
	scanf("%s%s", p,q);
	char cur = '0';
	for (i = 0; p[i]; i++) {
		if (cur != p[i])P.push_back(i);
		cur = p[i];
	}
	if (cur != '0')P.push_back(i);
	cur = '0';
	for (i = 0; q[i]; i++) {
		if (cur != q[i])Q.push_back(i);
		cur = q[i];
	}
	if (cur != '0')Q.push_back(i);
	int Psz = P.size(), Qsz = Q.size();
	int res = 1e9;
	int sss = (n + 1) / 2 * 2;
	for (i = -sss; i <= sss; i+=2) {
		int s = 0;
		for (j = -5000; j <= 15000; j++) {
			int x, y;
			if (i + j < 0)x = 0;
			else if(i + j < Psz)x = P[i + j];
			else x = n;
			if (j < 0)y = 0;
			else if (j < Qsz)y = Q[j];
			else y = n;
			s += abs(x - y);
		}
		res = min(res, s);
	}
	printf("%d\n", res);
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = (int)(1e6) + 5;
int s[N];
int D1[20][N];
int D2[20][N];
int dp1[1 << 20];
int dp2[1 << 20];
int sum[N];
int main(void)
{
    int n,k;
    cin>>n>>k;
    int shit = k;
    int LG = 1;
    while (shit) ++LG,shit /= 2;
    for (int i = 1;i <= n;++i)
        cin>>s[i];
    for (int t = 0;t < LG;++t)
        {
            for (int i = n;i;--i)
                if (i == n || s[i + 1] - s[i] > (k >> t))
                    D1[t][i] = i;
                else
                    D1[t][i] = D1[t][i + 1];
            for (int i = 1;i <= n;++i)
                if (i == 1 || s[i] - s[i - 1] > (k >> t))
                    D2[t][i] = i;
                else
                    D2[t][i] = D2[t][i - 1];
            D1[t][n + 1] = n;
            D2[t][0] = 1;
        }
    const int N = 1 << LG;
    for (int mask = 0;mask < N;++mask)
    {
        dp1[mask] = 0;
        dp2[mask] = n + 1;
    }
    for (int mask = 1;mask < N;++mask)
        for (int i = 0;i < LG;++i)
            if ((mask >> i) & 1)
            {
                smax(dp1[mask],D1[i][dp1[mask ^ (1 << i)] + 1]);
                smin(dp2[mask],D2[i][dp2[mask ^ (1 << i)] - 1]);
            }
    for (int mask = 0;mask < N;mask += 2)
    {
        const int lf = D2[0][dp1[mask] + 1];
        const int rg = D1[0][dp2[(N - 1) ^ 1 ^ mask] - 1];
        if (D1[0][dp1[mask] + 1] < D2[0][dp2[(N - 1) ^ 1 ^ mask] - 1])
            continue;
        sum[lf] += 1;
        sum[rg + 1] -= 1;
    }
    for (int i = 1;i <= n;++i)
        sum[i] += sum[i - 1];
    for (int i = 1;i <= n;++i)
        if (sum[i])
            puts("Possible");
        else
            puts("Impossible");
    return 0;
}


Measured memory_bytes: 124032
while True:
    x=int(input())
    if x==0: break
    else:
        y=1000-x
        a=y//500
        y1=y-a*500
        b=y1//100
        y2=y1-b*100
        c=y2//50
        y3=y2-c*50
        d=y3//10
        y4=y3-d*10
        e=y4//5
        f=y4-e*5
        print(a+b+c+d+e+f)



Measured memory_bytes: 5584
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


// a,bの最小公倍数
ll lcm(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll gcd(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}
// MOD
ll modadd(ll a, ll b){return (a%MOD+b%MOD+MOD)%MOD;}
ll modmul(ll a, ll b){return a%MOD*b%MOD%MOD;}
ll modexp(ll a, ll n){if(n==0)return 1; if(n%2==0){ll e=modexp(a,n/2); return modmul(e,e);} return modexp(a,n-1)*a%MOD;}
ll modinv(ll n){return modexp(n%MOD,MOD-2);}
ll modfact(ll n){ll res=1; for (int i=1; i <= n; ++i){res *= i; res %= MOD;} return res;}
ll modncr(ll n, ll r){ll numer=1;ll denom=1;for(int i=1;i<=r;++i){numer=modmul(numer,n-r+i);denom=modmul(denom,i);}return modmul(numer, modinv(denom));}


int main(){

    int a;
    cin >> a;


    cout << 48 - a << endl;





}



//              g++ -std=c++1z


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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	vi c(n);
	vvi a(n, vi(m));

	rep(i, n) {
		cin >> c[i];
		rep(j, m) {
			cin >> a[i][j];
		}
	}

	ll ans = INF;
	for (int i = 1; i < (1 << n); ++i) {
		ll cost = 0;
		vi p(n);

		for (int j = 0; j < n; ++j) {
			if ((1 << j) & i) {
				cost += c[j];
				rep(k, m) {
					p[k] += a[j][k];
				}
			}
		}
		bool ok = true;
		for (int j = 0; j < m; ++j) {
			if (p[j] < x) {
				ok = false;
				break;
			}
		}

		if (ok) {
			ans = min(ans, cost);
		}
	}

	if (ans == INF) cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>

using namespace std;
using ll = long long;
const int BIG = 100000007;


int main() {
    ll n;
    cin >> n;
    ll cnt = 0;
    for(ll i = 0;i < n;++i){
        ll a;
        cin >> a;
        if(i % 2 == 0 && a % 2 == 1)++cnt;
    }
    cout << cnt << endl;
}




Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	private static final int K = 26;

	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var d = sc.nextInt();
		var c = new int[K];
		var s = new int[d][K];
		for (var i = 0; i < K; i++) {
			c[i] = sc.nextInt();
		}
		for (var i = 0; i < d; i++) {
			for (var j = 0; j < K; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		var t = new int[d];
		for (var i = 0; i < d; i++) {
			t[i] = sc.nextInt();
		}
		sc.close();

		for (var i = 0; i < d; i++) {
			var sum = score(c, s, t, i + 1);
			System.out.println(sum);
		}
	}

	private static int score(int[] c, int[][] s, int[] t, int d) {
		var sum = 0;
		var last = new int[K];
		for (var i = 0; i < d; i++) {
			var ti = t[i] - 1;
			sum += s[i][ti];
			last[ti] = i + 1;
			for (var j = 0; j < K; j++) {
				sum -= ((i + 1) - last[j]) * c[j];
			}
		}

		return sum;
	}
}


Measured memory_bytes: 46716
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
using vi  = vector<int>;
using ii  = pair<int,int>;
using vii = vector<ii>;
using ll  = long long;

typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) int((x).size())
#define REP(i, a, b) for (auto (i) = (a); (i) <= (b); (i)++)
#define PER(i, a, b) for (auto (i) = (a); (i) >= (b); (i)--)
#define ITR(i, x) for (auto (i) = (x).begin(); (i) != (x).end(); (i)++)

string to_string(string s) { return '\"' + s + '\"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A,B> p)
{ return "(" + to_string(p.F) + ", " + to_string(p.S) + ")"; }
template <typename T> string to_string(T v) {
	int f = 0; string res = "{";
	for (const auto &x: v)
		res += (f++ ? ", " : "") + to_string(x);
	return res + "}";
}
void debug_out() { cerr << "]\n"; }
template <typename T, typename... V>
void debug_out(T a, V... v)
{ cerr << to_string(a); if (sizeof...(v)) cerr << ", "; debug_out(v...); }

#ifdef LOCAL // add -DLOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = [", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif // debug(var1, var2, ...);

ll ans[10];
set<ii> colored;
int dx[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	ll h, w;
	int n;
	cin >> h >> w >> n;
	ans[0] = (h-2)*(w-2);
	REP(num, 0, n-1)
	{
		int x, y;
		cin >> x >> y;
		REP(i, 0, 8)
		{
			int cx = x + dx[i];
			int cy = y + dy[i];
			if (cx-1 <= 0) continue;
			if (cy-1 <= 0) continue;
			if (cx+1 > h) continue;
			if (cy+1 > w) continue;
			int cnt = 0;
			REP(d, 0, 8)
			{
				if (colored.count(ii(cx + dx[d], cy + dy[d])))
					cnt++;
			}
			ans[cnt]--;
			ans[cnt+1]++;
		}
		colored.emplace(x, y);
	}
	REP(i, 0, 9)
		cout << ans[i] << '\n';
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int V[N], C[N];
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    int sum = 0;
    for (int i = 0; i < N; i++) {
        if (V[i] - C[i] > 0) {
            sum += V[i] - C[i];
        }
        else {}
    }
    cout << sum << endl;
    return 0;
}


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

int main() {
  int n,k,x;
  cin >> n >> k;
  x = 1;
  
  for(int i = 0; i < n ; i++){
    if(x * 2 < x + k) x = x * 2;
    else x += k;
  }
  cout << x << endl;
}

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

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
struct edge
{
    long long to, cost;
};
using P = pair<int, int>;
int V;
const int MAX_V = 1e5 + 1;

vector<int> G[MAX_V];
vector<long long> d(MAX_V, INT_MAX);
int N, M;
vint ans(MAX_V, -1);
vint to(MAX_V,-1);
void dijkstra(int start)
{
    priority_queue<P, vector<P>, greater<P>> que;
    d[start] = 0;
    que.push(P(0, start));
    while (!que.empty())
    {
        P p = que.top();
        que.pop();
        long long v = p.second;
        if (d[v] < p.first)
        {
            continue;
        }
        for (int i = 0; i < G[v].size(); i++)
        {
            int e = G[v][i];
            if (d[e] > d[v] + 1)
            {
                d[e] = d[v] + 1;
                to[e]=v;
                que.push(P(d[e], e));
            }
        }
    }
}
void dfs(int now)
{
    if (ans[now] != -1)
        return;
    for (auto &&i : G[now])
    {
        if(d[now]> d[i])
        {
            ans[now]=i;
        }
    }
}
int main()
{

    cin >> N >> M;
    //    vvint graph(N);
    int a, b;
    for (size_t i = 0; i < M; i++)
    {
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dijkstra(0);
    for (size_t i = 0; i < N; i++)
    {
 //       dfs(i);
    }
    cout<<"Yes"<<endl;
    for (size_t i = 1; i < N; i++)
    {
        cout << to[i] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 12012
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		
		int mod = n % 10;
		
		if(mod == 3) {
			System.out.println("bon");
		}else if(mod == 0 || mod == 1 || mod == 6 || mod == 8) {
			System.out.println("pon");
		}else {
			System.out.println("hon");
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 32660
n, m = list(map(int, input().split()))
low =[]
high=[]

for i in range(m):
  temp = list(map(int, input().split()))
  low.append(temp[0])
  high.append(temp[1])
  
maxlow= max(low)
minhigh=min(high) 

if minhigh-maxlow >= 0:
  print(minhigh-maxlow+1)
else:
  print(0)

Measured memory_bytes: 11064
#include <iostream>

using namespace std;

int main()
{
	int d;
	while(cin >> d)
	{
		int integral = 0;
		for(int i = 0; i < 600 / d; i++)
		{
			int x =  i * d;
			int y = x * x;
			integral += y * d;
		}
	
		cout << integral << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  ll r, g, b;
  cin >> r >> g >> b;
  
  if ((10*g + b) % 4 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
const int N=5e3;

#define C getchar()-48
int read()
{
  int s=0,t=1,k=C;
  for (;k<0||9<k;k=C) if (k==-3) t=-1;
  for (;0<=k&&k<=9;k=C) s=(s<<1)+(s<<3)+k;
  return s*t;
}

  int t;
  int h[N];
  struct hh
    {
      int n,r;
    }e[N];
void ins()
{
  int x=read(),y=read(); 
  e[++t]=(hh){h[x],y},h[x]=t;
  e[++t]=(hh){h[y],x},h[y]=t;
}

  int n,K;
void in()
{
  cin>>n>>K;
  for (int i=0;++i<n;)
    ins();
}

  int B;
#define P(i) e[i].r
void dfs(int k,int F,int D)
{
  if (D>K/2) ++B;
  for (int i=h[k];i;i=e[i].n)
    if (P(i)^F)
      dfs(P(i),k,D+1);
}

  int A=1e9;
void wor()
{
  for (int i=0;++i<=n;)
		if (K&1)
		  for (int j=h[i];j;j=e[j].n)
			  {
			    B=0;
          dfs(i,P(j),0);
          dfs(P(j),i,0);
          A=min(A,B);
			  }
		else
		  {
			  B=0;	
				dfs(i,0,0);
				A=min(A,B);
			}
}

void out()
{
  cout<<A;
}

int main()
{
  in();
  wor();
  out();
  exit(0);
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int H = sc.nextInt();
		int W = sc.nextInt();
		System.out.println((N - H + 1) * (N - W + 1));
		
	}
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(void)
{
	char str[101];
	int i;
	int n;
	int j;
	
	while (scanf("%s", str) != EOF){
		for (i = 0; str[i] != '\0'; i++){
			if (str[i] == '@'){
				i++;
				n = str[i] - '0';
				i++;
				for (j = 0; j < n; j++){
					printf("%c", str[i]);
				}
			}
			else {
				printf("%c", str[i]);
			}
		}
		printf("\n");
	}
	
	return (0);
}

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

using namespace std;

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

    vector <pair<int,int> > v;

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

        v.push_back(make_pair(y,x));
    }

    sort(v.begin(),v.end());

    int count = 0;
    int ed = 1;

    for(int i=0;i<m;i++)
    {
        if(v[i].second >= ed)
        {
            count++;
            ed = v[i].first;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 1400
/*
  ___    ___             ___    __                   _     _   _
 |   \  /   |           |   \  |  |                 | |   (_) | |
 |    \/    |  _ __     |    \ |  |   __ _   _____  | |_   _  | | __
 |  |\  /|  | | '__|    |  |\ \|  |  / _' | |  ___) | __| | | | |/ /
 |  | \/ |  | | |    _  |  | \    | | (_| | |___  | | \_  | | |   /
 |__|    |__| |_|   (_) |__|  \___|  \__,_| (_____|  \__| |_| |_|\_\

 */

 #include<bits/stdc++.h>
 using namespace std;
 #define ll long long
 #define M 1000000007
 #define endl "\n"

 int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    ll c=__gcd(a,b);
    cout<<a*b/c;
 }



Measured memory_bytes: 256
N = int(input())
V = list(map(int,input().split()))
even = [0]*(10**5+10)
odd = [0]*(10**5+10)
for v in V[::2]:
  odd[v] += 1
for v in V[1::2]:
  even[v] += 1
omax = max(odd)
emax = max(even)
if(even.index(emax) != odd.index(omax)):
  print(N - emax - omax)
else:
  even.sort()
  odd.sort()
  print(min(N - even[-1] - odd[-2], N - even[-2] - odd[-1]))

Measured memory_bytes: 14396
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int n,i,a[100050];
int main(){
	memset(a,0,sizeof(a));
	scanf("%d",&n);
	int maxn=0;
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	for(i=0;i<n;i++){
		if(a[i]==a[i+1]){
			a[i]=0;a[i+1]=0;
		}
	}
	int ans=0;
	for(i=0;i<n;i++){
		if(a[i]!=0)
			ans++;
	}
	printf("%d\n",ans);
	return 0;
} 

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --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; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int D, T, S;
    cin >> D >> T >> S;

    if (D <= S * T) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
static const ll LL_MAX = (ll)1 << 55;

ll x[100001] = {};
int main()
{
	ll n, a, b;
	scanf("%lld%lld%lld", &n, &a, &b);

	ll ans = 0;
	scanf("%lld", &x[1]);
	repe(i, 2, n) {
		scanf("%lld", &x[i]);
		ans += min((x[i] - x[i - 1])*a, b);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 20)

ll cnt[MAXN];
int n;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		cnt[t]++;
	}
	ll sum = 0;
	for (int i = 0; i < MAXN; i++) {
		sum += i * cnt[i];
	}
	int q = 0;
	cin >> q;
	for (int i = 0; i < q; i++) {
		ll t1, t2;
		cin >> t1 >> t2;
		sum += (t2 - t1) * cnt[t1];
		cnt[t2] += cnt[t1];
		cnt[t1] = 0;
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 4308
N = int(input())
zoro = 0
ans = 'No'
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        zoro += 1
    else:
        zoro = 0

    if zoro == 3:
        ans = 'Yes'
        break

print(ans)

Measured memory_bytes: 62200
#include <iostream>
using namespace std;
int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a<=c and c<=b and b<=d) cout << b-c << endl; //acbd
	else if (c<=a and a<=d and d<=b) cout <<d-a<<endl;//cadb
	else if (c>=b) cout << 0 << endl;//ab - cd
	else if (a>=d)cout << 0 << endl;//cd - ab
	else if (a<=c and c<=d and d<=b) cout << d-c << endl; //a c d b
	else if (c<=a and a<=b and b<=d) cout << b-a << endl; //c a b d
	
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<iomanip>
using namespace std;

int m[16][16];
int main(){
    int n,y,x,cur;
    while(cin>>n,n){
        memset(m,0,sizeof(m));
        y=(n+1)/2;
        x=(n-1)/2;
        cur=1;
        m[y][x]=1;
        while(cur<n*n){
            y=(y+1)%n;
            x=(x+1)%n;
            cur+=1;
            while(m[y][x]>0){
                y=(y+1)%n;
                x=(x-1+n)%n;
            }
            m[y][x]=cur;
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++)
                cout<<setfill(' ')<<setw(4)<<m[i][j];
            cout<<endl;
        }
    }
}

Measured memory_bytes: 1172
MOD = 10**9+7

n,m = map(int,input().split())

fac = [1]*(m+1)
fac_inv =  [0]*(m+1)

for i in range(m):
    fac[i+1] = (fac[i] * (i+1)) %MOD
fac_inv[-1] = pow(fac[-1],MOD-2,MOD)
for i in range(m,0,-1):
    fac_inv[i-1] = (fac_inv[i] * i) % MOD
    
def comb(n,k):
    if k<0 or k>n:
        return 0
    x = (fac[n] * (fac_inv[k] * fac_inv[n-k])%MOD)%MOD
    return x


ans = 0
for i in range(n+1):
    ans += (-1)**(i%2) * comb(n,i) * (fac[m-i] * fac_inv[m-n] %MOD) % MOD
    ans %= MOD

ans *= comb(m,n)*fac[n] %MOD
ans %= MOD
    
print(ans)

Measured memory_bytes: 48180