akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dbg(x) cerr << #x << " : " << x << endl;
int main(){

    int n;
    cin >> n;
    vector<int> a(n+1);
    
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    int sthg=0;
    for(int i=1;i<=n-1;i++){
        if(i&1) sthg-=a[i];
        else sthg+=a[i];
    }
    vector<int> ans(n);
    ans[0]=a[n] - sthg;
    for(int i=1;i<n;i++){
        ans[i] = 2*a[i]-ans[i-1];
    }
    for(int x:ans) cout << x << " " ;
    cout << endl;
    return 0;
}

Measured memory_bytes: 2048
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();
		if (16 / a < 2 || 16 / b < 2) {
			System.out.println(":(");
		} else {
			System.out.println("Yay!");
		}
	}
}

Measured memory_bytes: 23636
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>//可爱的头文件 
using namespace std;
int n,t[100005],ans=-1;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		t[x]++;
	}
	for(int i=1;i<=100000;i++)
	{
		ans=max(ans,t[i-1]+t[i]+t[i+1]);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
# 2020/07/26
# AtCoder Beginner Contest 153 - C

# Input
n, k = map(int,input().split())
h = list(map(int,input().split()))

# 降順にソート
h.sort()
h.reverse()
ans = 0

for i in range(n):
    # K回まで必殺技を使う
    if i < k:
        continue
    else:
        ans = ans + h[i]

# Output
print(ans)


Measured memory_bytes: 31492
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define Rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)

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

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//べき//
ll squ(ll n, ll p, ll m){
	if(p==0) return 1;
	if(p%2==0){
		ll t=squ(n, p/2, m);
		return t*t%m;
	}
	return n*squ(n,p-1,m);
	
}


//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nが大

ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}


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


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

int n=s.size();
int ans=0;
for(int i=1;i<=n/2;i++){
if(s[i-1]!=s[n-i]) ans++;
}

cout<<ans<<endl;
return 0;


}



Measured memory_bytes: 256
def solve():
    n = int(input())
    l = [0 for i in range(n+1)]
    for i in range(n):
        a, b = map(int, input().split())
        if a == b:
            l[i+1] = l[i]+1
    if max(l) >= 3:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define re register
#define mo 100003
using namespace std;
int n,m,s,t,l,num_edge,head[2000001],dis[2000001],a,x,y,tot[2000001];
int temp[2000001],sum;
int front=0;
int tail=1;
int num[2000001]; 
int b[2000001];
struct ed
{
	int next,to,dis;
}edge[2000001];
inline int read()
{
    int x=0,c=1;char ch=' ';
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    while(ch=='-') c*=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*c;
}
inline void add_edge(int from,int to)
{
	edge[++num_edge].next=head[from];
	edge[num_edge].to=to;
	head[from]=num_edge;
}
inline void dfs(int st)
{
	b[st]=1;
	for(int i=head[st];i;i=edge[i].next){
		if(!b[edge[i].to]) dfs(edge[i].to);
	}
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		s=read(),t=read();
		add_edge(s,t);
		add_edge(t,s);
	}
	for(int i=1;i<=n;i++){
		if(b[i]==1) continue;
		sum++;
		dfs(i);
	}
	cout<<sum-1;
}


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

class team{
    public:
        vector<int> tt;
        int ac = 0;
        vector<int> miss;
};

