akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(n) for(int i=0;i<n;i++)
#define ll long long
ll mob=1000000007;
using namespace std;
int main()
{ int k,n;
std::cin >> k>>n;
int a[n];
FOR(n) cin>>a[i];
int d[n];
FOR(n)
{

    if(i==0)
    {
        d[0]=a[0]+(k-a[n-1]);
        
    }
    else
    {
        d[i]=a[i]-a[i-1];
    }
}

int q=-1;
FOR(n){
    if(d[i]>q)
    q=d[i];
}
int u=0;
FOR(n)
{
    u+=d[i];


}
cout<<u-q;



return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=s-1; i>=s; i--)

int main(){

    int n; cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    bool pflag = true;

    ll cnt1 = 0;
    ll sum = 0;
    rep(i, n){
        sum += a[i];
        if(pflag){
            if(sum <= 0){
                cnt1 += 1 + abs(sum);
                sum = 1;
            }
        }
        else{
            if(sum >= 0){
                cnt1 += 1 + abs(sum);
                sum = -1;
            }
        }
        pflag = !pflag;
    }

    pflag = false;

    ll cnt2 = 0;
    sum = 0;
    rep(i, n){
        sum += a[i];
        if(pflag){
            if(sum <= 0){
                cnt2 += 1 + abs(sum);
                sum = 1;
            }
        }
        else{
            if(sum >= 0){
                cnt2 += 1 + abs(sum);
                sum = -1;
            }
        }
        pflag = !pflag;
    }

    cout << min(cnt1, cnt2) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
int n, m, col[100009]; vector<int> g[100009];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b; --a, --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	fill(col, col + n, -1); col[0] = 0;
	queue<int> que; que.push(0);
	bool f = true; int sum = 0;
	while (!que.empty()) {
		int u = que.front(); que.pop();
		for (int i : g[u]) {
			if (col[i] == col[u]) f = false;
			if (col[i] == -1) {
				col[i] = col[u] ^ 1;
				sum += col[i];
				que.push(i);
			}
		}
	}
	cout << (f ? 1LL * sum * (n - sum) : 1LL * n * (n - 1) / 2) - m << '\n';
	return 0;
}

Measured memory_bytes: 6272
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <queue>
#define fi first
#define se second
using namespace std;
typedef long long i64;
typedef pair<i64, int> pii;
inline i64 read(int f = 1, i64 x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5;
int n, s[N], u[N], v[N]; pii p[N]; i64 sum;
int main()
{
    n = read(); for(int i = 1; i <= n; ++i) p[i].fi = read(), p[i].se = i, s[i] = 1;
    sort(p+1, p+n+1); 
    for(int i = n; i > 1; --i)
    {
        i64 w = p[i].fi-n+s[i]*2; int j = lower_bound(p+1, p+1+n, pii(w, 0))-p;
        if(p[j].fi != w) return puts("-1"), 0; 
        u[i] = p[i].se, v[i] = p[j].se, s[j] += s[i], sum += s[i];
    }
    if(sum != p[1].fi) return puts("-1"), 0;
    for(int i = 2; i <= n; ++i) printf("%d %d\n", u[i], v[i]);
    return 0;
}

Measured memory_bytes: 4096
using System;
using System.Linq;

class ICPC2007rA{
	static int joseph(int n,int diff,int initial){
		int r=0,i=1;
		for(;i<n;i++)r=(r+diff)%i;
		return (r+1+initial)%n+1;
	}
	static void Main(){
		int[] a;
		for(;(a=Console.ReadLine().Split(' ').Select(int.Parse).ToArray())[0]>0;Console.WriteLine(joseph(a[0],a[1],a[2]-1)));
	}
}

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

static const int MAX = 100000;
static const int INFTY = 1e+9 + 7;

int power(int a, int n){
    if(n == 0) return 1;
    if(a == 0) return 0;
    return (a * power(a, n - 1)) % INFTY;
}

int main(){
    int n, a, A[MAX] = {}; 
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        A[a]++;
    }

    bool flag = true;
    if((n % 2) && (A[0] == 1)){
        for(int i = 2; i < n; i += 2)
            if(A[i] != 2){
                flag = false;
                break;
            }
    } else if(!(n % 2)) {
        for(int i = 1; i < n; i += 2)
            if(A[i] != 2){
                flag = false;
                break;
            }
    } else flag = false;

    if(flag) cout << power(2, n / 2) << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 1408
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a, b = map(int, input().split())

a_set = set(prime_factorize(a))
b_set = set(prime_factorize(b))
cd = list(a_set & b_set)
print(len(cd)+1)


Measured memory_bytes: 3064
#include <stdio.h>
#include<stdlib.h>

int main(){
  
  int A[1000];
  int i,j,key,N;
  
  scanf("%d",&N);
  
  if(N<1 || N>100) exit(1);
  
  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0; i<N-1; i++)
    printf("%d ",A[i]);
  
  printf("%d",A[i]);
  printf("\n");
  
  for(j=1; j<N; j++){
    key = A[j];
    i=j-1;
    while((i>=0) && (A[i]>key)){
      A[i+1] = A[i];
      i=i-1;
    }
    A[i+1] = key;
    
    for(i=0; i<N-1; i++)
      printf("%d ",A[i]);
    
    printf("%d",A[i]);
    printf("\n");
  }
  return 0;
    }
  

