akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define MAXN 200000
using namespace std;
int X[MAXN+5],W[MAXN+5];
int sum[2][MAXN+5],pos[MAXN+5];
int ans[MAXN+5];
int N,L,T;
int main()
{
	scanf("%d %d %d",&N,&L,&T);
	int T1=T;
	for(int i=0;i<N;i++)
	{
		scanf("%d %d",&X[i],&W[i]);
		pos[i]=X[i];
		sum[0][i]=sum[0][max((i-1),0)];
		sum[1][i]=sum[1][max((i-1),0)];
		W[i]--;
		sum[W[i]][i]++;
	}
	for(int i=N;i<2*N;i++)
	{
		pos[i]=X[i%N]+L;
		sum[0][i]=sum[0][i-1];
		sum[1][i]=sum[1][i-1];
		sum[W[i%N]][i]++;
	}
	int cnt[2]={};
	T*=2;
	cnt[0]=T/L*sum[0][N-1];
	cnt[1]=T/L*sum[1][N-1];
	T%=L;
	for(int i=0;i<N;i++)
	{
		if(W[i]==1)
			continue;
		int p=upper_bound(pos,pos+2*N,pos[i]+T)-pos;
		p--;
		int cntn=cnt[1]+sum[1][p]-sum[1][i];
		ans[(i+cntn)%N]=(pos[i]+T1)%L;
	}
	for(int i=N;i<2*N;i++)
	{
		if(W[i%N]==0)
			continue;
		int p=lower_bound(pos,pos+2*N,pos[i]-T)-pos;
		int cntn;
		if(p>0)
			cntn=cnt[0]+sum[0][i-1]-sum[0][p-1];
		else
			cntn=cnt[0]+sum[0][i-1];
		ans[((i-cntn)%N+N)%N]=((pos[i]-T1)%L+L)%L;
	}
	for(int i=0;i<N;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define itr(a) begin(a), end(a)
#define pb push_back
#define x first
#define y second
#define endl '\n'

#define FAST cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

#ifndef __LOCAL
#define FILES(namein, nameout) freopen(namein, "r", stdin); freopen(nameout, "w", stdout); FAST;
#else
#define FILES(namein, nameout) FAST;
#endif //__LOCAL

using namespace std;
using namespace __gnu_pbds;
using python = void;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned short uss;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type> ordered_set;

const ll M = 1e9+7;
const ll N = 1e5+228;
constexpr ll inf = 0x3f3f3f3f3f3f3f3f;
ll a[N], dp[N];
python solve(){
	FAST;
	ll n, k;
	cin >> n >> k;
	for(ll i =0;i<n;i++){
		cin >> a[i];
		dp[i] = inf;
		for(ll j = 1;j<=k && i-j>=0;j++) dp[i] = min(dp[i], dp[i-j]+abs(a[i]-a[i-j]));
		if(!i) dp[i] = 0;
	}
	cout << dp[n-1]<<'\n';
}

signed main(){
	FAST;
	ll q = 1;
	//cin >> q;
	while(q--){
		solve();
	}
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n,i,j,a,b;
cin>>n>>a>>b;
	if(b-a<=0) {
		printf("delicious");
		return 0;
	}
	if(b-a>n) {
		printf("dangerous");
		return 0;
	}
	printf("safe");
	return 0;



}

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

int main(){
	// 好きだと言われた回数を記録
	int n, m; cin >> n >> m;
	vector<int> count(m, 0);
	for(int i = 0; i < n; i++){
		int k; cin >> k;
		for(int j = 0; j < k; j++){
			int a; cin >> a;
			count[a - 1]++;
		}
	}

	int res = 0;
	for(int i = 0; i < m; i++){
		if(count[i] == n)
			res++;
	}

	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
#define _GLIBCXX_DEBUG
     
int main() {
  string s;
  cin >> s;
  int ans=0, count=0, len=s.size();

  rep (i, len) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      ++count;
    }
    else if (count > ans) {
      ans = count;
      count = 0;
    }
    else count = 0;
  }
  if (count > ans) {
      ans = count;
      count = 0;
  }
  cout << ans << endl;
}

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

int main(){
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  
  int count =0;
  for(int a = 0; a <= A; a++){
    for(int b = 0; b <= B; b++){
      for(int c = 0; c <= C; c++){
        if(a * 500 + b * 100 + c * 50 == X){
          count++;
        }
      }
    }
  }
  
  cout << count << endl;
}
          


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

#A
def A():
    a, b = LI()
    print(max(a + b, a - b, a * b))
    return

#B
def B():
    k, x = LI()
    ans = []
    for i in range(x - k + 1, x + k):
        ans.append(i)
    print(*ans)
    return

#C
def C():
    n = II()
    d = defaultdict(int)
    for _ in range(n):
        s = S()
        s.sort()
        d[tuple(s)] += 1
    ans = 0
    for i in d.values():
        ans += i * (i - 1) // 2
    print(ans)
    return

#D
def D():
    n, m = LI()
    ab = LIR(n)
    ab.sort(key=lambda x: (x[1], x[0]), reverse=True)
    ans = 0
    for i in range(n):
        if m >= ab[i][0]:
            ans += ab[i][1]
            m -= 1
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 38768
{
  const run = (input: string) => {
    let numbers = input.trim().split("")

    for (let first = 0; first <= 1; first++) {
      for (let second = 0; second <= 1; second++) {
        for (let third = 0; third <= 1; third++) {
          const o1 = first === 0 ? '+' : '-'
          const o2 = second === 0 ? '+' : '-'
          const o3 = third === 0 ? '+' : '-'

          const result = numbers[0] + o1 + numbers[1] + o2 + numbers[2] + o3 + numbers[3]
          if (eval(result) === 7) {
            return result + '=7'
          }
        }
      }
    }

  }

  const Main = (input: string) => {
    console.log(run(input))
  };

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


Measured memory_bytes: 29636
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
  int n;
  cin >> n;
  int a[100001]={};
  int min=10000000;
  int max= -1;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i] <= min){
      min = a[i];
    }
    if(a[i] >= max){
      max = a[i];
    }
  }

  if(max - min > 1){
    cout << "No" << endl;
    return 0;
  }

  if(max - min == 1){
    int m = 0;
    for(int i=0;i<n;i++){
      if(a[i]+1 == max)
        m++;
    }
    if(max - m <= 0){
      cout << "No" << endl;
      return 0;
    }
    if((max-m)*2 <= n-m)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;

    return 0;
  }

  if(max - min == 0){
    if(max + 1 == n){
      cout << "Yes" << endl;
      return 0;
    }
    if(max*2 <= n){
      cout << "Yes" << endl;
      return 0;
    }
    cout << "No" << endl;
    return 0;
  }

  return 0;
}

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

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 1000005;

