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

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.reserve(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

bool same(int x, int y) { return root(x) == root(y); }

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  int N;
  cin >> N;
  vector<bool> v(101, false);
  for (int i = 0; i < 101; i += 4) {
    v[i] = true;
    for (int j = 7; j < 101 - i; j += 7) {
      v[i + j] = true;
    }
  }
  cout << (v[N] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    System.out.println(n<k ? n*x : k*x+(n-k)*y);
  }
}


Measured memory_bytes: 35812
r,g,b,n = map(int, input().split())
ans = 0
for i in range(n // r + 1):
  res = n - r * i
  for j in range(res // g + 1): 
    res2 = res - g * j
    if res2 % b == 0:
      ans += 1
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int K,A,B;
    cin>>K;
    cin>>A>>B;
    int a,b;
    if(A%K==0){
        a=A/K;
    }
    else a=A/K+1;
    b=B/K;
    if(a>b) cout<<"NG";
    else cout<<"OK";
}

Measured memory_bytes: 3604
import java.io.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String s=r.readLine();
		int n = Integer.parseInt(s);
		int money=100000;
		try {
			for(;n>0;n--){
				money*=1.05;
				if (money%1000>0){
					money = ((money/1000)+1)*1000;
				}
			}
			System.out.println(money);
		} catch (Exception err) {
			System.exit(0);
		}
	}
}

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

int main(){
  int X,N;
  cin >> X >> N;
  vector<bool> V(102,true);
  
  for(int i=0;i<N;i++){
    int p;
    cin >> p;
    V[p] = false;
  }
  
  for(int i=0;;i++){
    if(X-i>=0){
      if(V[X-i]){
        cout << X-i << endl;
        return 0;
      }
    }
    if(X+i<=101){
      if(V[X+i]){
        cout << X+i << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
while(true){
int n;
cin >> n;
if(n == 0)return 0;
int a[n];
for(int i = 0; i < n; i++)
cin >> a[i];

int max = 0;
int min = 1000;
int sum = 0;

for(int i = 0 ; i < n ; i++){
	if(a[i] > max)
	max = a[i];
	if (a[i] < min)
	min = a[i];
	sum += a[i];
}
cout << (sum-max-min)/(n-2) << endl;

}
}

Measured memory_bytes: 3040
#include<stdio.h>
void draw(int x,int y);
int w,h,c[51][51];
int main(){
	int i,j;
	int count;
	scanf("%d %d",&w,&h);
	while((w!=0)&&(h!=0)){
		count=0;
		for(j=0;j<h;j++){
			for(i=0;i<w;i++){
				scanf("%d",&c[j][i]);
			}
		}
		for(i=0;i<w;i++){
			c[h][i]=0;
		}
		for(i=0;i<h;i++){
			c[i][w]=0;
		}
		for(i=0;i<w;i++){
			for(j=0;j<h;j++){
				if(c[j][i]==1){
					count++;
					draw(j,i);
				}
			}
		}
		printf("%d\n",count);
		scanf("%d %d",&w,&h);
	}
	return 0;
}
void draw(int x,int y){
	int i,j;
	c[x][y]=0;
	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			if(c[x-1+i][y-1+j]==1){
				draw(x-1+i,y-1+j);
			}
		}
	}
}

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

using namespace std;

#define fileInput(problemName) freopen ((string(problemName) + ".inp").c_str(), "r", stdin);freopen ((string(problemName) + ".out").c_str(), "w", stdout);
#define ll long long

const ll inf = 1e9 + 7;
const ll MOD = 1e9 + 7;
const ll N = 3e3 + 7;

string s1, s2, ans = "";
int n, m;
int f[N][N];

void modString(string &s) {
    s = '*' + s;
    return;
}

main() {
    //fileInput("lcs");
    cin >> s1 >> s2;
    n = s1.length();
    m = s2.length();
    modString(s1);
    modString(s2);
    memset(f, 0, sizeof(f));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s1[i] == s2[j]) f[i][j] = f[i - 1][j - 1] + 1;
            else f[i][j] = max(f[i - 1][j], f[i][j - 1]);
        }
    }
    int i = n, j = m;
    while (i >= 1 and j >= 1) {
        if (s1[i] == s2[j]) ans = s1[i] + ans, i--, j--;
        else {
            if (f[i - 1][j] > f[i][j - 1]) i--;
            else j--;
        }
    }
    cout << ans << endl;
}

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

int main(){
		int a,b,n,amari,ans=0;
		while(cin>>a){
			ans=0;
			cin>>b>>n;
			int dt[n+1];
			dt[0]=a/b;
			amari=a%b*10;
			for(int i=1;i<n+1;i++){
				dt[i]=amari/b;
				amari=amari%b*10;
				ans+=dt[i];
			}
			cout<<ans<<endl;
		}
		return 0;
}

Measured memory_bytes: 1160
import numpy as np
n = int(input())
dict = {}


x =[]
for i in range(n):
    x1, y1 = [i for i in input().split()]
    x.append(x1+"{0:03d}".format(100-int(y1)))

for i in range(len(x)):
    print(np.argsort(x)[i]+1)


