akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

constexpr ll MOD = 1000000000 + 7;

// O(p): x^p
ll mpow(ll x, ll p) {
    if (p == 1) { return x % MOD; }
    if (p % 2) { return (x * mpow(x, p - 1)) % MOD; }
    ll sub = mpow(x, p / 2);
    return (sub * sub) % MOD;
}

// O(l): x(x-1)...(x-l+1)
ll mfactorial(ll x, ll l) {
    if (x == 0) { return 1; }
    ll ans = 1;
    rep(i, 0, l) { ans = (ans * (x - i)) % MOD; }
    return ans;
}

ll madd(ll x, ll y) { return (x + y) % MOD; }

ll msub(ll x, ll y) { return (x - y + MOD) % MOD; }

ll mmul(ll x, ll y) { return (x * y) % MOD; }

ll combination(ll n, ll r, const vll& fac, const vll& inv) {
    if (r == 0) { return 1; }
    if (r == 1) { return n % MOD; }
    ll ans = mmul(fac[n], inv[r]);
    return mmul(ans, inv[n - r]);
}

int main() {
    ll n, k;
    cin >> n >> k;

    vll fac(n + 1, 0);
    fac[0] = 1;

    ll f = 1;
    rep(i, 1, n + 1) {
        f = mmul(f, i);
        fac[i] = f;
    }

    vll inv(n + 1, 0);
    inv[n] = mpow(fac.back(), MOD - 2);
    rrep(i, 0, n) { inv[i] = mmul(inv[i + 1], i + 1); }

    ll ans = 0;
    ll m = min(k + 1, n);

    rep(i, 0, m) {
        if (i == 0) {
            ans = madd(ans, 1);
        } else {
            ll tmp = mmul(combination(n, i, fac, inv), combination(n - 1, i, fac, inv));
            ans = madd(ans, tmp);
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
  double X;
  cin >> X;
  int x = static_cast<int>(sqrt(X));
  int max = 1;
  for (int i = 2; i <= x; ++i)
  {
    int p = i*i;
    while (p <= X)
    {
      if (X < p*i)
        break;
      else
        p *= i;
    }
    if (max < p)
      max = p;
  }
  cout << max;
  return 0;
}


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

int main(){
	int N, M, L, R, i;
	scanf("%d%d", &N, &M);
	int lmax = 1, rmin = N;
	for(i = 0; i < M; i++){
		scanf("%d%d", &L, &R);
		lmax = max(lmax, L);
		rmin = min(rmin, R);
	}
	printf("%d\n", max(rmin - lmax + 1, 0));
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()

num = [0] * 100001

for i in a:
    num[i] += 1

for i in range(100001):
    if num[i] > 1:
        num[i] = 1

sum_num = sum(num)

if sum_num % 2 == 0:
    print(sum_num - 1)
else:
    print(sum_num)

Measured memory_bytes: 14396
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextInt();
		double b = sc.nextInt();
		double ans = (a + b) / 2;
		ans = Math.ceil(ans);
		int i = (int)ans;
		System.out.print(i);
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int d=a+b+c;
        int ma=Math.max(Math.max(a,b),c);
        int mi=Math.min(Math.min(a,b),c);
        System.out.printf("%d %d %d\n",mi,d-ma-mi,ma);
    }
}


Measured memory_bytes: 26180
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ll q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;
  h = min(h, 2 * q);
  s = min(s, 2 * h);
  d = min(d, 2 * s);
  n *= 4;
  ll tot = 0;
  tot += n / 8 * d; n %= 8;
  tot += n / 4 * s; n %= 4;
  tot += n / 2 * h; n %= 2;
  tot += n * q;
  cout << tot << endl;
}


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