Measured memory_bytes: 608
a = list(map(int,input().split()))
b = list(map(int,input().split()))

b.sort(reverse=True)
#print(b)

s = 0
for i in range(len(b)):
  s += b[i]
  
flag = True
for i in range(a[1]):
  if b[i] < (s / (4*a[1])):
    flag = False

if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
      	int sum = 0;
      	int x = 0;
        int ans = 0;
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);
        int d = int.Parse(input[3]);
      　if(d <= a){
          ans = d;
        }
        else if(d <= a+b){
          ans = a;
        } else{
          ans = a - (d-(a+b));
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 17756
def main():
    H, W, K = map(int, input().split())
    S = [list(map(int, list(input()))) for i in range(H)]
    ans = (H-1)*(W-1)
    for i in range(2**(H-1)):
        border = []
        tmp = 0
        for j in range(H-1):
            if (i >> j) % 2 == 1:  # jの下に線を引く
                border.append(j)
                tmp += 1

        border.append(H-1)
        num = [0]*(tmp+1)
        flag = True
        prev = 0
        for k, x in enumerate(zip(*S)):
            sep = False
            for j, y in enumerate(border):

                if j == 0:
                    prev = 0
                else:
                    prev = border[j-1]+1

                if sep:
                    num[j] = sum(x[prev:y+1])
                elif num[j] + sum(x[prev:y+1]) > K:

                    #print(k, num[j], sum(x[prev:y+1]))
                    sep = True
                    tmp += 1
                    num[j] = sum(x[prev:y+1])
                    for l in range(j):
                        if l == 0:
                            num[l] = sum(x[:border[l]+1])
                        else:
                            num[l] = sum(x[border[l-1]:border[l]+1])
                else:
                    num[j] += sum(x[prev:y+1])

                if num[j] > K:
                    flag = False
                    break

        #print(border, tmp, flag)
        if flag:
            ans = min(ans, tmp)
        else:
            continue

    print(ans)


main()


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int H, W, N; cin >> H >> W >> N;
  int result = min( (N+(H-1))/H, (N+(W-1))/W );
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> n >> k >> x;

	if(n<0)n=-n;

	y = n/x;
	n-=(min(k,y))*x;
	k-=(min(k,y));

	if(k%2)
		cout<<abs(n-x)<<endl;
	else
		cout<<n<<endl;
}

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

#define endl '\n'

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

    int n; cin >> n;
    long long a[n], pots[62], M = 1e9 + 7;
    vector<long long> bits(62, 0);
    pots[0] = 1LL;
    for (int i = 1; i<62; i++) pots[i] = pots[i-1] * 2LL % M;
    for (int i=0; i<n; i++){
        cin >> a[i];
        long long x = a[i], pos = 0;
        while(x){
            bits[pos++] += (x & 1LL);
            x >>= 1LL;
        }
    }

    long long ans = 0;
    for (int i=0; i<n-1; i++){
        int pos = 0;
        long long x = a[i];
        while(x){
            bits[pos++] -= (x & 1LL);
            x >>= 1LL;
        }
        pos = 0;
        while(a[i]){
            if (a[i] & 1LL){
                ans = (ans + (((n - i - 1LL) - bits[pos]) * pots[pos]) % M)%M;
            } else{
                ans = (ans + (bits[pos] * pots[pos])%M)%M;
            }
            pos++;
            a[i] >>= 1LL;
        }
        for (; pos < 62; pos++) ans = (ans + (bits[pos] * pots[pos])%M)%M;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    string S;
    cin>>S;
    cout<< ( S[2]==S[3] and S[4]==S[5] ? "Yes" : "No" )<<"\n";

}

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


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

const int MAX = 202020;
const int MOD = 1e9 + 7;