Measured memory_bytes: 21416
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    ll N,K, ans;
    cin >> N >> K;

    if(2*N <= K){
        ans=N;
    } else if(N < K){
        ans = K-N;
    } else if(N==K) {
        ans = 0;
    } else if(N >= K*2) {
        ans = N%K;
    } else {
        ans = N%(N-K);
    }

    ans = min(ans, abs(K-ans));

    cout << ans << endl;

    return 0;
}



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

int main() {
  vector<string> ss(3);
  for (int i = 0; i < 3; i++) {
    cin >> ss[i];
  }

  string t = "";
  for (string &s : ss) t += s[0];
  cout << t << endl;
  return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    char s[1000];
    int c=0;
    scanf("%s",s);
    int n=strlen(s);
    if(s[0]=='A'){
        if(s[1]>'z'||s[1]<'a'){
            printf("WA\n");
            return 0;
        }

            for(int i=2;i<n-1;i++){
                if(s[i]>'z'||s[i]<'a'){
                    if(s[i]=='C'&&c==0)
                        c++;
                    else{
                        printf("WA\n");
                        return 0;}
                }

            }
            if(s[n-1]>'z'||s[n-1]<'a'){
                printf("WA\n");
                return 0;
            }


            if(c==1)
                printf("AC\n");
            else
                printf("WA\n");


    }
    else
        printf("WA\n");
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=1e5+5,M=6000,Z=2501;
typedef long long ll;
ll sum(ll x,ll y){
    ll res=0;
    while(x){
        res+=x%y;
        x/=y;
    }
    return res;
}
int main()
{
    ll N,S,b;
    scanf("%lld%lld",&N,&S);
    if(S>N){
        puts("-1");
        return 0;
    }
    if(S==N){
        printf("%lld\n",N+1);
        return 0;
    }
    for(int i=2;1ll*i*i<=N;i++){
        if(sum(N,i)==S){
            printf("%d\n",i);
            return 0;
        }
    }
    for(int i=sqrt(N-S);i>=1;i--)
        if((N-S)%i==0){
            b=(N-S)/i+1;
            if(sum(N,b)==S){
                printf("%lld\n",b);
                return 0;
            }
        }
    puts("-1");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
struct node
{
    int d,x;
}a[100010];
bool cmp(node a,node b)
{
    return a.d<b.d;
}
int main()
{
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    for (int i = 0;i < n;i ++)
        cin>>a[i].d>>a[i].x;
    sort(a,a + n,cmp);//先按天数升序排序
    priority_queue<int> que;
    int ans = 0,pos = 0;
    for (int i = 1;i <= m;i ++)
    {
        for (int j = pos;j <= n;j ++)
        {
            if (a[j].d == i) que.push(a[j].x);
            else if (a[j].d > i)
            {
                pos = j;
                break;
            }
        }
        if (!que.empty())
        {
            ans += que.top();
            que.pop();
        }
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+7;
ll arr[N];
ll num[N];
bool mark[N];
int  main(){
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>arr[i];
		num[arr[i]]++;
	}
	ll ans=0;
	for(ll i=1;i<=n;i++){
		if(mark[arr[i]]) continue ; 
		mark[arr[i]]=1;
		ans+=num[arr[i]]*(num[arr[i]]-1)/2;
	}  
	for(ll i=1;i<=n;i++){
		ll sum=ans;
		sum-=num[arr[i]]*(num[arr[i]]-1)/2; 
		sum+=(num[arr[i]]-1)*(num[arr[i]]-2)/2;
		cout<<sum<<endl;
	}
	return 0;            
}

Measured memory_bytes: 4992
n, q = map(int, input().split())
s = input()
lr = []
for i in range(q):#h:高さ
    lr.append([int(m) for m in input().split()])
accntli = [0] * len(s)
accnt = 0
for i in range(1, len(s)):
    accntli[i] = accnt
    if s[i - 1] == "A" and s[i] == "C":
        accnt += 1
        accntli[i] = accnt
ansli = [0] * q
for i in range(q):
    ansli[i] = accntli[lr[i][1] - 1] - accntli[lr[i][0] - 1]
for i in range(q):
    print(ansli[i])

Measured memory_bytes: 28360
import sys

def solve():
    input = sys.stdin.readline
    H, W, K = map(int, input().split())
    S = [input().strip("\n") for _ in range(H)]
    Ans = 10 ** 20
    Wcount = [[0 for _ in range(W + 1)] for _ in range(H + 1)]
    for h in range(H):
        for w in range(W):
            Wcount[h+1][w+1] = Wcount[h][w + 1] + Wcount[h + 1][w] - Wcount[h][w] + int(S[h][w])
        
            
    #print(Wcount)
    Ans = H * W + 1
    for i in range(2 ** (H - 1)):
        B = [0]
        d = i
        Hcount = 0
        for j in range(H - 1):
            if d % 2 == 1:
                B.append(j + 1)
                Hcount += 1
            d //= 2
        B.append(H)
        leftbound = 0
        TotalBound = Hcount
        NG = False
        for w in range(1, W+1):
            for b in range(Hcount + 1):
                if Wcount[B[b+1]][w] - Wcount[B[b+1]][leftbound] - Wcount[B[b]][w] + Wcount[B[b]][leftbound] > K:
                    if leftbound + 1 == w: 
                        NG = True
                    else:
                        TotalBound += 1
                        leftbound = w - 1
                    break
            if NG: break
        else: Ans = min(TotalBound, Ans)
        #print(i, B, TotalBound)
    print(Ans)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3436
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
inline int in(){
    int x=0;bool f=0;char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int a[200005],p[22],pp[22],n,mx;
ll res; 
int main()
{
	n=in();
	for (int i=1;i<=n;++i){
		a[i]=in();
		for (int j=0;j<20;++j)
		if (a[i]&(1<<j)) mx=max(mx,p[j]),pp[j]=p[j],p[j]=i;
		else mx=max(mx,pp[j]);
		res+=1ll*(i-mx);
	}printf("%lld",res);return 0;
}

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

int main(){
	ll a,b,n; cin>>a>>b>>n;
	ll mx=0;
  if(a>n){
		for(ll i=n; i>0; i-=1){
		mx=max(mx,(a*i)/b-a*(i/b));
	}
  }else{
    	for(ll i=n; i>0; i-=a){
		mx=max(mx,(a*i)/b-a*(i/b));
	}
  }
	cout<<mx<<endl;
}

Measured memory_bytes: 3616
// Author : Hardik Upadhyay
// college: SVNIT 
// slogan : Ab to phod dunga
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i = a ; i >= b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int MAXN = 100005;
ll mod=1000000007;
ll ans = 0;
vi a,b,c,d;
int n,m,q;
void solve(vi v){
	if(v.size() == n){
		//calc ans
		ll curr = 0;
		for(int i = 0; i < q; i ++){
			if( (v[b[i]] - v[a[i]]) == c[i]){
				curr+=d[i];	
			}
		}
		ans = max(ans,curr);
	}
	else{
		//backtrack and put in non decreasing order
		int st = 1;
		if(v.size()) st = v.back();
		for(int i = st; i <= m; i++){
			v.push_back(i);
			solve(v);
			v.pop_back();
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>q;
	a.resize(q);	
	b.resize(q);	
	c.resize(q);	
	d.resize(q);	
	for(int i = 0;i < q; i++){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		a[i]--;
		b[i]--;	
	}
	vector<int> v;
	solve(v);
	cout<<ans<<nl;
	return 0;
}



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

using namespace std;

typedef long long ll;

template<typename T> ostream& operator << (ostream& os, vector<T> v) {
  for (auto& i : v) os << i << " "; return os; 
}
template<typename T> istream& operator >> (istream& is, vector<T>& v) {
  for (auto& i : v) is >> i; return is;
}
template<typename K, typename V> ostream& operator << (ostream& os, unordered_map<K, V> m) {
  for (auto& i : m) os << i.first << ":" << i.second << endl; return os;
}
template<typename T> inline bool chmin(T& x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template<typename T> inline bool chmax(T& x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;

  vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));
  for (int len=1; len<=n; len++) {
    for (int i=0; i+len<=n; i++) {
      int j = i + len;
      if ((n-len) % 2 == 0) {
        dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1]);
      } else {
        dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j-1]);
      }
    }
  }
  cout << dp[0][n] << endl;
  return 0;
}


Measured memory_bytes: 70784
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] barLength = new int[n];
        for (int i = 0; i < n; i++) {
            barLength[i] = sc.nextInt();
        }

        Arrays.sort(barLength);
        int max= 0;
        for (int i = 0; i < k; i++) {
            max += barLength[n - i - 1];
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 24916
#include<stdio.h>
int main(void){
    int p,q,r,min;
    scanf("%d%d%d",&p,&q,&r);
    min = p+q;
    if(q+r<min){
        min = q+r;
    }
    if(r+p<min){
        min = r+p;
    }
    printf("%d",min);
    return 0;
}

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

int main(){
  long n;  cin >> n;
  vector<long> a(n+1, 0);
  for(int i=1; i<=n; i++){
    long tmp;  cin >> tmp;
    a[i] = a[i-1] + tmp;
  }
  
  long mod = 1e9+7;

  long ans = 0;
  for(int i=1; i<n; i++){
    long thisans = ((a[i]-a[i-1])%mod) * ((a[n]-a[i])%mod) % mod;
    ans = (ans + thisans) % mod;
  }

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


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

int main() {
  double l;
  cin >> l;
  double s=l/3;
  printf("%.10f\n",pow(s,3));
  cout << endl;
  return 0;  
}

Measured memory_bytes: 256
#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()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int a, b, c; cin >> a >> b >> c;
  set<int> s = {a, b, c};
  cout << s.size() << endl;
  system("pause");
}

Measured memory_bytes: 504
n = int(input())
rev = []
for i in range(n):
    ip = list(map(str, input().split())) + [i]
    ip[1] = 100 - int(ip[1])
    rev.append(ip)
rev.sort()
ans = [-1] * n
for i in range(n):
    print(rev[i][2] + 1)

Measured memory_bytes: 3060
module WeightedDirectedGraph
  (Weight : sig
    type t
    val inf : t (* オーバーフローの恐れはないので，max_intとか突っ込んでも良い *)
    val zero : t
    val neg_inf : t (* オーバーフローの恐れはないので，min_intとか突っ込んでも良い *)
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  val bellman_ford :
    (* 頂点数n *)
    int ->
    (* 辺のリスト
       頂点は0からn-1までの整数でなくてはならない *)
    (int * int * Weight.t) church_list ->
    (* 始点 *)
    int ->
    (* 頂点を受け取り，そこまでの距離を返す関数
       頂点に到達するパスが無ければinfを返し，
       そこに到達するまでに負閉路があればneg_infを返す *)
    (int -> Weight.t)
end =
struct
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  let bellman_ford n es s =
    (* 距離を覚えるやつ *)
    let d = Array.make n Weight.inf in
    (* 経路に負閉路が含まれる頂点を覚えるやつ *)
    let neg = Array.make n false in
    (* 始点より終点のインデックスが大きくなる辺を集めた隣接リスト *)
    let inc = Array.make n [] in
    (* 始点より終点のインデックスが小さくなる辺を集めた隣接リスト *)
    let dec = Array.make n [] in
    es.fold (fun ((u, v, c) as e) () ->
      if u <= v
      then inc.(u) <- e :: inc.(u)
      else dec.(u) <- e :: dec.(u)) ();
    d.(s) <- Weight.zero;
    (* 残りの反復回数 *)
    let i = ref n in
    (* 更新が行われたか *)
    let is_modified = ref true in
    (* 各辺の処理 *)
    let f (u, v, c) = 
      let open Weight in
      if neg.(u) && not neg.(v) then (neg.(v) <- true; is_modified := true);
      if
        (* 原点から到達できない頂点は更新しない *)
        0 < Weight.compare inf d.(u)
        (* c は u から v への辺の重さ
           d.(u) + c < d.(v) *)
        && 0 < Weight.compare d.(v) (d.(u) + c)
      then begin
        d.(v) <- d.(u) + c;
        is_modified := true;
        if !i <= succ n lsr 1 then neg.(v) <- true
      end in
    while 0 < !i && !is_modified do
      is_modified := false;
      (* インデックスが増加する辺の処理 *)
      for u = 0 to n - 1 do
        List.iter f inc.(u)
      done;
      (* インデックスが減少する辺の処理 *)
      for u = n - 1 downto 0 do
        List.iter f dec.(u)
      done;
      decr i
    done;
    fun v -> if neg.(v) then Weight.neg_inf else d.(v)
end

module G = WeightedDirectedGraph (struct
  type t = int
  let zero = 0
  let inf = min_int
  let neg_inf = max_int
  let ( + ) = ( + )
  let compare x y = compare y x
end)

let () = Scanf.scanf "%d %d %d\n" @@ fun n m p ->
  let abc = Array.init m @@ fun _ ->
    Scanf.scanf "%d %d %d\n" @@ fun a b c -> a - 1, b - 1, c - p in
  let d = G.bellman_ford n { G.fold = fun f -> Array.fold_right f abc } 0 (n - 1) in
  if max_int <= d
  then print_endline "-1"
  else Printf.printf "%d\n" @@ max 0 d


Measured memory_bytes: 6140
#include <bits/stdc++.h>
#define INF 3000001
using namespace std;
typedef long long ll;
typedef pair<long long, long long> pll;
int a[2222];
int main() {
    int n;
    int s = 0;
    cin >> n;
    for(int i = 0; i < 2 * n; i ++) cin >> a[i];
    sort(a , a + 2 * n);
    for(int i = 0; i < 2 * n; i += 2) s += a[i];
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i,a,b) for(int i=(a);i<=(b);++i)
#define FD(i,b,a) for(int i=(b);i>=(a);--i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;
constexpr int inv(LL x, int m) { return x > m ? inv(x % m, m) : x > 1 ? inv(m % x, m) * (m - m / x) % m : x; }
constexpr int mpow(LL a, LL k, int m) { int r(1); for (a %= m; k; k >>= 1, a = a * a % m) if (k & 1)r = r * a % m; return r; }

int main() {
    vector<int> a(4);
    FI(i, 0, 3) scanf("%d", &a[i]);
    sort(a.begin(), a.begin() + 4);
    if (a == vector<int> {1, 4, 7, 9}) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

int main() {
	int n;
	while (std::cin >> n) {
		if (n == 0) break;
		std::vector<int> a;
		for (int i = 0; i < n; ++i) {
			int ai;
			std::cin >> ai;
			a.push_back(ai);
		}
		// ここをかく
		int dp[6000], max;
		dp[0] = max = a[0];
		for (int i = 1; i < n; i++) {
			if (dp[i - 1] >= 0) {
				dp[i] = dp[i - 1] + a[i];
			}
			else {
				dp[i] = a[i];
			}
			max = max > dp[i] ? max : dp[i];
		}

		std::cout << max << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define EPS (1e-12)

using namespace std;

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

int p[6], q[6];

double func(double x){
	double res = 0.;
	rep (i, 6){
		res += max((double)p[i]*x, (double)q[i]*(1. - x));
	} // end rep

	res /= 100.;
	
	return res;
}

int main()
{
	memset(p, 0, sizeof(p));
	memset(q, 0, sizeof(q));

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	rep (i, 6) cin >> p[i];
	rep (i, 6) cin >> q[i];

	double lo = 0.;
	double hi = 1.;
	while(abs(hi - lo) > EPS){
		double mid1 = (2.*lo + hi) / 3.;
		double mid2 = (lo + 2.*hi) / 3.;
		double ans1 = func(mid1);
		double ans2  =func(mid2);
		if (ans1 < ans2){
			hi = mid2;
		}else{
			lo = mid1;
		} // end if
	} // end while
	
	printf("%.12lf\n", func((hi + lo) / 2.));

	return 0;
}

Measured memory_bytes: 256
//
// Created by HandwerSTD.
// Copyright (c) 2019 HandwerSTD. All rights reserved.
// Title: Graph Partition
//
// sto Qingyu orz
// 感谢真神sqy无私的教诲。膜时队者处处阿克，只因大师sqy在他背后。不膜大师者违背了真神的旨意，真神必将降下天谴，
// 使其天天爆零
// 我不由自主地膜拜真神sqy。
//

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>

#define FILE_IN(__fname) freopen(__fname, "r", stdin)
#define FILE_OUT(__fname) freopen(__fname, "w", stdout)
#define rap(a,s,t,i) for (int a = s; a <= t; a += i)
#define down(a,t,s,i) for (int a = t; a >= s; a -= i)
#define IMPROVE_IO() std::ios::sync_with_stdio(false)

using std::cin;
using std::cout;
using std::endl;

typedef long long int lli;

int getint() { int x; scanf("%d", &x); return x; }
lli getll() { long long int x; scanf("%lld", &x); return x; }

const int MAXN = 200 + 10;
const int dx[] = { 0, 1, -1, 0, 0 };
const int dy[] = { 0, 0, 0, 1, -1 };

int n, G[MAXN][MAXN];
char s[MAXN];
short col[MAXN];

bool biColor(int now, bool color) {
    std::queue<int> q;
    q.push(now); col[now] = color;
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int i = 1; i <= n; ++i) {
            if (G[u][i] == 0x3f3f3f3f || i == u) continue;
            int v = i;
            if (col[v] == -1) { col[v] = !col[u]; q.push(v); }
            else if (col[v] == col[u]) return false;
        }
    }
    return true;
}

int main() {
    n = getint();
    memset(G, 0x3f, sizeof G);
    memset(col, -1, sizeof col);
    for (int i = 1; i <= n; ++i) {
        scanf("%s", s);
        for (int j = 1; j <= n; ++j) {
            if (s[j - 1] == '1') G[i][j] = 1;
        }
        G[i][i] = 0;
    }
    if (!biColor(1, 0)) return (0 & printf("-1\n"));
    for (int k = 1; k <= n; ++k) {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                G[i][j] = std::min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
    int maxDis = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (G[i][j] != 0x3f3f3f3f && G[i][j] > maxDis) maxDis = G[i][j];
        }
    }
    printf("%d\n", maxDis + 1);
    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        int[] arr = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        int n = arr[0];
        int m = arr[1];
        Console.WriteLine(n*(n-1)/2+m*(m-1)/2);
    }




}





Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    fr(i,3){
        if(s[i]==s[i+1]){
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;
}

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

int main(){
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	string ans;
	while(k--){
		if(c <= b)
			c = c * 2;
		else if(b <= a)
			b = b * 2;
		else
			c = c * 2;

	}
	if(c > b && b > a)
		cout << "Yes";
	else
		cout << "No";


}


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

using namespace std;
const int N = 5e5 + 10;
char s[N];
int t[26][N];
int n, q;
int lowbit(int x) { return x & -x; }
void update(int x, int c, int *a) {
    for (int i = x; i <= n; i += lowbit(i)) a[i] += c;
}

int sum(int x, int *a) {
    int res = 0;
    for (int i = x; i >= 1; i -= lowbit(i)) res += a[i];
    return res;
}

int main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    cin >> n >> s >> q;
    for (int i = 0; i < n; i++) update(i + 1, 1, t[s[i] - 'a']);

    while (q--) {
        int a;
        cin >> a;
        if (a == 1) {
            int b;
            char tt;
            cin >> b >> tt;
            update(b, -1, t[s[b - 1] - 'a']);
            s[b - 1] = tt;
            update(b, 1, t[tt - 'a']);
        } else {
            int ans = 0;
            int l, r;
            cin >> l >> r;
            for (int i = 0; i < 26; i++) {
                if (sum(r, t[i]) - sum(l - 1, t[i]) >= 1)
                    ans++;
            }
            cout << ans << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 51584
#include<iostream>
#include<fstream>
#include <stack>

using namespace std;

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  stack<int> st;
  string S;
  cin>>S;

  int ans=0;
  for(int i=0;i<S.size();i++){
    if(st.empty()){
      st.push(S.at(i));
    }else{
      if(st.top()==S.at(i)){
        st.push(S.at(i));
      }else{
        st.pop();
        ans += 2;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 7;

int n;
long long A[maxN],S[maxN],m, Sum[maxN];

long long Dem(long long x)
{
    long long ans = 0;
    for (int i=1; i<=n; ++i)
    {
        long long v = x - A[i];
        int l=1, r = n, Res =0;
        do {
            int mid = (l+r)/2;
            if (A[mid] >= v)
            {
                Res = mid; l = mid + 1;
            } else r = mid - 1;
        } while (l<=r);

        ans += Res;
    }
    return ans;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    Sum[0] = 0;
    n = 0;
    scanf("%d%lld\n", &n, &m);
    for (int i=1; i<=n; ++i)
    {
        int x; scanf("%d", &x);
        A[i] = x;
    }
    sort(A+1, A+n+1, greater<long long>());
    for (int i=1; i<=n; ++i)
    {
        Sum[i] = Sum[i-1] + A[i];
        //cout<<A[i]<<" "<<Sum[i]<<endl;
    }
    long long l=0, r = A[1]*2 + 1;
    while(l+1<r)
    {
        long long mid = (l+r)/2;
        if (Dem(mid)>=m) l = mid;
          else r = mid;
    }
    //cout<<l<<" "<<r<<endl;
    long long ans = 0;
    for (int i=1; i<=n; ++i)
    {
        long long v = r - A[i];
        int l=1, r = n, Res =0;
        do {
            int mid = (l+r)/2;
            if (A[mid] >= v)
            {
                Res = mid; l = mid + 1;
            } else r = mid - 1;
        } while (l<=r);
        if (Res>m) Res = m;
        ans += Sum[Res] + A[i]*Res;
        m -= Res;
    }
    ans += m*l;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 
#define ALL(a)  (a).begin(),(a).end()



using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int a, int b)
{
	return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}

long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






int main(){
  long long Q,H,S,D,N;
  cin>>Q>>H>>S>>D>>N;
  long long HH=H*4;
  long long QQ=Q*8;
  long long SS=S*2;
  long long LL=min(min(HH,QQ),min(SS,D));
  long long HHH=H*2;
  long long QQQ=Q*4;
  long long L=min(min(HHH,QQQ),S);
  LL=min(LL,L*2);
  
  if(N%2==0){
    cout<<LL*(N/2)<<endl;
  }else{
    cout<<LL*(N/2)+L<<endl;
  }
  




  
}





Measured memory_bytes: 256
<?php
$n = 5;
$x = 0;
while ($n--) {
	fscanf(STDIN, "%d", $t);
	$s = $t % 10;
	if ($s) {
		$d[] = $s;
		$x += $t - $s + 10;
	} else {
		$x += $t;
	}
}
echo isset($d) ? $x + min($d) - 10 : $x;

Measured memory_bytes: 4604
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;
 
int main(){
    ll n;
    cin >> n;

    ll ans = n/2 + n%2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[3][3];
    int b[3][3];
    int i,j;
    for(i=0; i<3; i++)
        for(j=0; j<3; j++)
            cin>>a[i][j];
    int n;
    cin>>n;
    int c;
    int l;
    for(l=0; l<n; l++)
    {
        cin>>c;
        for(i=0; i<3; i++)
            for(j=0; j<3; j++)
                if(c==a[i][j])
                    b[i][j]=1;

    }
    for(i=0; i<3; i++)
        if(b[i][0]==1&&b[i][1]==1&&b[i][2]==1)
        {
            cout<<"Yes";
            return 0;
        }
    for(j=0; j<3; j++)
        if(b[0][j]==1&&b[1][j]==1&&b[2][j]==1)
        {
            cout<<"Yes";
            return 0;
        }
    if(b[1][1]==1)
    {
        if(b[0][0]==1&&b[2][2]==1)
        {
            cout<<"Yes";
            return 0;
        }
       if(b[0][2]==1&&b[2][0]==1)
       {
           cout<<"Yes";
           return 0;
       }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	string s; cin>>s;
	ll cnt=0;
	for(ll i=0,j=s.size()-1;i<=j;++i,--j){
		if(s[i]!=s[j])++cnt;
	}
	cout<<cnt<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
/*Author : Yuvraj Singh
 * Patience is Power
 * 
 * */
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
#define ar array
/*
ll power(ll x,ll y) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return ((temp%mod)*(temp%mod))%mod; 
    else
        return ((x%mod)*(temp%mod)*(temp%mod))%mod; 
}

int gcd(int x,int y){
	return y==0?x:gcd(y,x%y);
}

bool cmp(pair<int,int>a,pair<int,int>b){
	return a.second<b.second;
}
*/
void solve(){
	int x;cin>>x;
	if(x==0){
		cout<<1;
	}
	else{
		cout<<0;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	//int t; cin>>t;
	//while(t--)
		solve();
		
    return 0;
}



Measured memory_bytes: 3644
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        final long Mod = 1000000000+7;
        long[] x = new long[n];
        long[] y = new long[m];
        for(int i=0;i<n;i++) x[i] = sc.nextLong();
        for(int i=0;i<m;i++) y[i] = sc.nextLong();
        long[] unitSum = new long[n];
        long[] unitEnd = new long[n];
        for(int i=1;i<n;i++){
            long dx = x[i]-x[i-1];
            unitEnd[i]=((i*dx)%Mod+unitEnd[i-1])%Mod;
            unitSum[i]=(unitSum[i-1]+unitEnd[i])%Mod;
        }
        long[] yEnd = new long[m];
        for(int i=1;i<m;i++){
            long dy = y[i]-y[i-1];
            yEnd[i] = (yEnd[i-1]+(((i*unitSum[n-1])%Mod)*dy)%Mod)%Mod;
        }
        long ans = 0;
        for(int i=1;i<m;i++) ans = (ans+yEnd[i])%Mod;
        System.out.println(ans);
    }
}



Measured memory_bytes: 94804
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner inputs = new Scanner(System.in);
		char c = inputs.next().charAt(0);
		if(c>=65&&c<91) {
			System.out.println('A');
		}
		else
			System.out.println('a');
	}

}


Measured memory_bytes: 35684
H,W = list(map(int,input().split()))
b = []
if H == 1:
    print(input())
else:
    for _ in range(H):
        a = input()
        if a.count('.') == W:
            pass
        else:
            b.append(a)
    st = set()
    #print(b)
    for i,c in enumerate(b[0]):
        if c == '.':
            st.add(i)
    for a in b[1:]:
        s_st = set()
        for k in st:
            if a[k] == '#':
                s_st.add(k)
        st -= s_st
    #print(st)
    for c in b:
        for i,d in enumerate(c):
            if not i in st:print(d,end='')
        else:print('')

Measured memory_bytes: 4468
#include <iostream>

using namespace std;

int main(){
  string a, b, ans;
  cin >> a >> b;
  if(a=="H" && b=="H"){
    ans = "H";
  }else if(a=="H" && b=="D"){
    ans = "D";
  }else if(a=="D" && b=="H"){
    ans = "D";
  }else{
    ans = "H";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(200005)
#define fim endl
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define max3(x, y, z) max(x, max(y, z))
#define log2(k) int(log2(k))
using namespace std;
typedef pair<ll, int> pii;
typedef pair<string, int> psi;
typedef pair<int, pair<int, int> > piii;
typedef pair<char, int> pci;
typedef pair<int, bool> pib;

int main() {
    int n;
    bool flag = true;
    cin >> n;
    while(n--) {
        int x;
        cin >> x;
        if(x%2 > 0) continue;
        if(x%2 == 0 && (x%3 == 0 or x%5 == 0))
            continue;
        flag = false;
        break;
    }
    cout << (flag == false ? "DENIED" : "APPROVED") << fim;
}


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

int n;
int a[100001];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int p;
		cin>>p;
		a[p]=i;
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<" ";
	cout<<endl;
}


Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define       FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
int main()
{
  int t=1,i;
  //cin>>t;
  while(t--)
  {
      string s;
      s="ACL";
    int n;
    cin>>n;
    for(i=0;i<n;i++) cout<<s;
      cout<<endl;
  }
}



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

int main() {
  int N;
  cin >> N;
  vector<int>A(N);
  for(int i=0; i<N; i++)
    cin >> A.at(i);
  sort(A.begin(),A.end());
  cout << A.at(N-1)-A.at(0);
  
}

Measured memory_bytes: 256
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 998244353;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

void solve()
{
	int n;
	cin >> n;
	vector<p32> arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i].fi >> arr[i].se;
	}
	sort(arr.begin(), arr.end());
	v64 dp(n + 1, 0);
	stack<p64> S;
	dp[n] = 1;
	S.push({n, 3e9});
	for (int i = n - 1; i >= 0; i--)
	{
		while (S.top().se < arr[i].fi + arr[i].se)
			S.pop();
		int j = S.top().fi;
		dp[i] = dp[j];
		S.push({i, arr[i].fi});
		dp[i] = add(dp[i], dp[i + 1], MOD);
	}
	cout << dp[0] << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const int INF = 1e9;

int n;
string s;
int ans;
int main(){
  cin>>n>>s;
  for(int i=1;i<n;i++){
    bool b[28]={false};
    int a=0;
    for(int j=0;j<i;j++){
      b[s[j]-'a']=true;
    }
    for(int j=0;j<n-i;j++){
      if(b[s[i+j]-'a']==true){
	a++;b[s[i+j]-'a']=false;
      }
    }
    ans=max(a,ans);
  }
  cout<<ans<<endl;
  return 0;
}



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

    
    int main(){
       
        int a,b,c;
        cin >>a>>b>>c;
        
        if(a+b==c || b+c==a || a+c==b){
            cout<<"Yes"<<endl;
        }
       
        else{
            cout<<"No"<<endl;
        }

    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin >> x >> y;
    if(x == y)
    {
        cout << "Yes";
    }
    else if((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11))
    {
        cout << "Yes";
    }
    else if((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12))
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 256
count = 0

number = int(input())

inarr = number * [0]

for i in range(number):
    inarr[i] = int(input())

res = inarr[number - 1] - inarr[number - 2]
maxsell = inarr[number - 1]

for i in range(number - 2, -1, -1):
    tmpres = maxsell - inarr[i]
    if res < tmpres:
        res = tmpres
    if maxsell < inarr[i]:
        maxsell = inarr[i]

print(res)



Measured memory_bytes: 13376
a,b,c,d = map(int,input().split())
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
lc = c * d // (gcd(c,d))
total = b - a + 1
onlyc = (b//c) - (a-1)//c
onlyd = (b//d) - (a-1)//d
both = (b//lc) - (a-1)//lc

print(total - (onlyd + onlyc - both))


Measured memory_bytes: 3060
package main

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

const MOD int64 = int64(1e9+7)
var sc = bufio.NewScanner(os.Stdin)

func modinv (a, m int64) int64 {
	b, u, v := m, int64(1), int64(0)
	for b > 0 {
		t := a/b
		a -= t*b
		a, b = b, a
		u -= t*v
		u, v = v, u
	}
	u %= m
	if u < 0 {
		u += m
	}
	return u
}

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

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	a := make([]int, N, N)
	var sum, sum_sq int64
	for i := 0; i < N; i++ {
		a[i] = nextInt()
		sum += int64(a[i])
		sum %= MOD
		sum_sq += int64(a[i])*int64(a[i])
		sum_sq %= MOD
	}

	ans := (((sum*sum)%MOD-sum_sq+MOD)*modinv(int64(2), MOD))%MOD
	fmt.Printf("%d\n", ans)
	return
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
//

int dp[10][1000];

signed main()
{
    int n, s;
    dp[0][0] = 1;
    rep(add, 101) {
        for (int i = 8; i >= 0; i--) {
            rep(j, 900) {
                dp[i+1][j+add] += dp[i][j];
                //dp[i+1][j] += dp[i][j];
            }
        }
    }

    while (cin >> n >> s, n) {
        cout << dp[n][s] << endl;
    }

    return 0;
}

Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] data = new int[n];
    	for (int i = 0; i < n; i++) {
    		data[i] = sc.nextInt();
    	}
		
    	int q = sc.nextInt();
    	for (int i = 0; i < q; i++) {
    		if (solve(data, 0, sc.nextInt())) {
    			System.out.println("yes");
    		} else {
    			System.out.println("no");
    		}
    	}

    	sc.close();
	}

	private static boolean solve(int[] data, int p, int m) {
		if (m == 0) {
			return true;
		}
		if (p < data.length) {
			if (solve(data, p + 1, m - data[p])) {
				return true;
			}
			if (solve(data, p + 1, m)) {
				return true;
			}
		}
		
		return false;
	}
}

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

namespace AtConderBeginnerContest054
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            string szTotal = Console.ReadLine();
            string[] szArr = szTotal.Split(' ');
            int n = int.Parse(szArr[0]);
            int m = int.Parse(szArr[1]);

            int[] a = new int[m];
            int[] b = new int[m];
            for (int i = 0; i < a.Length; ++i)
            {
                string szLine = Console.ReadLine();
                szArr = szLine.Split(' ');
                a[i] = int.Parse(szArr[0]);
                b[i] = int.Parse(szArr[1]);
            }

            int result = Solve(a, b, n);
            Console.WriteLine(result);
        }
        private static int Solve(int[] a, int[] b, int n)
        {
            // 木構造で作成
            Node root = new Node(1, 1, n, null);
            CreateLeaf(root, a, b, n);

            // depthが最大までいったのをカウント
            int total = 0;
            CountTree(root, ref total, n);

            return total;
        }

        private static void CreateLeaf(Node node, int[] a, int[] b, int n)
        {
            int id = node._id;
            for (int i = 0; i < a.Length; ++i)
            {
                if (a[i] != id && b[i] != id) { continue; }

                int nextid = 0;
                if (a[i] == id) { nextid = b[i]; }
                else { nextid = a[i]; }

                // これは使用済みの辺かもしれない
                if(node.IsExists(nextid)) { continue; }

                Node leaf = new Node(nextid, node._depth + 1, n, node);
                node._leaf[nextid - 1] = leaf;
                CreateLeaf(leaf, a, b, n);
            }
        }

        private class Node
        {
            public int _id = 1;
            public int _depth = 1;
            public Node _parent = null;
            public Node[] _leaf = null;
            /// <summary>
            /// 
            /// </summary>
            /// <param name="id"></param>
            /// <param name="depth">1 以上</param>
            /// <param name="n"></param>
            public Node(int id, int depth, int n, Node parent)
            {
                _id = id;
                _depth = depth;
                _parent = parent;
                _leaf = new Node[n];
            }

            /// <summary>
            /// 親も含め存在しているか？
            /// </summary>
            /// <param name="id"></param>
            /// <returns></returns>
            public bool IsExists(int id)
            {
                if (_id == id) { return true; }

                if (_parent == null) { return false; }

                return _parent.IsExists(id);
            }
        }

        private static void CountTree(Node node, ref int total, int maxdepth)
        {
            if( node._depth == maxdepth)
            {
                ++total;
            }
            foreach(Node leaf in node._leaf)
            {
                if( leaf == null) { continue; }

                CountTree(leaf ,ref total, maxdepth);

            }
        }
    }


}


Measured memory_bytes: 13140