int main() {
    int k;
    vector<int> pos(5);
    rep(i, 5) cin >> pos.at(i);
    cin >> k;
    sort(pos.begin(), pos.end());
    if(pos.at(4) - pos.at(0) > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
map<string ,int >s;
string b;
map<int ,string>s1;
int main()
{
	int n,k=1,m=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>b;
		if(s[b]==0)
		{
			s1[k]=b;
			k++;
		}
		s[b]++;
	}
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>b;
		s[b]--;
	}
	for(int i=1;i<=k;i++)
	 {
	 	if(s[s1[i]]>m)
	 	m=s[s1[i]];
	 }
	 cout<<m;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long long int li;
const ll MAXN=2e6+51,MOD=1e9+7;
ll r1,r2,c1,c2,res;
ll fact[MAXN],finv[MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
} 
inline ll qpow(ll base,ll exponent)
{
    ll res=1;
    while(exponent)
    {
        if(exponent&1)
        {
            res=(li)res*base%MOD;
        }
        base=(li)base*base%MOD,exponent>>=1;
    }
    return res;
}
inline void setup(ll cnt)
{
	fact[0]=fact[1]=finv[0]=1;
	for(register int i=2;i<=cnt;i++)
	{
		fact[i]=(li)fact[i-1]*i%MOD;
	}
	finv[cnt]=qpow(fact[cnt],MOD-2);
	for(register int i=cnt-1;i;i--)
	{
		finv[i]=(li)finv[i+1]*(i+1)%MOD;
	}
}
int main()
{
	setup(2000010),r1=read(),c1=read(),r2=read(),c2=read();
	for(register int i=r1;i<=r2;i++)
	{
		res=(res+(li)fact[i+c2+1]*finv[i+1]%MOD*finv[c2]%MOD)%MOD;
		res=(res-((li)fact[i+c1]*finv[i+1]%MOD*finv[c1-1]%MOD)+MOD)%MOD;
	}
	printf("%d\n",res);
}

Measured memory_bytes: 15872
import java.util.*;
public class Main {
      public static void main(String[]args) {
    	  Scanner scan=new Scanner(System.in);
    	  int x=scan.nextInt();
    	  int a=scan.nextInt();
    	  int b=scan.nextInt();
    	  System.out.print((x-a)%b);
      }
}

Measured memory_bytes: 21844
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    long long a, b, c, d;
    cin >> a >> b >> c >> d;

    long long res = a * c;
    for (auto x : {a, b}) {
        for (auto y : {c, d}) {
            res = max(res, x * y);
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    lint n,x;
    cin>>n>>x;
    vec a(n);
    rep(i,n)cin>>a[i];
    lint cnt=0;
    rep(i,n-1){
        if(x<a[i]+a[i+1]){
            cnt+=a[i]+a[i+1]-x;
            a[i+1]-=a[i]+a[i+1]-x;
            a[i+1]=max(0LL,a[i+1]);
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 1024
'use strict'

function main(input) {
  const inputList = input.split('\n');
  const n = inputList[0]
  const list = inputList.slice(1)
  let result = true 

  let prevt = 0
  let prevx = 0
  let prevy = 0
  let nextt = 0
  let nextx = 0
  let nexty = 0

  for (let i=0; i<list.length; i++) {
    const tmpList = list[i].split(' ')
    nextt = tmpList[0]
    nextx = tmpList[1]
    nexty = tmpList[2]

    const difft = nextt - prevt
    const diffx = nextx - prevx 
    const diffy = nexty - prevy
    const tmp = difft - (diffx+diffy)
    if ( tmp<0 || tmp%2 === 1) {
      result = false 
      break
    }
  }

  if (result) {
    console.log('Yes')
  } else {
    console.log('No')
  }
}

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

Measured memory_bytes: 29944
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N
#math.ceilで切り上げ
#dp = [[0] * 4 for i in range(3)] #2次元配列初期化
#dp = [[[0] * 2 for i in range(3)] for j in range(5)]
#(ord('A'))でASCII出力 Aは65
import math
import string

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

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

N = intinput()
A = listintinput()
flag = 0
for i in A:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 == 0:
            continue
        else:
            flag = 1

if flag == 0:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 3896
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    if(S == "Sunny") cout << "Cloudy" << endl;
    if(S == "Cloudy") cout << "Rainy" << endl;
    if(S == "Rainy") cout << "Sunny" << endl;
}

 

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

int main (){
    int n;
    cin>>n;
    string s;
    cin>>s;
    char last=s[0];
    int i,c=1;
    //char a,b;
    for(i=1;i<n;i++,c++){
            //a=s[i].c_str();
            //b=s[i-1]c_str();
            if(s[i]==last){
                c--;
            }
            last=s[i];
        
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
typedef priority_queue<int> p_queue;
typedef long long ll;
int read(){
	char c=getchar();
	int sum=0;
	while(c>'9'||c<'0')c=getchar();
	while(c<='9'&&c>='0')sum=sum*10+c-'a',c=getchar();
	return sum;
}
string s;
int n;
int res;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	cin>>s;
	s=s+'*';
	s=s+'*';
	s=s+'*';
	s=s+'*';
	int i=0;
	while(i<s.size()){
		if(s[i]=='*'){
			cout<<res;
			return 0;
		}
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')res++,i+=3;
		else i++;
	}
	cout<<res;
	return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, 0, N) {
    cin >> L[i];
  }
  sort(L.begin(), L.end());

  int ans = 0;

  rep(i, 0, N) {
    int b = L[i];
    rep(j, i + 1, N) {
      int c = L[j];
      int plus = lower_bound(L.begin() + j + 1, L.end(), b + c) - lower_bound(L.begin() + j + 1, L.end(), abs(b - c));
      ans += plus;
    }
  }

  cout << ans << endl;
};


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <set>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <cassert>

using namespace std;
using ll = long long;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define nl "\n"

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

	int n;
	cin >> n;
	int x[n];
	for(int i = 0; i < n; i++) {
		cin >> x[i];
	}
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		bool ans = true;
		for(int j = 0; j < i; j++) {
			if(x[j] > x[i]) {
				ans = false;
			}
		}
		if(ans) {
			cnt++;
		}
	}
	cout << cnt << nl;
}

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

int main(){
  int n,m,ans=1;cin>>n>>m;
  bool f=0;

  for(int i=2;i*i<=m;i++) if(!(m%i)){
    f=1;
    break;
  }
  
  if(f) for(int i=n;i<=m;i++) if(!(m%i)){
    cout<<m/i;
    return 0;
  }
  cout<<"1";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(...) { printf("#  "); printf(__VA_ARGS__); puts(""); }
#define fi first
#define se second
#define endl "\n" 
using ll = long long;
using pII = pair <int, int>;
using pLL = pair <ll, ll>;
using VI = vector <int>;
using VL = vector <ll>;
constexpr int mod = 1e9 + 7;
template <class T1, class T2> inline void chadd(T1 &x, T2 y) { x += y; while (x >= mod) x -= mod; while (x < 0) x += mod; } 
template <class T1, class T2> inline void chmax(T1 &x, T2 y) { if (x < y) x = y; }
template <class T1, class T2> inline void chmin(T1 &x, T2 y) { if (x > y) x = y; }
inline int rd() { int x; cin >> x; return x; }
template <class T> inline void rd(T &x) { cin >> x; }
template <class T> inline void rd(vector <T> &vec) { for (auto &it : vec) cin >> it; }
template <class T> inline void out(T s) { cout << s << "\n"; }
template <class T> inline void out(vector <T> &vec) { for (auto &it : vec) cout << it << " "; cout << endl; } 
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll qpow(ll base, ll n) { ll res = 1; while (n) { if (n & 1) res = res * base % mod; base = base * base % mod; n >>= 1; } return res; }
constexpr int N = 1e5 + 10;
string t;
void run() {
	string s[3] = {
		"Sunny",
		"Cloudy",
		"Rainy"
	};
	for (int i = 0; i < 2; ++i) if (t == s[i]) return out(s[i + 1]);
	cout << s[0] << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cout << fixed << setprecision(20);
	while (cin >> t) run();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  X--, Y--;

  vector<vector<int>> table(N, vector<int>(N));
  rep(i, N) {
    repp(j, i + 1, N - 1) {
      table[i][j] = min({j - i, abs(X - i) + 1 + abs(Y - j)});
    }
  }

  vector<int> dist(N);
  rep(i, N) {
    repp(j, i + 1, N - 1) {
      dist[table[i][j]]++;
    }
  }

  rep(i, N) {
    if (i == 0)
      continue;
    cout << dist[i] << endl;
  }
}

Measured memory_bytes: 31616
#include<iostream>
#include <iomanip>
using namespace std;
int main()
{
  int N;
  cin >> N;
  cout << std::fixed;
  if(N%2==0){
    double n=1.0/2.0; 
    cout << setprecision(10) << n;
  }
  else {
    double n=(N/2+1);
    n=n/N;
    cout << setprecision(10) << n;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,m;
int l,r,d;
vector<Pi> v[100100];
int dis[100100];
int ans=1;
int main(){
	cin>>n>>m;
	REP(i,100100)dis[i]=-INF;
	for(int i=0;i<m;i++){
		cin>>l>>r>>d;
		v[l].push_back(Pi(r,d));
		v[r].push_back(Pi(l,-d));
	}
	queue<int> q;
	for(int i=1;i<=n;i++){
		if(dis[i]!=-INF)continue;
		while(q.size())q.pop();
		dis[i]=0;
		q.push(i);
		while(q.size()){
			int t=q.front();q.pop();
			for(int j=0;j<v[t].size();j++){
				Pi next=v[t][j];
				if(dis[next.first]==-INF){
					dis[next.first]=dis[t]+next.second;
					q.push(next.first);
				}else{
					if(dis[next.first]!=dis[t]+next.second){
						ans=0;
					}
				}
			}
		}
	}
	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 13440
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

S = input()
'''
s_cnt = 0
for m in S:
    if m == 'S':
        s_cnt += 1
    elif m == 'T' and s_cnt > 0:
        s_cnt -= 1

print(2 * s_cnt)
'''
from collections import deque
ans = deque()
for m in S:
    if m == 'S':
        ans.append(m)
    elif m == 'T':
        if ans and ans[-1] == 'S':
            ans.pop()
        else:
            ans.append(m)
print(len(ans))

Measured memory_bytes: 5092
import std.stdio;
import std.algorithm;
import std.math;
import std.string;
import std.conv;
import std.range;

void main() {
    while (true) {
        int l = readln.chomp.to!int;
        if (l == 0) break;

        int[][] ary;
        for (int i = 0; i < 12; i++) {
            ary ~= readln.chomp.split.map!(to!int).array;
        }

        int sum = 0;
        int month = 0;
        foreach (int i, e; ary) {
            sum += e[0] - e[1];
            if (sum >= l) {
                month = i + 1;
                break;
            }
        }

        writeln(month == 0 ? "NA" : month.to!string);
    }
}

Measured memory_bytes: 2024
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
	FIO
	ll x,y;
	cin>>x>>y;
	if(x==1||y==1)cout<<1;
	else
	cout<<(x*y+1)/2;
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;

int main() {
  int n,m;
  cin>>n>>m;
  priority_queue<int, vector<int>, greater<int>> a;
  vector<P> cb(m);
  rep(i,n){
    int w;
   cin>>w;
    a.push(w);
  }
  rep(i,m) {
    cin>>cb[i].second>>cb[i].first;
  }
  //////////
  sort(all(cb));
  reverse(all(cb));
  rep(i,m){
   int mn=a.top(); 
    int cnt=0;
    while(mn<cb[i].first&&cnt<cb[i].second){
      cnt++;
      a.pop();
      a.push(cb[i].first);
      mn=a.top();
    }
  }
  //
  ll ans=0;
  rep(i,n){
    ans+=a.top();
    //cout<<ans<<endl;
    a.pop();
  }
  cout<<ans<<endl; 
}

Measured memory_bytes: 1660
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

S = int(input())

# 数列の長さが k の場合何通りになるかを考える
# k 個の区別する箱と S 個の区別しない玉があって、 S 個のうち、 3*k 個はすでにそれぞれの箱に 3 個ずつ入っている状況
# ここから、残りの S-3*k 個の玉を k 個の箱のどれかに入れる場合の個数が combination(S-2*k-1, S-3*k) 通り
# これを k = 1, 2, ..., S//3 で計算して足していく

ans = 0
for k in range(1, S//3+1):
    ans += cmb(S - 2*k - 1, S - 3*k, p)

print(ans%p)



Measured memory_bytes: 127648
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			int a = sc.nextInt();
			int taro = 0;
			int hanako = 0;
			
			for(int b=0;b<a;++b){
				String c = sc.next();
				String d = sc.next();
				int e ;
				if(c.length()<d.length()){
					e=c.length();
				}else{
					e=d.length();
				}
				for(int f=0;f<e;++f){
					char g = c.charAt(f);
					char h = d.charAt(f);
					if(g>h){
						taro += 3;
						break;
					}else if(g<h){
						hanako += 3;
						break;
					}else if(g==h){
						if(f==e-1){
							if(c.length()>d.length()){
								taro += 3;
							}else if(c.length()<d.length()){
								hanako += 3;
							}else{
								taro +=1;
								hanako +=1;
							}
						}
					}
				}
			}
			System.out.println(taro + " " + hanako);
	}

}

Measured memory_bytes: 30044
#include <iostream>
using namespace std;
 
int main(){
 
 for(int y = 1; y < 10; y++){
  for(int x = 1; x < 10; x++){
   cout << y << "x" << x << "=" << x*y << endl;
    
  }
 }
 
 return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}



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

    int k, x;
    cin >> k >> x;
    if (k*500 >= x) {
        cout << "Yes";
    } else {
        cout << "No";
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);
 
 
vector<int> l;
int A, B, C;
int N;

int dfs(int cur, int a, int b, int c) {
  // a, b, c: A,B,Cの素体になる竹の長さ
  if(cur==N) {
    if(min(a, min(b,c))==0) return 100000; // 材料0はNG
    else return abs(a-A) + abs(b-B) + abs(c-C) - 30; // 0個から1個目を加える時のコストはないのでその分を引く
  } else {

    int ret0 = dfs(cur+1, a, b, c); // l[cur] を使用しない
    int ret1 = dfs(cur+1, a + l[cur], b, c) + 10; // l[cur]を Aの材料に加える
    int ret2 = dfs(cur+1, a, b + l[cur], c) + 10; // l[cur]を Bの材料に加える
    int ret3 = dfs(cur+1, a, b, c + l[cur]) + 10; // l[cur]を Cの材料に加える

    return min(min(ret0, ret1), min(ret2, ret3));
  }
}

int main() {
  cin >> N >> A >> B >> C;

  l.resize(N);
  rep(i, N) cin >> l[i];

  cout << dfs(0, 0, 0, 0) << endl;

  return 0;
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A;
    cin >> A;
    ll N = A.size();
    ll dp[200010];
    rep(i,0,N) dp[i] = INF;
    vector<ll> pos[27];
    rep(i,0,N) pos[A[i]-'a'].push_back(i);
    dp[N] = 1;
    map<ll, pair<char, ll> > mp;
    rrep(i,N-1,0){
        rep(c,0,26){
            ll p = lower_bound(pos[c].begin(), pos[c].end(), i) - pos[c].begin();
            if(p == pos[c].size()){
                if(dp[i] > 1){
                    mp[i] = {(char) ('a' + c), N};
                    // print(i,c);
                }
                dp[i] = min(dp[i], 1LL);
                continue;
            }
            ll nxt = pos[c][p];
            // print(nxt);
            if(dp[i] > dp[nxt+1] + 1){
                mp[i] = {(char)('a' + c), nxt+1};
            }
            dp[i] = min(dp[i], 1 + dp[nxt+1]);
        }
    }
    // rep(i,0,N+1) print(mp[i].first, mp[i].second);
    // printa(dp, N+1);
    string ans = "";
    ll cur = 0;
    while(cur < N){
        auto lp = mp[cur];
        ans += lp.first;
        cur = lp.second;
    }
    print(ans);
    // while(cur != N){
    //     rep(c,0,26){
    //         ll p = lower_bound(pos[c].begin(), pos[c].end(), cur) - pos[c].begin();
    //     }

    // }


    

}

Measured memory_bytes: 16148
N, A, B = map(int, input().split())
if A > B or (N == 1 and A < B):
    print(0)
    exit()
if N == 1 and A == B:
    print(1)
    exit()
mx = A+B+B*(N-2)
mn = A+B+A*(N-2)
print(mx-mn+1)


Measured memory_bytes: 2940
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

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

func main() {
	n, d := nextInt(), nextInt()

	var ans int
	i := d + 1
	for {
		ans++
		end := i + d
		if end >= n {
			fmt.Println(ans)
			return
		}
		i = end + 1 + d
		// if i >= n {
		// 	fmt.Println(ans)
		// 	return
		// }
	}
}


Measured memory_bytes: 640
#include <iostream>

#define MAX 100001
#define NIL -1

using namespace std;

struct Node { int parent, left, right; };

void print(int i, Node arr[], int ds[]) {
    cout << "node " << i << ": ";
    cout << "parent = " << arr[i].parent;
    cout << ", depth = " << ds[i];
    cout << ", ";
    
    if (arr[i].parent == NIL) cout << "root";
    else if (arr[i].left == NIL) cout << "leaf";
    else cout << "internal node";
    cout << ", [";
    
    if (arr[i].left != NIL) {
        int current = arr[i].left;
        cout << current;
        
        while (arr[current].right != NIL) {
            current = arr[current].right;
            cout << ", " << current;
        }
    }
    cout << "]" << endl;
}

void depth(int n, int d, Node nodes[], int ds[]) {
    ds[n] = d;
    if (nodes[n].right != NIL) depth(nodes[n].right, d, nodes, ds);
    if (nodes[n].left != NIL) depth(nodes[n].left, d+1, nodes, ds);
}

int main() {
    int n, id, k, c, root;
    Node T[MAX];
    int D[MAX];
    
    cin >> n;
    for (int i=0; i<n; i++) T[i].parent = T[i].left = T[i].right = NIL;
    
    for (int i = 0; i < n; i++) {
        cin >> id >> k;
        
        int left;
        for (int j = 0; j < k; j++) {
            cin >> c;
            if (j == 0) T[id].left = c;
            else T[left].right = c;
            T[c].parent = id;
            left = c;
        }
    }
    
    for (int i=0; i<n; i++) {
        if (T[i].parent == NIL) {
          root = i;
          break;
        }
    }
    
    depth(root, 0, T, D);
    
    for (int i=0; i<n; i++) print(i, T, D);
    return 0;
}


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

#include <iostream>
using namespace std;
int main() {
  int64_t x;
  cin >> x;
  int64_t a, b;
  bool is_end = false;
  for (int64_t i = -118; i < 119; ++i) {
    auto temp = pow(i, 5);
    for (int64_t j = -119; j < i; ++j) {
      if (x == temp - pow(j, 5)) {
        a = i;
        b = j;
        is_end = true;
        break;
      }
    }
    if (is_end) {
      break;
    }
  }
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 4060
#include<stdio.h>
#include<ctype.h>
int main(){
  int c;
  int cnt[500]={0};
  while(c!=EOF){
    c=getchar();
    if(islower(c)){
      cnt[c]++;
    }else{
      cnt[c+32]++;
    }
  }
  for(c='a';c<='z';c++){
    printf("%c : %d\n",c,cnt[c]);
  }
  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

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

int N,Q;
int A[111111];

int sufsum[111111];
int presum[111111];
void solve(){
	int X;cin>>X;

	int lb=0,ub=N;
	while(ub-lb>1){
		int mid=(ub+lb)/2;
		bool ok=true;
		if(X>=A[mid])ok=false;
		else{
			int d=A[mid]-X;
			int num=mid-(lower_bound(A,A+N,X-d)-A);
			if(num<=N-1-mid)ok=false;
		}
		if(ok)ub=mid;
		else lb=mid;
	}

	int ans=sufsum[ub];
	if((N-ub)*2>=N){
		cout<<ans<<endl;
		return;
	}
	int d=A[lb]-X;
	int num=lb-(lower_bound(A,A+N,X-d)-A);
	if(num==N-1-lb){
		ans+=A[lb];
		ans+=presum[max(N-(N-lb)*2,0ll)];
	}
	else{
		ans+=presum[N-(N-ub)*2];
	}
	cout<<ans<<endl;
}

signed main(){
	cin>>N>>Q;
	rep(i,N)cin>>A[i];
	for(int i=0;i<N;i++){
		if((N-i)&1)presum[i+1]+=A[i];
		presum[i+1]+=presum[i];
	}

	for(int i=N-1;i>=0;i--)sufsum[i]=sufsum[i+1]+A[i];
	while(Q--)solve();
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ

signed main(){
    int a,b; cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << endl;
}




Measured memory_bytes: 3532
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()

ans = 0
if N%2 == 0:
    c1, c2 = A[N//2-1], A[N//2]
    del A[N // 2-1]
    del A[N // 2-1]
    for a in A:
        ans += abs(a-c1)*2
    ans += c2-c1
else:
    c = A[N//2]
    c1, c2 = A[N//2-1], A[N//2+1]
    ans -= min(abs(c-c1), abs(c-c2))
    for a in A:
        ans += abs(a-c) * 2
print(ans)


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

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

ll LCM(ll a, ll b) {
	return a / GCD(a, b)*b;
}

ll mypow(ll a, ll b, ll c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	else return mypow(a, b / 2, c)*mypow(a, b / 2, c) % c;
}

ll longmax(ll a,ll b){
	if(a>b) return a;
	else return b;
}

ll longmin(ll a,ll b){
	if(a<b) return a;
	else return b;
}

int c[100010]={},d[100010]={};

signed main(){
	int a,x[100000],z=0,zz,zzz=0,zzzz;
	cin>>a;
	f(i,a){
		cin>>x[i];
	}
	for(int i=0;i<a;i+=2){
		c[x[i]]++;
		if(z<c[x[i]]){
			z=c[x[i]];
			zz=x[i];
		}
	} 
	for(int i=1;i<a;i+=2){
		d[x[i]]++;
		if(zzz<d[x[i]]){
			zzz=d[x[i]];
			zzzz=x[i];
		}
	}
	if(zz==zzzz){
		int e[100010]={},f[100010]={};
		int z0=0,z1,z2,z3=0;
		for(int i=0;i<a;i+=2){
			e[x[i]]++;
			if(z0<e[x[i]]&&x[i]!=zz){
				z0=e[x[i]];
				z1=x[i];
			}
		}
		for(int i=1;i<a;i+=2){
			f[x[i]]++;
			if(z3<f[x[i]]&&x[i]!=zzzz){
				z3=f[x[i]];
				z2=x[i];
			}
		}
		cout<<a-max(z0+zzz,z3+z)<<endl;
	} 
	else cout<<a-zzz-z<<endl;
	return 0;
}


Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		double a = sc.nextDouble();
		double b = sc.nextDouble();

		if (a > b) {

			System.out.println("GREATER");

		} else if (a < b) {

			System.out.println("LESS");

		} else if (a == b) {

			System.out.println("EQUAL");

		}

	}
}


Measured memory_bytes: 23124
#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 N; cin >> N;
    vector<string> S;
    rep(i, N){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        S.push_back(s);
    }
    sort(S.begin(), S.end());

    int i = 1;
    ll counter = 1;
    ll ans = 0;
    while(i < N){
        if(S[i] == S[i-1]){
            counter++;
        } else {
            ans += (counter * (counter-1)) / 2;
            counter = 1;
        }
        i++;
    }
    ans += (counter * (counter-1)) / 2;

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 5748
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, ans, now = MINF;

int main() {
	cin >> n;
	vector<P> s(n);
	REP(i, n) {
		ll a, b;
		cin >> a >> b;
		s[i] = P(a + b, a - b);
	}
	sort(ALL(s));
	REP(i, n) {
		if (s[i].second >= now) {
			ans++;
			now = s[i].first;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
def solve():
    n, k, q = map(int, input().split())
    a = []
    for i in range(n):
        a.append(0)
    for i in range(q):
        aa = int(input()) - 1
        a[aa] = a[aa]+1
    for i in range(n):
        if k - (q-a[i]) > 0:
            print('Yes')
        else:
            print('No')

if __name__ == "__main__":
    solve()
    

Measured memory_bytes: 4620
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

//互除法
ll gcd(ll a, ll b){
	if (a < b){
		return gcd(b, a);
	}else if (a % b){
		return gcd(b, a % b);
	}else{
		return b;
	}
}

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

	int N;
	int ans;
	cin >> N >> ans;

	for (int i = 0; i < N-1; i++) {
		int tmp;
		cin >> tmp;
		ans = gcd(ans, tmp);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int a,b,c[5],ans=0;
	cin>>a>>b;
	loop(i,a,b+1){
		int num=i,tmp=10000;
		for(int j=4;j>=0;j--){
			c[j]=num/tmp;
			num%=tmp;
			tmp/=10;
		}
		if((c[0]==c[4])&&(c[1]==c[3]))ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict


n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]


dic=defaultdict(int)
for i in range(n):
    dic[s[i]]+=1

for i in range(m):
    dic[t[i]]-=1

ans=0
for i in dic.values():
    ans=max(ans,i)
print(ans)

Measured memory_bytes: 65348
n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
ans = [0, 0]
i = j = 0
while i + 1 < n:
    if a[i] == a[i+1]:
        ans[j] = a[i+1]
        j += 1
        i += 2
        if j == 2: break
    else: i += 1
print(int(ans[0]*ans[1]))

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

using namespace std;

int main(){
 long h,w; 
  cin >> h >> w;
  
 long a[h][w];
  for(int i=0;i<h;i++){
   for(int j=0;j<w;j++) cin >> a[i][j];
  }
  
  vector<tuple<long,long,long,long>> v;
   
  for(int i=0;i<h;i++){
   for(int j=0;j<w-1;j++){
     if(a[i][j]%2){ a[i][j]--;
                    a[i][j+1]++;
                   v.push_back(make_tuple(i+1,j+1,i+1,j+2));
                  }   
   }   
  } 
  
  for(int i=0;i<h-1;i++){
    if(a[i][w-1]%2){ a[i][w-1]--;
                    a[i+1][w-1]++;
                   v.push_back(make_tuple(i+1,w,i+2,w));
                  }   
  }
  
  cout << v.size() << endl;
  for(int i=0;i<v.size();i++) cout << get<0>(v[i]) << " " << get<1>(v[i]) << " " << get<2>(v[i]) << " " << get<3>(v[i]) << endl;  
  
}


Measured memory_bytes: 8432
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

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

int main() {
	int n, m;
	string s, t;
	cin >> n >> m >> s >> t;
	for (int i = 0;i < gcd(n, m);i++) {
		if (s[n / gcd(n, m)*i] != t[m / gcd(n, m)*i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << (long long)n / gcd(n, m)*m << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 512
using AtCoderBeginnerContest123.Questions;
using AtCoderBeginnerContest123.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest123.Questions
{
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var people = inputStream.ReadLong();
            var capacities = new long[5];

            for (int i = 0; i < 5; i++)
            {
                capacities[i] = inputStream.ReadLong();
            }

            var neckCapacity = capacities.Min();

            yield return Math.Ceiling((decimal)people / neckCapacity) + 4;
        }
    }
}


namespace AtCoderBeginnerContest123
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest123.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest123.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <stdio.h>

using namespace std;

int main(void)
{
    int x;
    
    for (int i = 1; true; ++i) {
        scanf("%d", &x);
        if (x == 0) {
            break;
        }
        printf("Case %d: %d\n", i, x);
    }
    
    return 0;
}


Measured memory_bytes: 2680
#define NguyenDangQuan the_author

#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define mset(x, i) memset(x,i,sizeof(x))
#define elif else if
#define heap priority_queue
#define fi first
#define se second
#define pb push_back
#define ld long double
#define ll long long
#define ull unsigned long long
#define task ""
using namespace std;

int typetest;
template<class T>
void read(T &x){
    register int c;
    T neg = 1;
    x = (T)0;
    while ((c = getchar()) <= 47 || c >= 58)
		if(c == '-') neg = -1;
    for (; (c > 47 && c < 58); c = getchar()){
        x = (x << 3) + (x << 1) + (T)(c - 48);
    }
	x *= neg;
}
inline void fastIOfileinput(){
	ios_base:: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	freopen(task".INP", "r", stdin);
//	freopen(task".OUT", "w", stdout);
//	freopen(task".in", "r", stdin);
//	freopen(task".out", "w", stdout);
	typetest = 0;
}

const int N = 1e5 + 2;
const ll mod = 1e9 + 7;
int n, k;

ll mul(ll a, ll b){
	if(!(b ^ 0))
		return 0;
	ll t = mul(a, b >> 1) % mod;
	if(b & 1)
		return ((t << 1) % mod + a) % mod;
	return (t << 1) % mod;
}

void Enter(){
	read(n);
	read(k);
}
void Solve(){
	ll ans = 0;
	for(int i = k; i <= n + 1; ++i)
		ans = (ans + mul(i, n - i + 1) + 1) % mod;// cerr << i << " " << mul(i, n + 1 - i + 1) << "\n";
	cout << ans;
}

signed main(){
	fastIOfileinput();
	if(typetest){
		int t;
		cin >> t;
		while(t--){
			Enter();
			Solve();
		}
	}
	else{
		Enter();
		Solve();
	}
}


Measured memory_bytes: 3664
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,k,q,a,i,y[100000]={0};
	scanf("%d%d%d",&n,&k,&q);
	for(i=0;i<q;i++){
		scanf("%d",&a);
		y[a-1]++;
	}
	for(i=0;i<n;i++){
		if(k-q+y[i]>0) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2052
#include<iostream>
using namespace std;
int main()
{
	int n,a[100],i,x=0;
	cin>>n;
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=0;i<n;i++)
	{
		if(a[i]%2==0){
			if(a[i]%3!=0&&a[i]%5!=0){
				cout<<"DENIED";
				x++;
				break;
			}
		}
		
	}
	if(x==0)
	cout<<"APPROVED";
 } 

Measured memory_bytes: 256