int fac[MAX], finv[MAX], inv[MAX];

//前処理Ｏ(n)
void CombInit() {
  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;
  }
}

// 二項係数計算Ｏ(1)_nCk
int nCk(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;
}

signed main() {
  int N, M, K;
  cin >> N >> M >> K;

  CombInit();

  int tmp = 0;
  for (int i = 1; i <= M; i++) {
    tmp += (M - i) * i % MOD;
    tmp %= MOD;
  }
  tmp *= N * N % MOD;
  tmp %= MOD;
  tmp *= nCk(N * M - 2, K - 2);
  tmp %= MOD;

  int tmpp = 0;
  for (int i = 1; i <= N; i++) {
    tmpp += (N - i) * i % MOD;
    tmpp %= MOD;
  }
  tmpp *= M * M % MOD;
  tmpp %= MOD;
  tmpp *= nCk(N * M - 2, K - 2);
  tmpp %= MOD;

  cout << (tmp + tmpp) % MOD << endl;
  return 0;
}


Measured memory_bytes: 4992
def resolve():
    N,A,B=map(int,input().split())
    if A==0:
        print(0)
        return
    if B==0:
        print(N)
        return

    C=A+B
    D=N//C
    S=N%C

    print(A*D+min(A,S))



if __name__ == "__main__":
    resolve()

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

int main()
{
 ll a,b,c,k,s,ans;
  cin>>a>>b>>c>>k;
  if(k<=a)
   cout<<k<<endl;
  else if(k<=(a+b))
    cout<<a<<endl;
  else if(k<=(a+b+c))
  {
    s=k-(a+b);
    ans=a-s;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;


ll powmod(ll k){
    ll ret=1;
    ll n=2LL;
    while(k>0){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k/=2;
    }
    return ret;
}

bool even[3][101010],odd[3][101010];
ll dp[2][101010];
int main(){
    int n,m;
    cin>>n>>m;
    memset(odd,1,sizeof odd);
    memset(even,1,sizeof even);
    int cnt=0;
    set<pair<pint,int>> st;

    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        --a;--b;
        if(a>b)swap(a,b);
        if(st.count({{a,b},c})){
            if(b-a<3)odd[b-a][b]=false;
        }
        else if(st.count({{a,b},!c})){
            if(b-a<3)even[b-a][b]=false;
            else{
                cout<<0<<endl;
                return 0;
            }
        }
        else if(a!=b)++cnt;
        else if(c)even[0][b]=false;
        else odd[0][b]=false;
        st.insert({{a,b},c});
    }
    dp[0][0]=even[0][0];
    dp[1][0]=odd[0][0];
    rep(i,n-1){
        if(even[0][i+1]){
            if(even[1][i+1]&&even[2][i+1])dp[0][i+1]+=dp[0][i];
            if(odd[1][i+1]&&odd[2][i+1])dp[0][i+1]+=dp[1][i];
        }
        if(odd[0][i+1]){
            if(odd[1][i+1]&&even[2][i+1])dp[1][i+1]+=dp[0][i];
            if(even[1][i+1]&&odd[2][i+1])dp[1][i+1]+=dp[1][i];
        }
        dp[0][i+1]%=mod;
        dp[1][i+1]%=mod;
    }
    cout<<(dp[0][n-1]+dp[1][n-1])*powmod((ll)n*(n-1)/2-cnt)%mod<<endl;
    
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define     ll              long long
#define     MAX             100000
#define     FI              freopen("input.txt","r",stdin)
#define     FO              freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define     sc(a)           scanf("%d",&a)
#define     sc2(a,b)        scanf("%d %d",&a,&b)


int main()
{
    ll n;
    cin>>n;
    string s;
    set<string>st;
    while(n--)
    {
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<"\n";
    return 0;
}



Measured memory_bytes: 19152
(defun main ()
  (let* ((a (read)) (b (read)) (c (read)) (cnt 0))
    (when (= a b) (incf cnt))
    (when (= a c) (incf cnt))
    (when (= b c) (incf cnt))
    (write-line (if (= cnt 1) "Yes" "No"))))

(main)


Measured memory_bytes: 23476
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  long K;
  
  cin>>N>>K;
  
  vector<int> A(N+1);
for (int i = 1; i < N+1; i++) {
  cin >> A.at(i);
}
  
  vector<int> B(N);
for (int i = 0; i < N; i++) {
  //cin >> A.at(i);
  B.at(i)=0;
}
  
  vector<int> C(N+1);
for (int i = 1; i < N+1; i++) {
  //cin >> A.at(i);
  C.at(i)=0;
}
  
  
  int sw=1;
  B.at(0)=1;
  C.at(1)=1;
  
  int res=0;
 
  
  for(int i=0;i<2*pow(10,5);i++){
    sw=A.at(sw);
    B.at(i+1)=sw;
    C.at(sw)++;
    if(C.at(sw)==2){
      res=i;
      break;
    }
  }
  
  
  
  int sw1;
  for(int i=0;i<2*pow(10,5);i++){
    if(B.at(i)==sw){
      sw1=i;
      break;
    }
  }
  int sw2;
  sw2=res+1-sw1;
  
  if(K<sw1){
    cout<<B.at(K)<<endl;
  }else{
    cout<<B.at((K-sw1)%sw2+sw1)<<endl;
  }
  
  
  
  
  
}



  
  

Measured memory_bytes: 5596
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)














int main() {
    string s;
    cin >> s;
    ll dp[13] = {};
    dp[0] = 1;
    REP(i, s.size()){
        ll tmp[13] = {};
        REP(j, 13){
            if(s[i] == '?'){
                REP(k, 10){
                    tmp[(j * 10 + k) % 13] += dp[j];
                    tmp[(j * 10 + k) % 13] %= MOD;
                }
            }
            else{
                tmp[(j * 10 + (s[i] - '0')) % 13] += dp[j];
                tmp[(j * 10 + (s[i] - '0')) % 13] %= MOD;
            }
        }
        REP(j, 13){
            dp[j] = tmp[j];
        }
    }
    cout << dp[5] << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

int main(){
	int n; cin >> n;
	vector<int> v(n);
	int two=0, four=0;
	rep(i,n){
		int a; cin>>a;
		if (a%4==0){
			four++;
		}else if (a%2==0){
			two++;
		}
	}
	if (two >= 2){
		cout << (two+four*2>=n? "Yes":"No") << endl;
	}else{
		cout <<(four*2+1>=n?"Yes":"No") << endl;
	}
}

Measured memory_bytes: 640
n=int(input())
ans=0
cnt=-(10**9)-1
li=[]
for i in range(n):
    X,L=map(int,input().split())
    li.append([X+L,L])
li=sorted(li,key=lambda x:x[0])
for i in range(n):
    if cnt>li[i][0]-li[i][1]*2:
        ans+=1
    else:
        cnt=li[i][0]
print(n-ans)



Measured memory_bytes: 22128
def main():
    i = list(map(int, input().split()))

    for j in i:
        if isinstance(j, int) == False:
            return
        if j < 0 or 10**9 < j:
            return
    if i[0] == i[1]:
        return

    a = i[0]
    b = i[1]

    k = (a + b)/2

    if k*2 % 2 == 0:
        print(int(k))
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    l = I()
    print((l/3)**3)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var nums = cin.ReadIntArray(3);
            var ans = Max(nums[2] - (nums[0] - nums[1]), 0);
            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 13268
/**
 *    author:  tourist
 *    created: 31.03.2018 19:01:07       
**/
#include <bits/stdc++.h>

using namespace std;

const int md = (int) 1e9 + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) {
    a -= md;
  }
}