void solve(int v[], int n){
  if(n == 1){
    printf("%d\n", v[0]);
    return;
  }
  int v2[n];
  for(int i = 0; i < n-1; i++){
    printf("%d ", v[i]);
    v2[i] = abs(v[i] - v[i+1]);
  }
  printf("%d\n", v[n-1]);
  return solve(v2, n-1);
}

int n;
int v[N];
int dp[N];

int main() {
  bool f1 = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%1d", v+i);
    v[i]--;
    f1 |= v[i] == 1;
  }
  if(f1){
    for(int i = 0; i < n; i++){
      v[i] %= 2;
    }
  }
  for(int i = 0; i < n; i++){
		dp[i] = v[i];
	}
	for(int b = 0; b <= 22; b++){
		for(int i = 0; i < n; i++){
			if(i & (1 << b)){
				dp[i] ^= dp[i ^ (1 << b)];
			}
		}
	}
  printf("%d\n",dp[n-1]);
  return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
///The greatest enemy of knowledge is not ignorance, it is illusion of knowledge

#include<bits/stdc++.h>
using namespace std;


#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpll vector<pll>
#define vpii vector<pii>
#define umap unordered_map
#define uset unordered_set
#define PQ priority_queue

#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a) printa(a,0,a.size())
#define print2d(a,r,c) for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define fbo find_by_order
#define ook order_of_key
#define MP make_pair
#define UB upper_bound
#define LB lower_bound

#define F first
#define S second
#define mem(a,x) memset(a,x,sizeof(a))
#define inf 1e18
#define PI (acos(-1.0))
#define E 2.71828182845904523536
#define gamma 0.5772156649
#define nl "\n"
#define lg(r,n) (int)(log2(n)/log2(r))
#define pf printf
#define sf scanf
#define _ccase printf("Case %lld: ",++cs)
#define _case cout<<"Case "<<++cs<<": "
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }

#define asche cerr<<"Ekhane asche\n";
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<ll>())
#define all(v) v.begin(),v.end()
#define mnv(v) *min_element(v.begin(),v.end())
#define mxv(v) *max_element(v.begin(),v.end())
#define toint(a) atoi(a.c_str())
#define fast ios_base::sync_with_stdio(false)
#define valid(tx,ty) (tx>=0&&tx<n&&ty>=0&&ty<m)
#define one(x) __builtin_popcount(x)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define stree ll l=(n<<1),r=l+1,mid=b+(e-b)/2
#define fout(x) fixed<<setprecision(x)