int main(void){
    int M,T,P,R;
    
    while(cin >> M >> T >> P >> R, M){
    
        vector<team> teams(T);
        for (int i=0; i<T; i++) {
            teams[i].tt = vector<int>(P,-1);
            teams[i].miss = vector<int>(P,0);
        }

        int m,t,p,j;
        for (int i=0; i<R; i++) {
            cin >> m >> t >> p >> j;
            if (j == 0) {
                teams[t-1].tt[p-1] = max(teams[t-1].tt[p-1], m);
                teams[t-1].ac++;
            }
            else {
                teams[t-1].miss[p-1]++;
            }
        }
        

        
        vector<pair<int, pair<int, int>>> score(T);
        
        for (int i=0; i<T; i++){
            int t = 0;
            for (int j=0; j<P; j++) {
                if (teams[i].tt[j] != -1)
                    t += teams[i].tt[j] + teams[i].miss[j]*20;
            }
            score[i] = make_pair(teams[i].ac, make_pair(-t, i+1));
        }
        
        // for (int i=0; i<T; i++){
        //     cout << "team " << i+1 <<" :" << endl;
        //     cout << teams[i].ac << endl;
        //     for (int j=0;j<P;j++) {
        //         cout << teams[i].tt[j] << " ";
        //     }
        //     cout << endl;
        //     for (int j=0;j<P;j++) {
        //         cout << teams[i].miss[j] << " ";
        //     }
        //     cout << endl;
        //     cout << -score[i].second.first << endl;
        // }
        
        
    
        sort(score.begin(), score.end(), greater<pair<int,pair<int,int>>>());
        
        
        for (int i=0; i<T-1; i++) {
            cout << score[i].second.second;
            if (score[i].first == score[i+1].first && score[i].second.first == score[i+1].second.first) cout << "=";
            else cout << ",";
        }
        cout << score[T-1].second.second << endl;
    }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(it,st,en) for(int it=(st);it<(int)(en);++it)
#define all(c) (c).begin(), (c).end()
#define debug(x) cerr << #x << " = " << x << endl
#define eb emplace_back
#define X first
#define Y second
typedef long long int ll; 
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin>>s;
  ll sm = 0, cnt = 0;
  rep(i,0,s.size()) if(s[i] == 'W') {
    sm += i - cnt;
    ++cnt;
  }
  cout << sm << endl;
  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
bool can[1000000];
int sz[1000000];
int main()
{
    int n,m;
    cin>>n>>m;
    can[1]=1;
    int ans=0;
    for (int i=1;i<=n;i++)
        sz[i]=1;
    while(m--)
    {
        int x,y;
        cin>>x>>y;
        sz[x]--;
        sz[y]++;
        if (can[x])can[y]=1;
        if (sz[x]==0)
            can[x]=0;

    }
    for (int i=1;i<=n;i++)
        if (can[i])
            ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 768
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = INF;
	ans = min(ans, (abs(b - a) + abs(c - b)));//abc
	ans = min(ans, (abs(c - b) + abs(a - c)));//bca
	ans = min(ans, (abs(a - c) + abs(b - a)));//cab
	print(ans);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const int MOD=1000000007;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s;
	cin>>s;
	n=s.size();
	int red=0, brw=0;
	REP(i, n){
		if(s[i]=='0'){
			++red;
		}
		else{
			++brw;
		}
	}
	cout<<min(red, brw)*2<<'\n';
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <fstream>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
typedef long long ll;

int main() {

	int N; cin >> N;
	vector<int> s(N);
	REP(i,N) cin >> s[i];

	int sum = 0;
	REP(i,s.size()) sum += s[i];

	if(sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	} else {
		sort(s.begin(),s.end());
		int idx = 0;
		while(idx < s.size()) {
			if(s[idx] % 10 != 0) {
				cout << sum - s[idx] << endl;
				return 0;
			}
			idx++;
		}
	}

	cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    string S; cin >> S;
    ll a[500010] = {};

    ll cnt = 0;
    REP(i,S.size()) {
        if (S[i] == '<') {
            cnt++;
        } else {
            cnt = 0;
        }
        a[i + 1] = max(a[i + 1], cnt);
    }

    cnt = 0;
    for (int i = (int)S.size() - 1; i >= 0; i--) {
        if (S[i] == '>') {
            cnt++;
        } else {
            cnt = 0;
        }
        a[i] = max(a[i], cnt);
    }

    ll ans = 0;
    REP(i,S.size() + 1) {
        ans += a[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4740
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
gp_hash_table<long long, int> gh;
char s[5001];
int h1 = 1299827, h2 = 81689;
const int mod = 1e9+7;
long long p1[5001], val1[5001];
long long p2[5001], val2[5001];
int main(){
    int n;
    scanf("%d%s", &n, s+1);
    p1[0] = p2[0] = 1;
    for(int i=1;i<=n;i++){
        p1[i] = p1[i-1]*h1%mod;
        p2[i] = p2[i-1]*h2%mod;
    }
    for(int i=1;i<=n;i++){
        val1[i] = (val1[i-1] + p1[i]*s[i])%mod;
        val2[i] = (val2[i-1] + p2[i]*s[i])%mod;
    }
    int lo = 1, hi = n, ans = 0;
    while(lo <= hi){
        int mid = (lo+hi)/2;
        gh.clear(); 
        bool ok = 0;
        for(int i=1;i<=n-mid+1;i++){
            int l = i, r = i+mid-1;
            long long v1 = (val1[r] - val1[l-1] + mod)*p1[n-r]%mod;
            long long v2 = (val2[r] - val2[l-1] + mod)*p2[n-r]%mod;
            if(gh.find(v1*1ll*mod + v2) != gh.end()){
                if(gh[v1*1ll*mod + v2] < l){
                    ok = 1;
                    break;
                }
            }
            else gh[v1*1ll*mod + v2] = r;
        }
        if(ok) ans = mid, lo = mid+1;
        else hi = mid-1;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int n;
  cin>>n;
  v(ll) t(n);
  cin>>t[0];
  ll ans=t[0];
  rrep(i,n-1) {
    cin>>t[i];
    ans=lcm(ans,t[i]);
  }
  cout<<ans<<endl;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9


int main(){
  int N;
  cin >> N;
  vector<vector<int>> cnt(10, vector<int>(10,0));
  FOR(i, 1, N+1){
    string x = to_string(i);
    cnt[x[0]-'0'][x.back()-'0']++;
  }
  ll ans = 0;
  REP(i, 10){
    REP(j, 10){
      ans += cnt[i][j] * cnt[j][i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n, a, b, c = map(int, input().split())
q = [(0, 1) if si == 'AB' else (1, 2) if si == 'BC' else (0, 2) for si in (input() for _ in range(n))]
ans = []
ch = ['A', 'B', 'C']
d = [a, b, c]

nxt = [[-1] * 3] * n
t = [-1, -1, -1]
for i, (x, y) in reversed(list(enumerate(q))):
    nxt[i] = t.copy()
    t[x], t[y] = y, x
for (x, y), t in zip(q, nxt):
    if d[x] == d[y] == 0:
        print('No')
        break
    if d[x] != 0 and (d[y] == 0 or d[x] >= 2 or t[3 - x - y] == y):
            x, y = y, x
    d[x] += 1
    d[y] -= 1
    ans.append(ch[x])
else:
    print('Yes', *ans, sep='\n')


Measured memory_bytes: 30324
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int no_of_stones;
    cin >> no_of_stones;

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

    vector <int> minimum_cost(no_of_stones + 1);
    minimum_cost[2] = abs(height[2] - height[1]);
    for(int i = 3; i <= no_of_stones; i++)
        minimum_cost[i] = min(minimum_cost[i - 1] + abs(height[i] - height[i - 1]),
                              minimum_cost[i - 2] + abs(height[i] - height[i - 2]));

    cout << minimum_cost[no_of_stones];
    return 0;
}

Measured memory_bytes: 3968
x = gets.to_i
ma = 1000
(-ma..ma).each do |b|
  ta = x + b**5
  (-ma..ma).each do |a|
    if a**5 == ta
      puts "#{a} #{b}"
      exit(0)
    elsif a**5 > ta
      break
    end
  end
end
    

Measured memory_bytes: 14260
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod = 1e9+7;
ll inf = 1e18;
//LLONG_MIN

struct Factorial{
	long long N,mod;
	vector<long long> fact,inv;
	long long mod_pow(long long x,long long n){
		long long res=1;
		while(n){
			if(n&1) (res*=x)%=mod;
			(x*=x)%=mod;
			n>>=1;
		}
		return res;
	}
	Factorial(){}
	Factorial(long long sn,long long smod){
		N=sn; mod=smod;
		fact.reserve(sn+1); inv.reserve(sn+1);
		//初期化
		fact[0]=1;
		for(int i=1;i<=sn;i++){
			fact[i]=(fact[i-1]*i) % mod;
		}
		inv[sn]=mod_pow(fact[sn],mod-2);
		for(int i=sn;i>0;i--){
			inv[i-1]=(inv[i]*i) % mod;
		}
	}
	long long Fact(long long n){
		if(n<0)return 0;
		return fact[n];
	}
	long long Inv(long long n){
		if(n<0)return 0;
		return inv[n];
	}
	long long Combination(long long n,long long r){
		if(n<r)return 0;
		if(r<0)return 0;
		long long ans=1;
		ans = (ans*Fact(n)) % mod;
		ans = (ans*Inv(r)) % mod;
		ans = (ans*Inv(n-r)) % mod;
		return ans;
	}
};

int main(void){
	ll n,a[100010],b[100010]={},l,r,L,R;
	cin>>n;
	reg(i,1,n+1){
		cin>>a[i];
		if(b[a[i]]==0){
			b[a[i]]=i;//場所記録
		}else{
			l=b[a[i]];
			r=i;
		}
	}
	L=l-1;
	R=n+1-r;
	Factorial f(n+1,mod);
	reg(k,1,n+1){
		ll ans=(f.Combination(n+1,k)+mod-f.Combination(L+R,k-1))%mod;
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll, ll>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
// #define fat 1000000007
#define fat 998244353
#define PI_2 1.57079632679489661923


int main()
{
    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, c, d, u, v, x, y;
    ll ans = 0;

    ll l = 0, r = 0;
    bool poss = true;

    boost;
    string sa, sb;

    // cin >> tt;  
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n;

        vi aa(n), bb(n);
        for(i = 0; i < n; i++) cin >> aa[i] >> bb[i];

        sort(aa.B, aa.E);
        sort(bb.B, bb.E);

        if(n&1){
            ll mid = n / 2;
            ans = bb[mid] - aa[mid] + 1;
        }
        else{
            ll m1 = n / 2;
            ll m2 = n / 2 - 1;

            ans = (bb[m1] + bb[m2]) - (aa[m1] + aa[m2]) + 1;
        }
        cout << ans << nl;
    }   

    return 0;
}

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


int* g;

long long int_pow(long long a, long long b, const int& mod) {
    long long ans(1);
    while (b) {
        if (b % 2) ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}

void pre_calc(const int& n) {
    bool* is_c = new bool[n + 1];
    vector<int> p;
    //vector<int> g(n + 1);
    g = new int[n + 1];
    g[1] = 1;

    for (int i = 2; i <= n; ++i) {
        if (!is_c[i]) {
            p.push_back(i);
            // phi: i-1, mu: -1, lcm: i - i * i
            g[i] = i - 1;
        }
        
        for (int j = 0; j < p.size() && p[j] * i <= n; ++j) {
            is_c[i * p[j]] = true;
            // for mobius function: 
            // g[i] * (i % p[j] ? g[p[j]] : 0)
            g[i * p[j]] = g[i] * (i % p[j] ? g[p[j]] : p[j]);
            if (i % p[j] == 0) break;
        }
    }

    //delete[] is_c;
}

int main() {
    // time :k log(n)
    // space k
    int n, k;
    cin >> n >> k;
    const int mod(1000000007);
    long long ans(0);
    pre_calc(k);
    //for (int i = 0; i <= n; ++i) cout << g[i] << ' ';

    //cout << endl;
    for (int i = 1; i <= k; ++i)
        ans = (ans + int_pow(k / i, n, mod) * g[i] % mod) % mod;
    //delete[] g;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4148
n,k=map(int,input().split())
ans=0
if k>2*n:
  print(ans)
else:
  r=k
  for i in range(1,k):
    if 2*i%k==0:
      r=i
  amari=set()
  for i in range(1,(n-r)//r+1+1):
    if r*i%k in amari:
      continue
    else:
      amari.add(r*i%k)
      q=(n-r*i)//k+1
      ans+=q**3
  print(ans)

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

using namespace std;

const int maxn = 2e5 + 10;

int n;
int a[maxn], lo[maxn], hi[maxn];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);

	stack <int> st;
	for (int i = 1; i <= n; ++i) {
		lo[i] = 0; hi[i] = n + 1;
		while (!st.empty() && a[st.top()] > a[i]) {
			hi[st.top()] = i;
			st.pop();
		}
		if (!st.empty()) lo[i] = st.top();
		st.push(i);
	}
	long long answer = 0;
	for (int i = 1; i <= n; ++i) {
		answer += 1ll * (hi[i] - i) * (i - lo[i]) * a[i];
//		cerr << i << " " << lo[i] << " " << hi[i] << "\n";
	}
	cout << answer << "\n";
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  
  vector<int> a(N);
  
  for(int i = 0;i < N;i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(),a.end());
  
 
    cout << a.at(N/2) - a.at(N/2 - 1) << endl;
  
  
}

Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;
    getline(cin, s);
    for (int i=0; i<s.size(); i++)
    {
        if (s[i]>='a' && s[i]<='z') s[i]+='A'-'a';
        else if (s[i]>='A' && s[i]<='Z') s[i]+='a'-'A';
    }
    cout<<s<<'\n';
    return 0;
}



Measured memory_bytes: 3164
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
static const double PI = 3.141592653589793;
const ll INF = 100000000000000;
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;


vector<int> G[200005];
ll y[200005];

void Representing_graph(int s, int t) {
	G[s].push_back(t);
	G[t].push_back(s);
}

void search(int x,int p) {
	for (ll i = 0; i < G[x].size(); i++) {
		if (G[x][i] != p) {
			y[G[x][i]] += y[x];
			search(G[x][i], x);
		}
	}
}

int main() {
	ll n, q,a,b;
	cin >> n >> q;
	for (ll i = 1; i <= n ; i++)y[i] = 0;
	for (ll i = 0; i < n - 1; i++) {
		cin >> a >> b;
		Representing_graph(a, b);
	}
	for (ll i = 0; i < q; i++) {
		cin >> a >> b;
		y[a] += b;
	}

	search(1,0);

	for (ll i = 1; i <= n; i++) {
		cout << y[i] << endl;
	}
}


Measured memory_bytes: 27392
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {

        //var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var S = Console.ReadLine();
        long N = S.Length;
        long ans = 0;
        long pre = 0;
        for (int i = 0; i < N; i++)
        {
            var now = S[i];
            long count = 1;

            while (i + 1 < N && now == S[i + 1])
            {
                count++;
                i++;
            }
            ans += count * (count + 1) / 2;
            if (S[i] == '>') ans -= Math.Min(count, pre);
            pre = count;
        }
        
        Console.WriteLine(ans);
    }



}


Measured memory_bytes: 27888
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n, m,q;
    cin >> n >> m >> q;
    ll a[n];
    rep(i, n) a[i] = m - q;
    rep(i, q)
    {
        ll x;
        cin >> x;
        x--;
        a[x]++;
    }
    rep(i, n)
    {
        cout << (a[i] > 0? "Yes\n": "No\n");
    }
}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 1408
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

lli square(lli x) {
  return x * x;
}

void solve(vector<lli> const &code, vector<lli> const &sig) {
  int const len = sig.size();
  vector<vector<lli>> dp(sig.size(), vector<lli>(256, infty<lli>));
  for (auto &&c : code) {
    int v = min(255LL, max(0LL, 128 + c));
    chmin(dp[0][v], square(v-sig[0]));
  }

  for(int i = 1; i < len; ++i) {
    for (auto &&c : code) {
      for (int v = 0; v < 256; ++v) {
        int w = min(255LL, max(0LL, v + c));
        chmin(dp[i][w], dp[i-1][v] + square(w-sig[i]));
      }
    }
  }
  // cout << accumulate(begin(dp.back()), end(dp.back()), infty<lli>, minimum<lli>) << "\n";
  lli ans = infty<lli>;
  for (auto &&x : dp.back()) {
    chmin(ans, x);
  }
  cout << ans << "\n";
}

int main() {
  // cout << fixed << setprecision(10);

  int N, M;
  while (cin >> N >> M && N) {
    vector<lli> code, sig;
    REP(i, M) {
      lli C; cin >> C;
      code.push_back(C);
    }
    REP(i, N) {
      lli X; cin >> X;
      sig.push_back(X);
    }
    solve(code, sig);
  }
  return 0;
}



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




int N;
set<int> E[101010], EE[101010];
//-----------------------------------------------------------------
int col[101010];
string sol() {
    queue<int> que;
    
    rep(i, 1, N + 1) if (E[i].size() == 1) que.push(i);
    while (!que.empty()) {
        int i = que.front(); que.pop();
        if (E[i].size() == 0) {
            if (col[i]) break;
            for (int j : EE[i]) if (col[j] == 2) break;
            return "First";
        }
        int j = *E[i].begin();

        if (col[i] == 0) {
            if (col[j] == 1) return "First";
            col[j] = 1;
            col[i] = 2;
        }
        
        E[j].erase(i);
        if (E[j].size() == 1) que.push(j);
    }

    return "Second";
}
//-----------------------------------------------------------------
int main() {
    cin >> N;

    if (N == 1) {
        cout << "First" << endl;
        return 0;
    }

    rep(i, 0, N - 1) {
        int a, b; scanf("%d%d", &a, &b);
        E[a].insert(b);
        E[b].insert(a);
        EE[a].insert(b);
        EE[b].insert(a);
    }

    cout << sol() << endl;
}

Measured memory_bytes: 29056
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		int a,b,c;

		Scanner stdIn = new Scanner(System.in);

		a = Integer.parseInt(stdIn.next());
		b = Integer.parseInt(stdIn.next());
		c = Integer.parseInt(stdIn.next());

		if(c > b && c > a) {
			if(b > a) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26148
N,K = map(int,input().split())
i=0
p=0
u=0
sum_a=0
number=[]
if N>=K:
    num = K-1
else:
    num = N
for a in range(1,num+1):
    sum_a=a
    while u<=1:
        sum_a1=sum_a*2
        sum_a =+sum_a1
        #print(sum_a)
        i=i+1
        #print(sum_a)
        if (sum_a)>=K:
            u=2
    number.append(i)
    u=0
    i=0
    sum_a1=0
if num!=N:
    for i in range(N):
        number.append(0)
for i in range(N):
    if number[i]!=0:
        a=(1/2)**int(number[i])
        p = p +((1/N)*a)
        #print(p)
    else:
        p=p + (1/N)
    

print(p)


Measured memory_bytes: 3992
N = int(input())
abc = [tuple(map(int, input().split())) for _ in range(N)]
dp = [[0, 0, 0] for _ in range(N + 1)]
for i in range(N):
    for a in range(3):
        for b in range(3):
            if a == b:
                continue
            dp[i + 1][b] = max(dp[i + 1][b], dp[i][a] + abc[i][b])
print(max(dp[-1]))


Measured memory_bytes: 40176
#ABC141_C
N,K,Q = map(int,input().split())
A = []
Point = []
for i in range(Q):
    A.append(int(input()))
for i in range(N):
    Point.append(K-Q)
for num in A:
    Point[num-1] += 1
for i in range(N):
    if Point[i] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 11776
#include<map>
#include<cstdio>
#include<algorithm>
using namespace std;

int n,m,x;
map<int,int> M;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&x);
		M[x]++;
	}
	scanf("%d",&m);
	for(int i=1;i<=m;++i)
	{
		scanf("%d",&x);
		if(!M[x])	
		{
			puts("NO");
			return 0;
		}
		else M[x]--;
	}
	puts("YES");
	return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Bichrome Cells
            var line = ReadLines(2);
            int N = line[0];
            int A = line[1];

            Console.WriteLine(N * N - A);
        }

        static List<int> ReadLines(int count = 0)
        {
            //[summary]コンソールの値を読み込む
            var lines = new List<int>();
            string s;

            //読み込む行数が未指定のときは、1行目の値を"count"とみなす
            if (count == 0)
            {
                s = Console.ReadLine().TrimEnd();
                count = int.Parse(s);
            }

            for (int i = 0; i < count; i++)
            {
                s = Console.ReadLine().TrimEnd();
                lines.Add(int.Parse(s));
            }

            return lines;
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>

using namespace std;

int n,q;
int tree[100050];

int Find(int x)
{
    if(tree[x]==x)
        return x;
    return Find(tree[x]);
}

int main()
{
    while(scanf("%d %d",&n,&q)==2)
    {
        if(n==0&&q==0)
            break;
        tree[1]=1;
        for(int i=2;i<=n;i++)
            scanf("%d",&tree[i]);
        getchar();
        long long ans=0;
        for(int i=1;i<=q;i++)
        {
            int temp;
            char s[100];
            gets(s);
            sscanf(&s[2],"%d",&temp);
            if(s[0]=='M')
                tree[temp]=temp;
            else if(s[0]=='Q')
                ans+=Find(temp);
        }
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 1608
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]
ans = 0
cnt = C
for i in range(N):
    for j in range(M):
        cnt += B[j]*A[i][j]
    if cnt > 0:
        ans += 1
    cnt = C
print(ans)

Measured memory_bytes: 38384
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
const ll mod=10007;
ll N;
string str;
ll dp[1000][8];
ll seki[1000];
int main()
{
	scanf("%lld",&N);
	cin>>str;
	for(ll i=0;i<N;i++){
		if(str[i]=='J') seki[i]=0;
		else if(str[i]=='O') seki[i]=1;
		else seki[i]=2;
	}
	for(ll s=1;s<8;s++){
		if((s>>seki[0])&1) if(s&1) dp[0][s]=1;
	}
	for(ll i=1;i<N;i++){
		for(ll s=1;s<8;s++){
			if((s>>seki[i])&1){
				for(ll ps=1;ps<8;ps++){
					if(s&ps){
						dp[i][s]=(dp[i][s]+dp[i-1][ps])%mod;
					}
				}
			}
		}
	}
	ll ans=0;
	for(ll i=0;i<8;++i){
		ans+=dp[N-1][i];
	}
	printf("%lld\n",ans%mod);
}

Measured memory_bytes: 3368
#include <iostream>

using namespace std;

int main(){

  int a, b, c;

  cin >> a >> b >> c;

  if (((a + b) == c) || ((b + c) == a) || ((c + a) == b)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/*
  Contest 086
  A - Product
  Rakesh Kumar --> 18/09/2020
 */

#include <bits/stdc++.h>

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

    int a = 0, b = 0;
    std::cin >> a >> b;
    if ((a == 1 && b == 1) ||
        ((a & 1) && (b & 1)))
        std::cout << "Odd" << std::endl;
    else
        std::cout << "Even" << std::endl;
    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	int N, K;
	cin >> N >> K;
	vector<int>H(N);
	rep(i, N) {
		cin >> H[i];
	}
	vector<int>dp(N,1000000000);//minを更新するので十分大きい値にする
	dp[0] = 0;
	for (int i = 1; i < N; i++) {
		for (int j = 1; j <= K; j++) {
			if (i - j >= 0) {
				dp[i] = min(dp[i], dp[i - j] + abs(H[i] - H[i - j]));
			}
		}
	}
	cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1024
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<Long, Long> Pair;
void solve() {
  int n, m;
  cin >> n >> m;
  Long k;
  cin >> k;
  vector<Long> a(n), b(m);
  fore(i, 0, n) cin >> a[i];
  fore(i, 0, m) cin >> b[i];
  fore(i, 1, n) a[i] += a[i - 1];
  fore(i, 1, m) b[i] += b[i - 1];
  int q = upper_bound(all(b), k) - b.begin();
  Long ans = q;
  fore(i, 0, n) {
    Long need = k - a[i];
    if (need < 0) break;
    Long p = upper_bound(all(b), need) - b.begin();
    ans = max(ans, i + 1 + p);
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int t = 1;
  //cin >> t;
  while (t--) solve();

  return 0;
}

Measured memory_bytes: 6352
program sample
    implicit none
  
    integer(8) :: i,j,m,n,a(10000000)
    
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n

    do i=1,10000000
        a(i)=0
    end do
    do i=1,n
        do j=1,n/i
             a(i*j)=a(i*j)+1
         end do
    end do
    m=0
    do i=1,n
        m=m+a(i)*i

    end do
    write(*,*) m
  
    stop
end program sample
  



Measured memory_bytes: 80920
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

K=gets.to_i
if K<=50
  puts 50
  puts ([50]*K+[0]*(50-K)).join(" ")
  exit
end
ans=array(50)
#K=m*50+r
m=(K/50)
r=K%50
50.times do|i|
  ans[i]=50+(m-1)+(r>0 ? 1 : -i)
  r-=1
end
puts 50
puts ans.join(" ")

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> A(N);
    REP(i, N){
        cin >> A.at(i).first >> A.at(i).second;
    }
    vector<pair<ll, ll>> B(N);
    REP(i, N){
        ll x = A.at(i).first - A.at(i).second;
        ll y = A.at(i).first + A.at(i).second;
        B.at(i).first = y;
        B.at(i).second = x;
    }
    sort(all(B));
    ll pos = -10e9;
    int cnt = 0;
    REP(i, N){
        if(B.at(i).second >= pos){
        cnt++;
        pos = B.at(i).first;
        }
    }

print(cnt);
}


Measured memory_bytes: 2560
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<bitset>
#define int long long
#define lowbit(x) ((x)&(-x))
#define hh putchar('\n')
#define kg putchar(' ')
using namespace std;
const int maxn=100005,mod=20101009;
int n,m,cnt,head[maxn],h[maxn],ans;
struct edge
{
	int to,next;
}e[maxn<<1];
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
		if(ch=='-')
			f=-1;
		ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
    }
    return x*f;
}
inline void write(int a)
{
    if(a<0)
    {
		putchar('-');
		putchar('1');
    }
    else
    {
		if(a>=10)
			write(a/10);
		putchar(a%10+'0');
    }
}
void add(int from,int to)
{
	e[++cnt]=(edge){to,head[from]};
	head[from]=cnt;
}
signed main()
{
	n=read(),m=read();
	for(int i=1;i<=n;++i)
		h[i]=read();
	for(int i=1;i<=m;++i)
	{
		int u=read(),v=read();
		add(u,v),add(v,u);
	}
	for(int i=1;i<=n;++i)
	{
		int flag=0;
		for(int j=head[i];j;j=e[j].next)
			if(h[e[j].to]>=h[i])
			{
				flag=1;
				break;
			}
		if(!flag)
			++ans;
	}
	write(ans);
	return 0;
}


Measured memory_bytes: 8336
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);
    String s;
    StringBuffer str;
    String t;
    int n, count;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    if(n!=0){
		s = sc.next();
		solve();
	    }
	}
    }

    void solve(){
	str = new StringBuffer();
	while(n>0){
	    n--;
	    cut();
	    s = str.toString();
	    str.setLength(0);
	}
	System.out.println(s);
    }

    void cut(){
	int i=0;
	count = 0;
	t = "";
	while(i<s.length()){
	    if(!t.equals(s.substring(i, i+1))){
		if(count!=0){
		    str.append(count + t);
		}
		t = s.substring(i, i+1);
		count = 1;
	    }
	    else count++;
	    i++;
	}
	str.append(count + t);
    }
}

Measured memory_bytes: 50044
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>; //pop_back pop_front push_back push_front front back clear empty
using L = vector<long long>;
using M = map<int,long long>;  //erase  (でキーごと削除) 追加削除検索O(log(N))
using A = vector<vector<long long>>;
using U = unordered_map<int,long long>; //map  (との違いはkeyの順番を保持していない)
using PQL = priority_queue<long long>; //erase  (でキーごと削除) push pop top 
using PQG = priority_queue<long long,L,greater<long long>>; //erase  (でキーごと削除) push pop top 

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define sortedreverce(vector) sort(vector.rbegin(),vector.rend()) //O(nlongn)
#define vdel(vector,a) vector.erase(vector.begin()+a)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define max max<unsigned long>
#define min min<unsigned long>
#define inf 1000000000000000000+10
#define setans long long ans=0;

long long MOD=1000000007;

template <typename PQ>
long long pqsum(PQ pq){long long tmp=0;while(!pq.empty()){tmp+=pq.top();pq.pop();};return tmp;};

template <typename T>
void print(T a){for (auto b:a){cout<<b<<" ";};cout<<endl;}
template <>
void print(unsigned long a){cout<<a<<endl;}
template <>
void print(char a){cout<<a<<endl;}
template <>
void print(bool a){cout<<a<<endl;}
template <>
void print(long long a){cout<<a<<endl;}
template <>
void print(A a){for (auto b:a){for (auto c:b){cout<<c<<" ";}cout<<endl;};cout<<endl;}
template <>
void print(string a){cout<<a<<endl;}



//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ
//printf("%.16f", ans); 誤差落ち対応君



int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long n,l;
    
    cin>>n>>l;
    
    L a;
    for(long long i=0  ;i<n  ;i++){
        a.push_back(l+i);
    }

    setans;
    ans=vsum(a);
    //print(ans);
    L b;
    for(long long i=0  ;i<n  ;i++){
        b.push_back(ans-a[i]);
    }
    long long sa=inf;
    long long aaa=0;
    for(long long i=0  ;i<n  ;i++){
        if (sa>abs(b[i]-ans)){
            sa=abs(b[i]-ans);
            aaa=b[i];
        }
    }
    print(aaa);
}




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

using namespace std; 

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;	

int ma[21][21];

int n,m,c,val;

int ans = 0;

int main(){
	
	
	
	cin >> n >> m >> c; 
	
	vi valus(m);
	
	f(i,0,m){
		cin >> valus[i];
	}
	
	int aux;
	
	f(i,0,n){
		aux = 0;
		f(j,0,m){
			cin >> val;
			aux+=val * valus[j];
		}
		aux+=c;
		
		if(aux>0){
			ans++;
		}
	}
	
	cout << ans << endl;
	
	
    return 0;
}


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

using namespace std;

#define int long long
#define sz(x) (int)x.size()
#define yes cout << "Yes\n"
#define  no cout << "No\n"
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ft first
#define sd second
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<int> vi;
typedef vector<bool> vb;
mt19937_64 rnd(time(0));

void start() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(10);
    // cerr << fixed << setprecision(10);
#ifdef MY
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}

signed main() {
    start();
    int n;
    cin >> n;
    vi a(n), d(n, 1e18);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    d[0] = 0;
    d[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; ++i) {
        d[i] = min(d[i-1] + abs(a[i]-a[i-1]),d[i-2] + abs(a[i]-a[i-2]));
    }
    cout << d[n-1];


}

Measured memory_bytes: 4696
#include<iostream>

using namespace std;

int main()
{
 int n,m;
 cin >> n >> m;
 int tmp=0;
 for(int i=0;i<m;i++){
   int c;
   cin >> c;
   tmp+=c;
 }
 int ans=n-tmp;
 if(ans<0){
   cout << -1;
 }
 else{
   cout << ans;
 }
 return 0;
}

Measured memory_bytes: 3644
<?php
$s = trim(fgets(STDIN));
$t = trim(fgets(STDIN));

$n = strlen($s);
for($i = 0; $i < $n; $i++){
    $charMap[$s[$i]] = true;
}
$s = $s.$s;
foreach($charMap as $c => $_){
    $l = -1;
    for($i = $n*2-1; $i >= 0; $i--){
        if($i < $n){
            $dp[$c][$i] = $l;
        }
        if($s[$i] == $c){
            $l = 0;
        }
        $l++;
    }
}
$c = -1;
for($j = 0, $J = strlen($t); $j < $J; $j++){
    if(!isset($dp[$t[$j]])){
        echo -1,"\n";exit;
    }
//    echo $dp[$t[$j]][($c+$n) % $n],"\n";
    $c+=$dp[$t[$j]][($c+$n) % $n];
}
printf("%d", $c + 1);

Measured memory_bytes: 115448