int dp[2][2][2][2];
int new_dp[2][2][2][2];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = (int) s.length();
  if (n == 1) {
    cout << (s == "0" ? 0 : 1) << '\n';
    return 0;
  }
  dp[1][0][0][0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int last = 0; last < 2; last++) {
      for (int last2 = 0; last2 < 2; last2++) {
        for (int was = 0; was < 2; was++) {
          for (int good = 0; good < 2; good++) {
            new_dp[last][last2][was][good] = 0;
          }
        }
      }
    }
    for (int last = 0; last < 2; last++) {
      for (int last2 = 0; last2 < 2; last2++) {
        for (int was = 0; was < 2; was++) {
          for (int good = 0; good < 2; good++) {
            int ft = dp[last][last2][was][good];
            if (ft == 0) {
              continue;
            }
            int from = 0, to = 1;
            if (i == n) {
              from = to = 1;
            } else {
              if (s[i] != '?') {
                from = to = (int) (s[i] - '0');
              }
            }
            for (int c = from; c <= to; c++) {
              if (c == 0) {
                add(new_dp[c][last][was][good], ft);
              } else {
                if (last == 0) {
                  add(new_dp[c][last][was][good], ft);
                } else {
                  int new_was = was, new_good = good;
/*                  if (i == 1 || i == n - 1) {
                    new_good = 1;
                  } else {*/
                    if (was && i % 2 == 1) {
                      new_good = 1;
                    } else {
                      if (i % 2 == 0) {
                        new_was = 1;
                      }
                    }
//                  }
                  add(new_dp[c][last][new_was][new_good], ft);
                }
              }
            }
          }
        }
      }
    }
    for (int last = 0; last < 2; last++) {
      for (int last2 = 0; last2 < 2; last2++) {
        for (int was = 0; was < 2; was++) {
          for (int good = 0; good < 2; good++) {
            dp[last][last2][was][good] = new_dp[last][last2][was][good];
          }
        }
      }
    }
  }
  int ans = 0;
  for (int last = 0; last < 2; last++) {
    for (int last2 = 0; last2 < 2; last2++) {
      for (int was = 0; was < 2; was++) {
        add(ans, dp[last][last2][was][1]);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


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

signed main()
{
  int n;
  vector<int> kanade;
  cin >> n;

  for (int i = 0; i < n; i++) {
    kanade.clear();
    for (int j = 0; j < 10; j++) {
      int tmp;
      cin >> tmp;
      kanade.push_back(tmp);
    }

    int b = 0, c = 0;
    bool hayami = true;
    for (int j = 0; j < 10; j++) {
      if (b == 0 || b < kanade[j]) {
        b = kanade[j];
      } else if (c == 0 || c < kanade[j]) {
        c = kanade[j];
      } else {
        hayami = false;
      }
    }

    if (hayami) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

  return (0);
}

Measured memory_bytes: 3140
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)


int main(){
    int n;
    scanf("%d",&n);
    long sum=0;
    F(i,1,n+1){
        if(i%3!=0 && i%5!=0){
            sum+=i;
        }
    }
    printf("%ld\n",sum);
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  int i, j;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int m = 0;
  vector<int> result(n + 1, 0);
  for (i = n; i > 0; i--) {
    int sum = 0;
    for (j = 0; j <= n; j += i) {
      sum += result[j];
    }
    if (sum % 2 != a[i]) {
      result[i] = 1;
      m++;
    }
  }
  cout << m << endl;
  for (i = 1; i <= n; i++) {
    if (result[i]) {
      cout << i << ' ';
    }
  }
  if (m) {
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;

int main() {
	long long int k, n, a[200000], min;
	cin >> k >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	min = a[n - 1] - a[0];
	for (int i = 0; i < n - 1; i++) {
		if (k - (a[i + 1] - a[i]) < min) {
			min = k - (a[i + 1] - a[i]);
		}
	}
	cout << min << endl;
	return 0;
}

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

int main()
{
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long num_m = a * c;
    long long num;
    num = a * d;
    if (num_m < num)
    {
        num_m = num;
    }
    num = b * c;
    if (num_m < num)
    {
        num_m = num;
    }
    num = b * d;
    if (num_m < num)
    {
        num_m = num;
    }
    cout << num_m << endl;
}

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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void precal() {

	return;
}

bool solve() {
	lli w, h, x, y;
	string s;
	if ( cin >> w >> h >> x >> y );
	else return false;
	
	cout << (w*h)/2. << ' ';
	
	if ( x*2 == w and y*2 == h ) cout << 1 << '\n';
	else cout << 0 << '\n'; 
	
	return true;
}

int main() {
	precal();
	int t = INT_MAX;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		if ( !solve() ) break;
	}
	return 0;
}


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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a


using ll = long long;

int main() {
    bool ans = false;
    int k;
    vector<vector<int>> a(3,vector<int>(3));
    vector<vector<bool>> aja(3,vector<bool>(3,false));
    REP(i, 3){
        REP(j, 3){
            cin >> a[i][j];
        }
    }
    
    IN(int, n);
    REP(i, n){
        cin >> k;
        REP(i, 3){
            REP(j, 3){
                if (a[i][j]==k) {
                    aja[i][j] = true;
                }
            }
        }
    }
    
    REP(i, 3){
        if (aja[i][0] && aja[i][1] && aja[i][2]) {
            ans = true;
        }
    }
    
    REP(i, 3){
        if (aja[0][i] && aja[1][i] && aja[2][i]) {
            ans = true;
        }
    }
    
    if (aja[0][0] && aja[1][1] && aja[2][2]) {
        ans = true;
    }
    if (aja[0][2] && aja[1][1] && aja[2][0]) {
        ans = true;
    }
    
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
str = input()

K = (int(str.split()[0]))
X = (int(str.split()[1]))
min = -1000000
max = 1000000

print("{}".format(X - K + 1), end="")
for i in range(X - K + 2, X + K) :
	print(" ", end="")
	if (min <= i and i <= max):
		print("{}".format(i), end="")
print()


Measured memory_bytes: 3060
w,h,n=map(int,input().split())
x0,x1,y0,y1=0,w,0,h
for i in range(n):
  x,y,a=map(int,input().split())
  if(a==1):
    x0=max([x0,x])
  elif(a==2):
    x1=min([x1,x])
  elif(a==3):
    y0=max([y0,y])
  else:
    y1=min([y1,y])
if(x0>=x1 or y0>=y1):
  print(0)
else:
  print((x1-x0)*(y1-y0))

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}

int main(){
 ll a,b; cin>>a>>b;
  
  cout<< (b-1+a-1-1)/(a-1)<<endl;
  
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, W;
    cin >> n >> W;
    vector<int> w(n), v(n);
    for(int i = 0; i < n; ++i){
        cin >> w[i] >> v[i];
    }

    vector<vector<ll>> dp(n + 1, vector<ll>(W + 1));
    for(int i = 1; i <= n; ++i){
        for(int j = 0; j <= W; ++j){
            dp[i][j] = dp[i-1][j];
            if(j >= w[i-1]) dp[i][j] = max(dp[i][j], dp[i-1][j-w[i-1]] + v[i-1]);
        }
    }

    ll ans = 0;
    for(int i = 0; i <= W; ++i){
        ans = max(ans, dp[n][i]);
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 80256
import numpy as np
c1 = list(map(int,input().split()))
A = np.array(c1)
c1 = list(map(int,input().split()))
B = np.array(c1)
c1 = list(map(int,input().split()))
C = np.array(c1)

D = A-B 
D1 = list(D)
D1 = set(D1)
if len(D1) == 1:
    pass 
else:
    print('No')
    exit()

E = B-C
E1 = list(E)
E1 = set(E1) 
if len(E1)== 1:
    print('Yes') 
else:
    print('No')

Measured memory_bytes: 27272
#include<iostream>
#include<sstream>
#include <cmath>
using namespace std;
int main()
{
	// 整数の入力
	int a;
	//cin >> a;
	// スペース区切りの整数の入力
	int b,c;
	cin >> b >> c;
	// 文字列の入力
	string s;
	//cin >> s;
	// 出力
	int diff = abs(b+c);
	if((diff & 1) == 0) {
		cout << diff/2 << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

vector<ll> l(100001),r(100001);
ll n,q;
string s;
ll ans;
//sum.at(i)はiまでのACの数
vector<ll> sum(100001,0);

int divide(int l,int r)
{
  if(l==1) return ans=sum.at(r-1);
  else ans=sum.at(r-1)-sum.at(l-2);

  if(s.at(l-2)=='A' && s.at(l-1)=='C') ans--;

  return ans;
}

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

  rep(i,q) cin>>l.at(i)>>r.at(i);

  //ACの累積和を求める
  char tmp;
  rep(i,n)
  {
    if(i==0) tmp=s.at(i);
    else
    {
      if(tmp=='A' && s.at(i)=='C') sum.at(i)=sum.at(i-1)+1;
      else sum.at(i)=sum.at(i-1);
    }
    tmp=s.at(i);
  }

  rep(i,q) cout<<divide(l.at(i),r.at(i))<<endl;


}

Measured memory_bytes: 3456
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class AC>void r(AC &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,x,y; 
int main(){
    r(n);
    r(x);
    r(y);
    if((x-y)%2==0)puts("Alice");
    else puts("Borys");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
int main()
{
	boost
	vector<ll>v[26];
	string s,t;
	cin>>s>>t;
	char ch='a';
	for(ll i=0; i<s.size(); i++)
	{
		ll val=s[i]-ch;
		v[val].pb(i+1);
	}
	ll ans=0;
	for(ll i=0; i<t.size(); i++)
	{
		ll val=t[i]-ch;
		ll we=ans%(s.size());
		if(v[val].size()==0)
		{
			cout<<"-1"<<endl;
			return 0;
		}
		ll temp=upper_bound(v[val].begin(),v[val].end(),we)-v[val].begin();
		if(temp==v[val].size())
		{
			ans=ans+s.size()-we+v[val][0];	
		}
		else
		{
			ans=ans+v[val][temp]-we;
		}
	//	cout<<ans<<" "<<temp<<" "<<v[val][temp]<<t[i]<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

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


int main() {
  string s;
  
  cin >> s;
  
  for(int i=0; i<s.size()-1; i++){
    if(s.at(i) == s.at(i+1)){
      cout << "Bad";
      return 0;
    }
  }
  cout << "Good";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int ca){
    int a,b,c; cin>>a>>b>>c;

    cout<<c<<" "<<a<<" "<<b<<endl;

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(1);
#endif
    return 0;
}


Measured memory_bytes: 256
Main(myin());
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//不明値:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var list = myconv(input[1],4);
  var output = 0;
  var max = Math.max.apply(null,list);
  for(var i = 0; i < max; i++){
    var check = false;
    for(var j = 0; j < N; j++){
      if(list[j] != 0){
        if(!check){
         check = true;
          output++;
        }
        list[j]--;
      }else{
        check = false;
      }
    }
  }
  myout(output);
}

Measured memory_bytes: 11468
#include <bits/stdc++.h>
#define inf 200000000000
using namespace std;
// 0-indexed
struct Dinic {
  struct edge {
    int to;
    long long cap;
    int rev;
  };
  vector<vector<edge>> lst;
  vector<int> completed;
  vector<int> dist;
  Dinic(int n = 1) {
    // if 1-indexed
    //++n;
    lst.resize(n);
    completed.resize(n);
    dist.resize(n);
  }
  bool add(int start, int goal, long long capacity) {
    lst[start].push_back(
        (edge){goal, capacity, (int)lst[goal].size()});
    lst[goal].push_back(
        (edge){start, 0, (int)lst[start].size() - 1});
    return 1;
  }
  // dist = time from start to now number
  void distbfs(int start) {
    fill(dist.begin(), dist.end(), -1);
    queue<int> bfsqu;
    dist[start] = 0;
    bfsqu.push(start);
    while(bfsqu.size() > 0) {
      int now = bfsqu.front();
      bfsqu.pop();
      for(int i = 0; i < lst[now].size(); ++i) {
        edge* nowe = &lst[now][i];
        if(nowe->cap > 0 && dist[nowe->to] < 0) {
          dist[nowe->to] = dist[now] + 1;
          bfsqu.push(nowe->to);
        }
      }
    }
  }
  long long pathdfs(int now, int goal, long long nf) {
    if(now == goal) return nf;
    for(int& i = completed[now]; i < lst[now].size(); ++i) {
      edge* e = &lst[now][i];
      if(e->cap > 0 && dist[now] < dist[e->to]) {
        long long ans =
            pathdfs(e->to, goal, min(nf, e->cap));
        if(ans > 0) {
          e->cap -= ans;
          lst[e->to][e->rev].cap += ans;
          return ans;
        }
      }
    }
    return 0;
  }
  long long solve(int start, int goal) {
    long long ans = 0, nf = 0;
    while(1) {
      // bfs
      distbfs(start);
      // cannnot go to goal from start
      if(dist[goal] < 0) return ans;
      // reset
      fill(completed.begin(), completed.end(), 0);
      while((nf = pathdfs(start, goal, inf)) > 0) ans += nf;
    }
    return -1;
  }
};

int n;
long long a[104] = {0};
long long sum = 0;
Dinic dn;

int main() {
  cin >> n;
  dn = Dinic(n + 2);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i) {
    sum += max(0LL, a[i]);
    dn.add(0, i + 1, max(0LL, -a[i]));
    dn.add(i + 1, n + 1, max(0LL, a[i]));
    for(int j = 2; j * (i + 1) <= n; ++j)
      dn.add(i + 1, j * (i + 1), inf);
  }
  cout << sum - dn.solve(0, n + 1) << endl;
  return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(C-B<=0){
    cout << "Yes" << endl;
  }
  else if(A-D<=0){
    cout << "No" << endl;
  }
  else if(C%B == 0 && A%D !=0){
    if(C/B <= A/D +1){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" <<endl;
    }
  }
  else if(C%B != 0 && A%D == 0){
    if(C/B +1 <= A/D){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" <<endl;
    }
  }
  else if(C/B <= A/D){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3636
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let h: usize = sc.read();
    let w: usize = sc.read();
    let k: usize = sc.read();
    let c: Vec<Vec<char>> = (0..h).map(|_| sc.chars()).collect::<Vec<_>>();
    let mut ans = vec![vec![0; w]; h];
    let mut count = 1;
    for i in 0..h {
        for j in 0..w {
            if c[i][j] == '#' {
                ans[i][j] = count;
                count += 1;
            }
        }
    }
    assert_eq!(count - 1, k);

    for i in 0..h {
        for j in 1..w {
            if ans[i][j] == 0 && ans[i][j - 1] != 0 {
                ans[i][j] = ans[i][j - 1];
            }
        }
        for j in (0..(w - 1)).rev() {
            if ans[i][j] == 0 && ans[i][j + 1] != 0 {
                ans[i][j] = ans[i][j + 1];
            }
        }
    }
    for j in 0..w {
        for i in 1..h {
            if ans[i][j] == 0 && ans[i - 1][j] != 0 {
                ans[i][j] = ans[i - 1][j];
            }
        }
        for i in (0..(h - 1)).rev() {
            if ans[i][j] == 0 && ans[i + 1][j] != 0 {
                ans[i][j] = ans[i + 1][j];
            }
        }
    }

    for i in 0..h {
        for j in 0..w {
            if j > 0 {
                sc.write(" ".to_string());
            }
            sc.write(format!("{}", ans[i][j]));
        }
        sc.write("\n".to_string());
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write(&mut self, s: String) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4860
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    a=vcat(vcat([500],parseMap(split(readline()))),[0])
    ans=1000
    kabu=0
    for i in 1:n
        if a[i]>=a[i+1]<=a[i+2]
            ans,kabu=ans-ans÷a[i+1]*a[i+1],kabu+ans÷a[i+1]
        elseif a[i]<=a[i+1]>=a[i+2]
            ans,kabu=ans+a[i+1]*kabu,0
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 171112
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
long long map[100001];


int main(){
	int N, num1, num2;
	long long K;
	cin >> N >> K;
	for (int i =0;i<N;i++){
		cin >> num1 >> num2;
		map[num1] += num2;
	}
	for (int i=1;i<100001;i++){
		if (K > map[i]){
			K -= map[i];
		}else{
			cout << i << endl;
			break;
		}
	}
	

}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    ll n, k, a[1000 + 100], ke[1000 * (1000 + 1) / 2 + 100], ke_cou = 0, add;
    ll ans = 0, want, cou = 0;

    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    for(int i = 0; i < n; i++){
        ke[ke_cou++] = a[i];
        add = a[i];
        for(int j = i + 1; j < n; j++){
            add += a[j];
            ke[ke_cou++] = add;
        }
    }

    for(int i = 45; i >= 0; i--){
        want = ans ^ (1LL<<i);
        cou = 0;
        for(int j = 0; j < ke_cou; j++){
            if((want & ke[j]) == want)cou++;
        }
        if(cou >= k)ans = want;
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main() {
  int n,m,x,k,l;
  cin >> n >> m >> x;
  vector<int>num(m);
  for (int i = 0; i < m; i++) {
    cin >> num.at(i);
  }
  for (int i = 0; i < m; i++) {
    if (num.at(i) < x && x < num.at(i+1)) {
      k = i+1;
      break;
    }
 }
 for (int i = m-1; 0 <= i; i--) {
   if (num.at(i) < x && x < num.at(i+1)) {
     l = m-i-1;
     break;
   }
 }
  int ans = min(k,l);
  cout << ans << endl;
}  

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b = map(int, input().split())
    if a < 10 and b < 10:
        print(a * b)
    else:
        print(-1)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int n;
int ans;

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        int a;cin>>a;
        while(a%2==0){
            a/=2;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
# Segment tree (+)
class SegmentTree:
    _f = None
    _data = None
    _offset = None
    _size = None

    def __init__(self, size, f):
        self._f = f
        self._size = size
        t = 1
        while t < size:
            t *= 2
        self._offset = t - 1
        self._data = [0] * (t * 2 - 1)

    def update(self, index, value):
        f = self._f
        data = self._data
        i = self._offset + index
        data[i] = value
        while i >= 1:
            i = (i - 1) // 2
            data[i] = f(data[i * 2 + 1], data[i * 2 + 2])

    def query(self, start, stop):
        def iter_segments(data, l, r):
            while l < r:
                if l & 1 == 0:
                    yield data[l]
                if r & 1 == 0:
                    yield data[r - 1]
                l = l // 2
                r = (r - 1) // 2
        f = self._f
        it = iter_segments(self._data, start + self._offset,
                           stop + self._offset)
        result = next(it)
        for e in it:
            result = f(result, e)
        return result


from sys import stdin
readline = stdin.readline

from operator import add

N, M = map(int, readline().split())
ab = [list(map(int, readline().split())) for _ in range(M)]

ab.sort(key=lambda x: x[1])
st = SegmentTree(N - 1, add)

result = 0
for a, b in ab:
    a, b = a - 1, b - 1
    if st.query(a, b) != 0:
        continue
    result += 1
    st.update(b - 1, 1)
print(result)


Measured memory_bytes: 29304