#define SQ(x) ((x)*(x))
#define issq(x) (((ll)(sqrt((x))))*((ll)(sqrt((x))))==(x))
#define AMR std::ios::sync_with_stdio(false);cin.tie(NULL);
void lcs(string a,string b)
{
    int la=a.size(),lb=b.size();
    int arr[la+1][lb+1];
    for(int i=0; i<=la; i++)
        for(int j=0; j<=lb ; j++)
        {
            if(i==0 || j==0)
            {
                arr[i][j]=0;
                continue;
            }
            else if(a[i-1]==b[j-1])
                arr[i][j]=arr[i-1][j-1]+1;
            else
                arr[i][j]=max( arr[i-1][j], arr[i][j-1] );
        }


   // cout<<arr[la][lb]<<endl;


    string ans="";
    int i=la,j=lb;
    while(i> 0 && j>0)
    {
        if(a[i-1]==b[j-1])
        {
            ans+=a[i-1];
            i--,j--;
        }
        else if(arr[i-1][j]>arr[i][j-1])
            i--;
        else
            j--;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;

}
int main()
{
    AMR;
    string s,t;
    cin>>s>>t;
    lcs(s,t);





}



Measured memory_bytes: 35456
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+7+7;

int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
//<<-----Implement Functions Here---->>//
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
  
       
        spf[i] = i; 
  
    
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) 
    { 
      
        if (spf[i] == i) 
        { 
             
            for (ll j=i*i; j<MAXN; j+=i) 
  
                
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
vector<ll> getFactorization(ll x) 
{ 
    vector<ll> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n;
		sieve();
		ll ans = 1;
		for(ll i=2;i<=n;i++)
		{
			vll v = getFactorization(i);
			map<ll,ll>map1;
			for(auto it:v)map1[it]++;
			ll temp = 1;
			for(auto it:map1)temp*=(it.s+1);
			ans += i*temp;
		}
		cout<<ans<<endl;

}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

Measured memory_bytes: 81760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  ll K;
  cin >> N >> M >> K;
  vector<ll> A(N), B(M), sumA(N+1), sumB(M+1);
  rep(i, N) {
    cin >> A[i];
    sumA[i+1] = sumA[i] + A[i];
  }
  rep(i, M) {
    cin >> B[i];
    sumB[i+1] = sumB[i] + B[i];
  }
  int ans = 0;
  rep(i, N+1) {
    if(sumA[i] > K) continue;
    int cur = upper_bound(all(sumB), K-sumA[i]) - begin(sumB);
    ans = max(i+cur-1, ans);
  }
  cout << ans << "\n";
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int a[n];
  int max = 0;
  int count[100000] = {};
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    count[a[i]] += 1;
  }
  for (int i = 1; i < 99999; i++) {
    if (count[i - 1] + count[i] + count[i + 1] > max) {
      max = count[i - 1] + count[i] + count[i + 1];
    }
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3

def binsearch(l, r, pred): # [l, r)
    assert l < r
    l -= 1
    while r - l > 1:
        m = (l + r) // 2
        if pred(m):
            r = m
        else:
            l = m
    return r

import sys
def pred(n):
    assert 1 <= n and n <= 10 ** 18
    print('?', n)
    sys.stdout.flush()
    return input() == 'Y'

def solve():
    s = ''
    s += str(binsearch(1, 9 + 1, lambda c: not pred(int(s + str(c)))) - 1)

    if s == '9':
        f = lambda k: pred(int('1' + '0' * k))
    else:
        f = lambda k: not pred(int('9' * k))
    k = 1
    while f(k):
        k += 1
        if k >= 13:
            return 1

    if k == 1:
        return binsearch(1, 9 + 1, lambda c: pred(int(str(c) + '0')))
    else:
        for _ in range(k - 2):
            s += str(binsearch(0, 9 + 1, lambda c: not pred(int(s + str(c)))) - 1)
        s += str(binsearch(0, 9 + 1, lambda c: pred(int(s + str(c) + '0'))))

    return int(s)

print('!', solve())


Measured memory_bytes: 3404
#include <bits/stdc++.h>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eps 1e-8
#define all(v) (v.begin(),v.end())
#define db double
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const double pi=acos(-1.0);
const double inf = 1e100;
template<class T>
inline T read()
{
	T x=0,f=1;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-')f=-1;s=getchar();};
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();};
	return x*f;
}
template<typename T>
inline void wri(T x)
{
	if(x<0){x=-x;putchar('-');};
	if(x/10) wri(x/10);
	putchar(x%10+48);
}
template<typename T>
inline void print(T x,char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a,T b)
{
	return b==0?a:gcd(b,a%b);
}
//关闭流同步就不能手写读入优化啦
int h,w,k;
string s[10];
ll ans;
int vis[10][10];
int cnt=0;
vector<vector<int>>p;
void dfs(int i,int sum){
	for(int j=i+1;j<h;j++){
		
	}
	if(i==h-1) return ;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>h>>w>>k;
    rep(i,0,h) cin>>s[i];
    for(int i=0;i<(1<<h);i++){
    	for(int j=0;j<(1<<w);j++){
    		int cnt=0;
    		for(int k=0;k<h;k++){
    			for(int l=0;l<w;l++){
    				//cout<<s[k][l]<<endl;
    				if(((1<<k)&i)&&((1<<l)&j)&&(s[k][l]=='#'))
    				cnt++;
				}
			}
			//cout<<cnt<<endl;
			ans+=(cnt==k);
		}
	}
	cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <cstring>
#include <string>

using namespace std;
#define long long long

const int N = 1e5 + 10;
const long INF = 1e9 + 7;

int n, total;
long w[N], v[N], f[110][N];

int main()
{
//    freopen(".INP", "r", stdin);
//    freopen(".OUT", "w", stdout);
    cin.tie(NULL); ios_base::sync_with_stdio(false);

    cin >> n >> total;
    for (int i = 1; i <= n; ++i) cin >> w[i] >> v[i];

    fill(f[0], f[0] + N, INF); f[0][0] = 0;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j < N; ++j) {
            f[i][j] = f[i - 1][j];
            if (v[i] <= j) f[i][j] = min(f[i][j], f[i - 1][j - v[i]] + w[i]);
        }
    int res = 0;
    for (int j = 1; j < N; ++j)
        if (f[n][j] <= total) res = j;
    cout << res;

    return 0;
}


Measured memory_bytes: 82176
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,q,c,up,low,t,x,y,arr[4],a,b;
double ff;
bool f;

int main()
{
    cin >> a >> b;
    for (ll i=1;i<=b;i++)
    {
        cin >> x;
        c+=x;
    }
    if (c>=a)
        cout << "Yes\n";
    else
        cout << "No\n";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
  int key;
  struct node *p, *l, *r;
}T_node;
int main(){
  int n;
  scanf("%d", &n);
  T_node *heap[n + 1];
  int i;
  for(i = 1; i <= n; i++){
    heap[i] = (T_node *)malloc(sizeof(T_node));
    heap[i]->p = heap[i]->l = heap[i]->r = NULL;
    scanf("%d", &(heap[i]->key));
    if(i /2){
      heap[i]->p = heap[i / 2];
      if(i % 2)
	heap[i / 2]->r = heap[i];
      else
	heap[i / 2]->l = heap[i];
    }
  }
  for(i = 1; i <= n; i++){
    printf("node %d: key = %d, ", i, heap[i]->key);
    if(heap[i]->p != NULL)
      printf("parent key = %d, ", heap[i]->p->key);
    if(heap[i]->l != NULL)
      printf("left key = %d, ", heap[i]->l->key);
    if(heap[i]->r != NULL)
      printf("right key = %d, ", heap[i]->r->key);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 608
n = gets.to_i
a = gets.split.map(&:to_i).unshift(0)
b = Hash.new(0)
ans = 0
n.times do |i|
    a[i+1] += a[i]
end
a.each do |num|
    b[num] += 1
end
b.values.each do |v|
    ans += v*(v-1)/2
end
puts ans

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> dp(n+1, 1e9);
    dp[0] = 0;
    vector<int> c(m);
    for(int i=0; i<m; ++i) {
        cin >> c[i];
    }
    for(int i=0; i<m; ++i) {
        for(int j=c[i]; j<=n; ++j) {
            dp[j] = min(dp[j], dp[j-c[i]] + 1);
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define ll long long
#define Mod 1000000007
#define N 2004

using namespace std;

int n, m;
ll f[N][N];
int s[N], t[N];

int main(){
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		scanf("%d", s + i),f[i][0] = 1;
	for (int i = 1; i <= m; ++i)
		scanf("%d", t + i),f[0][i] = 1;
	f[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			(f[i][j] += (f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1]) % Mod) %= Mod;
			if (s[i] == t[j])
				(f[i][j] += f[i - 1][j - 1]) %= Mod;
		}
	}

	cout << (f[n][m] % Mod + Mod) % Mod << endl;
	return 0;
}



Measured memory_bytes: 31616
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

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

    set<int> s;
    int x = 7%k;
    int ans = 1;
    while (s.count(x)==0) {
        s.insert(x);
        if (x==0) {
            cout << ans << endl;
            return 0;
        }
        ++ans;
        x = (10*x+7)%k;
    }
    cout << -1 << endl;
    return 0;
}

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

long long att(long long x) {
	if (x == 1) return 1;
	return 1 + 2 * att(x/2);
}

int main() {
	
	long long x;
	cin >> x;
	cout << att(x) << endl;
	
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
ll n,m,a,b;
ll fpow(ll b,ll p,ll mod)
{
	ll ans=1,tmp=b;
	while(p)
	{
		if(p&1)ans=ans*tmp%mod;
		tmp=tmp*tmp%mod;
		p>>=1;
	}
	return ans%mod;
}
ll inv(ll b,ll mod)
{
	return fpow(b,mod-2,mod)%mod;
}
const int N=200002;
const ll mod=1e9+7;
ll fac[N],ans=0;
ll C(ll n,ll m)
{
	if(n<m)return 0;
	return fac[n]%mod*inv(fac[m],mod)%mod*inv(fac[n-m],mod)%mod;
}
ll Lucas(ll n,ll m)
{
	if(!m)return 1;
	return C(n%mod,m%mod)*Lucas(n/mod,m/mod);
}
int main()
{
	fac[0]=1;
	for(int i=1;i<=200000;i++)fac[i]=fac[i-1]*i%mod;
	scanf("%lld%lld%lld%lld",&n,&m,&a,&b);
	for(ll i=1;i<=n-a&&i<=m-b;i++)
	{
		ll X=n-a-i,Y=b+i-1;
		ans=(ans+Lucas(X+Y,X)%mod*Lucas(m-Y+n-X-2,m-Y-1)%mod)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
const int MAXL = 128;
const int Q = 850;
 
int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	const string chars = 
		"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
		"abcdefghijklmnopqrstuvwxyz"
		"0123456789";
	assert(chars.size() == 62);
	auto query = [&](string q) -> int {
		cout << '?' << ' ' << q << '\n' << flush;
		int v;
		cin >> v;
		return v;
	};
	auto get_cnt = [&](char c) -> int {
		return MAXL - query(string(MAXL, c));
	};
	vector<int> cnts(62);
	int L = 0;
	for (int i = 0; i < 62; i++) {
		cnts[i] = get_cnt(chars[i]);
		L += cnts[i];
	}
	auto is_subseq = [&](string q) -> int {
			return query(q) == L - int(q.size());
	};
	auto combine = [&](const string& a, const string& b) -> string {
		string res;
		int ia = 0, ib = 0;
		while (ia < int(a.size()) && ib < int(b.size())) {
			if (is_subseq(a.substr(0, ia+1) + b.substr(ib))) {
				res += a[ia++];
			} else {
				res += b[ib++];
			}
		}
		while (ia < int(a.size())) res += a[ia++];
		while (ib < int(b.size())) res += b[ib++];
		return res;
	};
	function<string(int , int)> solve = [&](int lx, int rx) {
		if (lx + 1 == rx) {
			return string(cnts[lx], chars[lx]);
		} else {
			return combine(solve(lx, (lx + rx) / 2), solve((lx + rx) / 2, rx));
		}
	};
	string ans = solve(0, 62);
	cout << '!' << ' ' << ans << '\n';
}

Measured memory_bytes: 3780
n, x, y = map(int, input().split())
x -= 1; y -= 1
cnt = [0] * (n-1)

for i in range(n):
    for j in range(i+1, n):
        c = min(j-i, abs(i-x)+abs(j-y)+1, abs(j-x)+abs(i-y)+1)
        cnt[c-1] += 1

print(*cnt, sep="\n")


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

int main(){
	int N, i, j;
	cin >> N;
	int A[N];
	for(i=0; i<N; i++){
		cin >> A[i];
	}
	
	int max=0, B[N][N];
	for(i=0; i<N; i++){
		for(j=i; j<N; j++){
			B[i][j] = abs(A[i]-A[j]);
			if(max < B[i][j])	max = B[i][j];
		}
	}
	
	cout << max << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>

using namespace std;

int main(){
  string num;
  int tmp;
  int ans;
  ans=0;
  int dif;
  dif=999;
  int length;
  cin>>num;
  length=num.length();
  vector<int> v(length);
  for(int i=0;i<length;++i){

  v[i]=(int)(num[i]-'0');
  }
  for(int i=0;i<length-2;++i){
  tmp=v[i]*100+v[i+1]*10+v[i+2];
  if(abs(tmp-753)<dif){
  dif=abs(tmp-753);
  ans=tmp;
  }
  }
  cout<<dif;
  return 0;
  }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

#define debug(x) cout<<#x<<" : "<<x<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define derep(i,a,b) for(int i=a;i>b;i--)
#define all(x) (x).begin(),(x).end()
#define PB push_back
typedef long long ll;

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

	return 0;
}


Measured memory_bytes: 256
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
  ll x;
  cin >> x;

  ll ans = 0;
  ans = x / 11 * 2;
  x -= (x / 11) * 11;
  if ( x == 0) ;
  else if (x <= 6) ans++;
  else if (x < 11) ans += 2;

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

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

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif

void solve() {
	rd1(ll, a);
	rd1(ld, b);
	
	ld ans = (ld)a * (ld)b;
	
	cout << (ll)ans;
	
}

int main() {
	
	fastio;

// 	rd1(ll, t);
	ll t = 1;

    while(t--) {
        solve();
    }
    
	return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
ll gcd(ll a,ll b){
    a=abs(a);
    b=abs(b);
    if(a==0)return b;
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
set<ll> p,ansp;
void solve(long long N, std::vector<long long> a){
    ll g=abs(a.back());
    for (auto &&i : a)
    {
        if(i!=0)g=gcd(i,g);
    }
    for(long long i = 2; i < N+3; i+=2){
        bool flag=true;
        for (auto &&j : p)
        {
            if(i%j==0){flag=false;break;}
            if(j*j>i){break;}
        }
        if(flag)p.insert(i);
        if(i==2)i--;
    }
    for (auto &&i : p)
    {
        vector<ll> sums(i-1);
        for(long long j = 0; j < a.size(); j++){
            sums[j%(i-1)]+=a[j];
            sums[j%(i-1)]%=i;
        }
        bool flag=true;
        for (auto &&j : sums)
        {
            if(j%i!=0){
                flag=false;
                break;
            }
        }
        if(a[0]%i!=0)flag=false;
        if(flag){
            ansp.insert(i);
        }
    }
    for(long long i = 2; i*i <= g; i+=2){
        if(g%i==0){
            while(g%i==0)g/=i;
            ansp.insert(i);
        }
        if(i==2)i--;
    }
    if(g!=1)ansp.insert(g);
    for (auto &&i : ansp)
    {
        cout<<i<<endl;
    }
    
    
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N-0+1);
    for(int i = 0 ; i < N-0+1 ; i++){
        scanf("%lld",&a[i]);
    }
    reverse(a.begin(),a.end());
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 512
n = int(input())
li = [list(map(int,input().split())) for i in range(n)]
 
if li[0][0] - abs(li[0][1]) - abs(li[0][2]) < 0:
  print("No")
  exit()
elif li[0][0] - abs(li[0][1]) - abs(li[0][2]) > 0:
  if (li[0][0] - abs(li[0][1]) - abs(li[0][2])) % 2 != 0:
    print("No")
    exit()
else:
  for k in range(1,n):
    t = li[k][0]
    x = li[k][1]
    y = li[k][2]
    tt = li[k-1][0]
    xx = li[k-1][1]
    yy = li[k-1][2]
    if t - tt - abs(x - xx) - abs(y - yy) <0:
      print("No")
      exit()
    elif t - tt - abs(x - xx) - abs(y - yy) <0:
      if (t - tt - abs(x - xx) - abs(y - yy)) % 2 != 0:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 27380
from collections import deque
s = list(input())
q = int(input())

d = deque()
for i in s:
    d.append(i)

c = 1
for _ in range(q):
    t = list(input().split())
    if t[0] == '1':
        c *= -1
    else:
        if t[1] == '1':
            if c == 1:
                d.appendleft(t[2])
            else:
                d.append(t[2])
        else:
            if c == 1:
                d.append(t[2])
            else:
                d.appendleft(t[2])

print(''.join(list(d)[::c]))


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

int main(){
    int x;
    cin >> x;
    string ans;
    if(x<1200) ans="ABC";
    else ans = "ARC";
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        string[] array = Console.ReadLine().Split(' ');
        int H = int.Parse(array[0]);
        int W = int.Parse(array[1]);
        string[] a = new string[H];
        int[,] b = new int[H, W];
        int[] c = new int[W];

        for (int i = 0; i < H; i++)
        {
            a[i] = Console.ReadLine();
            for (int j = 0; j < W; j++)
            {
                if (a[i][j] == '#')
                {
                    b[i, j] = 1;
                    c[j]++;
                }
                else b[i, j] = 0;
            }
        }

        for (int i = 0; i < H; i++)
        {
            int tmp = 0;
            for (int j = 0; j < W; j++)
            {
                tmp += b[i,j];
            }
            if (tmp == 0) continue;
            for (int j = 0; j < W; j++)
            {
                if (c[j] == 0) continue;
                if (b[i, j] == 1) Console.Write('#');
                else Console.Write('.');
            }
            Console.Write("\n");
        }
    }
}

Measured memory_bytes: 13220
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int w,a,b;
    cin>>w>>a>>b;
    if(a>b)
    {
        swap(a,b);
    }
    if(a+w>=b&&a+w<=b+w)
    {
        cout<<0<<endl;
        return 0;
    }
    cout<<abs(w+a-b)<<endl;
}


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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 650555;
const int L = 21;
const int M = 2155;
const int K = 555;

void solve() {
    string s;
    cin >> s;

    for (int i = 0; i < SZ(s); i++){
        if (s[i] == '7'){
            cout << "Yes";
            return;
        }
    }
    
    cout << "No";

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3652
n = int(input())
lis = list(map(int,input().split()))
nu1 = 0
nu2 = 0
nu4 = 0
for nu in lis:
    if nu % 2 == 0:
        if nu % 4 == 0:
            nu4 += 1
        else:
            nu2 = 1
    else:
        nu1 += 1
if nu4 + 1 >= nu1 + nu2:print("Yes")
else:print("No")

Measured memory_bytes: 14252
// Volume0 - 0021: Parallelism
#include <iostream>
#include <complex>
#include <cmath>
using namespace std;
 
// 外積のスカラーを返す
double cross(complex<double> z1, complex<double> z2) {
    return (z1.real()*z2.imag() - z1.imag()*z2.real());
}
 
int main(int argc, char** argv) {
    static const double EPS = 1e-10;
    int n;
    cin >> n;
    for(int i=0; i<n; i++) {
        double x[4], y[4];
        for(int j=0; j<4; j++) {
            cin >> x[j] >> y[j];
        }
        complex<double> ab(x[1]-x[0], y[1]-y[0]);
        complex<double> cd(x[3]-x[2], y[3]-y[2]);
        if(abs(cross(ab, cd)) < EPS) { // 外積が0なら平行
            cout << "YES" << endl;
        }else {
            cout << "NO" << endl;
        }
    }
}

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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

const int N = 1e5 + 7;

bool vis[N][100];

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

int n;

void dfs(int r, int s)
{
    if(s >= 99) return;
    if(vis[r][s]) return;
    vis[r][s] = 1;
    for(int i = 0; i < 10; i++)
        dfs((10 * r + i) % n, s + i);
}

int main()
{
    _upgrade
    cin >> n;
   
    dfs(0, 0);
    //while(n % 2 == 0) n /= 2;
    //while(n % 5 == 0) n /= 5;
    int res = 1e9;
    for(int i = 1; i < 99; i++)
        if(vis[0][i]) res = min(res, i);
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 233344
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int left[LIMIT1],right[LIMIT1],c[LIMIT1];
int tmp(cv *p, cv *q){
  return right[*(int *)p]-right[*(int *)q];
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int x[LIMIT2]={0},l[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  rep(i,n){
    scanf("%d %d",&x[i],&l[i]);
    left[i] = x[i]-l[i];
    right[i] = x[i]+l[i];
    c[i]=i;
  }
  qsort(c,n,sizeof(int),tmp);
  j=0;//last nokosu
  for(i=1;i<n;i++){
    if(right[c[j]]<=left[c[i]]){
      j=i;
    }else{
      result++;
    }
  }
  printf("%lld",n-result);
  return 0;
}



Measured memory_bytes: 5628
N = int(input())
lst_a = list(map(int, input().split()))
lst_color = [0] * 8
cnt_super = 0


for a in lst_a:
    i = a // 400
    if i >= 8:
        cnt_super += 1
    else:
        lst_color[i] += 1
cnt_existed = sum(1 for x in lst_color if x!=0)


ans_min = max(cnt_existed, 1)
ans_max = cnt_existed + cnt_super


print(ans_min, ans_max)

Measured memory_bytes: 3064
//DP-1

#include<iostream>
#include<stdio.h>


using namespace std;


int main()
{
    int i,n;
    //メモ化のための配列
    int dp[50];
    scanf("%d",&n);
    dp[0]=1;
    dp[1]=1;

    for(i=2;i<=n;i++)
    {
        dp[i]=dp[i-1]+dp[i-2];
    }
    printf("%d\n",dp[n]);

}


Measured memory_bytes: 3220
n = int(input())
*h, = map(int, input().split())

max_num = 0
temp = 0
for i in range(n-1):
    if h[i]>=h[i+1]:
        temp += 1
    else:
        if max_num < temp:
            max_num = temp
        temp = 0

print(max(max_num, temp))

Measured memory_bytes: 14252
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-8)
#define MOD 1000000007
#define PI 3.141592653589793
#define RMAX 4294967295
#define equals(a,b)(fabs((a)-(b))<EPS)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef complex<double> comp;
typedef vector<complex<double>> vcomp;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef string::const_iterator State;
class ParseError {};
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;



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

	string N;
	cin >> N;
	rep(i, N.size()) {
		if (N[i] == '9') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
n, k = map(int,input().split())

ls = list(map(int,input().split()))
ls = [(x+1)/2 for x in ls]

m = tot = sum(ls[:k])
for i in range(1,n-k+1):
  tot = tot-ls[i-1]+ls[i+k-1]
  m = max(m, tot)
print(m)

Measured memory_bytes: 24804
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int m, n;
std::vector<std::pair<int, int>>mxy, nxy;

int main()
{
	while (true)
	{
		m = n = 0;
		mxy.clear(); nxy.clear();

		in >> m;
		if (m == 0) { return 0; }
		rep(i, m)
		{
			int x, y;
			in >> x >> y;
			mxy.push_back({ x,y });
		}
		in >> n;
		rep(i, n)
		{
			int x, y;
			in >> x >> y;
			nxy.push_back({ x,y });
		}

		std::sort(nxy.begin(), nxy.end());
		std::sort(mxy.begin(), mxy.end());
		for (auto i : nxy)
		{
			auto dif_x = i.first - mxy[0].first;
			auto dif_y = i.second - mxy[0].second;
			bool flag = true;
			for (auto j : mxy)
			{
				auto iter = std::lower_bound(nxy.begin(), nxy.end(), std::make_pair(j.first + dif_x, j.second + dif_y));
				if (iter != nxy.end())
				{
					if (*iter != std::make_pair(j.first + dif_x, j.second + dif_y))
					{
						flag = false;
						break;
					}
				}
			}
			if (flag)
			{
				out << dif_x << " " << dif_y << std::endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3080
from math import sqrt

Q = int(input())

for i in range(Q):
    A, B = list(map(int, input().split()))

    sq = sqrt(A*B)
    sq_int = int(sq)

    ans = sq_int*2 - 2
    if sq_int**2==A*B and A!=B:
        ans -= 1
    if sq_int*(sq_int+1)<A*B:
        ans += 1

    #print(A*B, sq_int)
    print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);

	cout << a[0] << " " << a[1] << " " << a[2] << endl;
	return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  long long N;
  cin >> N;
  
  vector<long long> A(N);
  
  long long num = 0;
  
  long long num2;
  
  long long num3 = 0;
  
  long long num4 = 1e13;
  
  long long num5;
  
  
  for(int i = 0;i < N;++i){
    cin >> A[i];
  }
  
  for(int i = 0;i < N;++i){
    num = A[i] + num;
  }
  
  
  for(int i = 0;i < N;++i){
    num3 = A[i] + num3;
    num2 = num - num3;
    num5 = abs(num2 - num3);
    num4 = min(num5,num4);
  }
  
  cout << num4 << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
// #include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }

int a[N];
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	int n; sc(n);
	for (int i=1; i<=n; i++)
	{
		int x; sc(x);
		++a[x];
	}
	int ma=0;
	for (int i=n-1; i>=1; i--)
		if (a[i]) { ma=i; break; }
	int mi=(ma+1)>>1;
	for (int i=ma; i> mi; i--)
		a[i]-=2;
	a[mi]-=(ma&1)?2:1;
	for (int i=1; i< n; i++)
		if (a[i]< 0) return puts("Impossible"),0;
	for (int i=1; i<=mi; i++)
		if (a[i]) return puts("Impossible"),0;
	puts("Possible");

    return 0;
}


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

#define INF 987654321
#define ll long long

int K, N;
int A[200201];

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

	int mn = -INF; // mx
	for(int i=1; i<N; i++)
		mn = max(mn, A[i]-A[i-1]);
	mn = max(mn, A[0] + K - A[N-1]);
	printf("%d", K-mn);
	return 0;
}

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

using namespace std;

#define int long long

void solve() {
    int n, x, d;
    cin >> n >> x >> d;
    if (d < 0) {
        d *= -1;
        x *= -1;
    }
    if (d == 0) {
        if (x == 0) {
            cout << 1;
            return;
        }
        cout << n + 1;
        return;
    }
    int pr[n + 1];
    pr[0] = 0;
    pr[1] = x;
    for (int i = 2; i <= n; ++i) pr[i] = pr[i - 1] + (i - 1) * d + x;
    vector <pair <int, int> > otr;
    for (int i = 0; i <= n; ++i) {
        int l = 2 * pr[i] - pr[n], r = pr[n] - 2 * pr[n - i];
        //cout << i << ' ' << l << ' ' << r << '\n';
        otr.push_back({l, r});
    }
    sort(otr.begin(), otr.end());
    map <int, int> uf;
    int ans = 0;
    for (int i = 0; i < otr.size(); ++i) {
        int l = otr[i].first, r = otr[i].second, ost = ((l % (2 * d)) + 2 * d) % (2 * d);
        if (uf[ost]) {
            if (r > uf[ost]) {
                ans += (r - max(l, uf[ost] + 2 * d)) / (2 * d) + 1;
                uf[ost] = r;
            }
        }
        else {
            uf[ost] = r;
            ans += (r - l) / (2 * d) + 1;
        }
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 17644