akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int l; cin >> l;
	int r; cin >> r;
	if (r / 2019 - (l - 1) / 2019) {
		cout << 0;
	} else {
		l %= 2019;
		r %= 2019;
		int ans = 20000;
		for (int i = l; i < r; ++i) {
			for (int j = l + 1; j <= r; ++j) {
				ans = min(ans, i * j % 2019);
			}
		}
		cout << ans;
	}
}

Measured memory_bytes: 256
/*
	プログラミングコンテスト用テンプレート
*/
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;

double EPS = 1e-10;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define int(x) int x; cin >> x;
#define lint(x) long long x; cin >> x;
#define vint(v,n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vlint(v,n) vector<lint> v(n); REP(i,n) cin >> v[i];
#define double(x) double x; cin >> x[i];
#define vdouble(v,n) vector<double> v(n); REP(i,n) cin >> v[i];
#define string(x) string x; cin >> x;

int main()
{
	int(x);
	int(y);

	if ((x + y) >= 10)	cout << "error" << endl;
	else cout << x + y << endl;

	return 0;
}

Measured memory_bytes: 256
#define first f
#define second s
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector <int> a(n), b(n), c(n - 1);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i];
	}
	int ans = b[a[0] - 1];
	for (int i = 1; i < n; i++) {
		if (a[i] == a[i - 1] + 1) ans += c[a[i-1]-1];
		ans += b[a[i]-1];
	}
	cout << ans;
}

Measured memory_bytes: 256
from heapq import heappush, heappop


N, M = map(int, input().split())
X = list(map(int, input().split()))

X.sort()

if N >= M:
    print(0)
    exit()

q1 = []

for i in range(M - 1):
    sec = X[i + 1] - X[i]
    heappush(q1, -sec)

ans = 0
for _ in range(N - 1):
    ans -= heappop(q1)

print(X[-1] - X[0] - ans)


Measured memory_bytes: 13960
#include <iostream>

using namespace std;

int N;
int F[100][10];
int P[100][11];


int main(void) {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 10; ++j) {
            cin >> F[i][j];
        }
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 11; ++j) {
            cin >> P[i][j];
        }
    }

    int res = -(1 << 30);
    for (int b = 1; b < (1 << 10); b++) {
        int cc = 0;
        for (int i = 0; i < N; ++i) {
            int c = 0;
            for (int j = 0; j < 10; ++j) {
                if ((b >> j & 1) && F[i][j]) {
                    c++;
                }
            }
            cc += P[i][c];
        }
        if (res < cc) res = cc;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
x, y = [int(i) for i in input().split(' ')]

g = [[ 1, 3, 5, 7, 8, 10, 12], [ 4, 6, 9, 11], [2]]

ax = list(map(lambda i: x in i, g))
ay = list(map(lambda i: y in i, g))
print('Yes' if ax == ay else 'No')


Measured memory_bytes: 2940
/** "Ever tried.
         Ever failed.
               No matter.
                   Try Again.
                        Fail again.
                             Fail better.**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb push_back
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define setdp memset(dp,-1,sizeof(dp))
#define fr first
#define sc second
#define NumofDigits(n)   ((long long)log10(n)+1)
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int MOD = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
int dx[] = {- 1, 0, 0, 1, 0 };
int dy[] = { 0,- 1, 1, 0, 0 };*/
void File()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    ll n;
    cin>>n;
    ll ans=0;
   for(ll i=1;i<=n;i++)
   {
       ans+=i;
       if(ans>=n)
         return cout<<i,0;
   }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAXN 200000
#define rint register int
inline int read(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}
int A[MAXN+5], n; ll Ans;
int main()
{
	n = read(); for(rint i = 1; i <= n; A[i] = read(), i++); if(A[1]) return puts("-1"),0;
	for(rint i = 1; i <= n; i++) if(A[i]>A[i-1]+1) return puts("-1"),0;
	for(rint i = 1; i <= n; i++) Ans += A[i]==A[i-1]+1 ? 1 : A[i]; cout << Ans << endl; return 0;
}

Measured memory_bytes: 1024
import sys
import math
k = int(sys.stdin.readline())
a = 1
t = 0
while a <= k:
  b = 1
  while b <= k:
    c = 1
    while c <= k:
      t += math.gcd(math.gcd(a,b), c)
      c += 1
    b += 1
  a += 1
print(t)


Measured memory_bytes: 67392
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
v(int) adj[200001];
bool vis[200001]={0};
int dfs(int i){
    if(vis[i]) return 0;
    int c=1;
    vis[i]=true;
    rep(j,adj[i].size()){
        //if(p!=adj[i][j])
            c+=dfs(adj[i][j]);
    }
    return c;
}
#define MX 1000000007
int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  int n,m;
  cin>>n>>m;
  rep(i,m){
      int a,b;
      cin>>a>>b;
      a--;b--;
      adj[a].pb(b);
      adj[b].pb(a);
  }
  int ans=0;
  rep(i,n){
      ans=max(ans,dfs(i));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 20928
// Koto Diatance
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int w = sc.nextInt();
		int h = sc.nextInt();
		boolean[] width = new boolean[w];
		boolean[] height = new boolean[h];
		Arrays.fill(width, false);
		Arrays.fill(height, false);
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int wi = sc.nextInt();
			for (int j = Math.max(x - wi, 0); j < Math.min(x + wi, w); j++)
				width[j] = true;
			for (int j = Math.max(y - wi, 0); j < Math.min(y + wi, h); j++)
				height[j] = true;
		}
		if (isFilledWithTrue(width) || isFilledWithTrue(height))
			System.out.println("Yes");
		else
			System.out.println("No");
		sc.close();
	}

	private static boolean isFilledWithTrue(boolean[] bool) {
		for (boolean b : bool)
			if (!b)
				return false;
		return true;
	}
}

Measured memory_bytes: 96796
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

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

const int L=2e5+10;
const int M=998244353;
string S;
void brute(vector<int> v,set<vector<int>>& ret){
	if(ret.count(v))return;
	ret.insert(v);
	for(int i=0;i+1<v.size();i++){
		if(v[i]!=v[i+1]){
			vector<int> w=v;
			w[i]=w[i+1]=2*(v[i]+v[i+1])%3;
			brute(w,ret);
		}
	}
}
#if 0
void f(vector<int> v){
	if(v.size()==4){
		for(int w:v){
			cerr << w;
		}
		set<vector<int>> ret;
		brute(v,ret);
		cerr << ": " << ret.size() << endl;
		return;
	}
	v.push_back(0);
	for(int i=0;i<3;i++){
		v.back()=i;
		f(v);
	}
}
#endif
LL dp[L][3][3][2];
LL dp2[L][3][3];
int main() {
	cin >> S;
	for(int i=0;i<3;i++){
		dp[0][i][i][0]=1;
		dp2[0][i][i]=1;
	}
	LL p=1;
	for(int i=1;i<S.size();i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				for(int s=0;s<3;s++){
					int s2=(j+s)%3;
					for(int d=0;d<2;d++){
						int d2=d|(j==k?1:0);
						dp[i][j][s2][d2]+=dp[i-1][k][s][d];
						dp[i][j][s2][d2]%=M;
					}
					if(j!=k){
						dp2[i][j][s2]+=dp2[i-1][k][s];
						dp2[i][j][s2]%=M;
					}
				}
			}
		}
		p*=3;
		p%=M;
#if 0
		for(int j=0;j<3;j++){
			for(int s=0;s<3;s++){
				for(int d=0;d<2;d++){
					cerr << i << ", "<< j << ", " << s << ", " << d << dp[i][j][s][d] << endl;
				}
			}
		}
#endif
	}
	if(S.size()<4){
		set<vector<int>> v;
		vector<int> in;
		for(auto s:S){
			in.push_back(s-'a');
		}
		brute(in,v);
		cout << v.size()%M << endl;
		return 0;
	}
	bool any=false;
	bool all=true;
	int sum=0;
	for(int i=0;i<S.size();i++){
		if(i+1<S.size()){
			any=any||(S[i]==S[i+1]);
			all=all&&(S[i]==S[i+1]);
		}
		sum+=S[i]-'a';
		sum%=3;
	}
	if(all){
		cout << 1 << endl;
		return 0;
	}
	LL ret=p;
	for(int k=0;k<3;k++){
		ret+=M-dp2[S.size()-1][k][sum];
		//ret+=dp[S.size()-1][k][sum][1];
		ret%=M;
	}
	if(!any){
		ret++;
		ret%=M;
	}
	cout << ret << endl;

	return 0;
}




Measured memory_bytes: 42756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
using namespace std;

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

	long long MinMove = min({A, B, C, D, E});
	
	long long ans = ((N + MinMove - 1) / MinMove) + 4; 
	
	cout << ans << endl;
	return 0;
}

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

int64_t makeLucas(vector<int64_t>&, int);


int main() {
  int n;
  cin >> n;
  vector<int64_t> lucas(MAX_N, -1);
  
  lucas[0] = 2;
  lucas[1] = 1;
  
  cout << (int64_t)makeLucas(lucas, n) << endl;
}

int64_t makeLucas(vector<int64_t> &lucas, int n) {
  if (lucas[n] != -1) return lucas[n];
  
  lucas[n] = makeLucas(lucas, n-1) + makeLucas(lucas, n-2);
  return lucas[n];
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i = 0;
	int n;
	int a[100];
	
	scanf("%d", &n);
	
	while(i < n){
		scanf("%d", &a[i]);
		i++;
	}
	while(i--){
		printf("%d", a[i]);
		printf(i?" ":"\n");
	}
	return 0;
}


Measured memory_bytes: 2088
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        int a,b,ansa,ansb;
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
       ansa = a*b;
       ansb = a+a+b+b;
       System.out.println(ansa + " " + ansb);
    }
}


Measured memory_bytes: 25784
#include <bits/stdc++.h>
using namespace std;
int N,x=0,ans=0;
string s;
int main(){
  cin >> N >> s;
  for(int i=0;i<N;i++){
    if(s[i]=='I') x++;
    if(s[i]=='D') x--;
    ans=max(ans,x);
  }
  cout << ans << 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 REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong

int n,m;
vector<int> edge[MAX];
int jisuu[MAX] = {};
int parent[MAX];


bool DFS(int x){
    itrfor(itr,edge[x]){
        jisuu[*itr]--;
        if(jisuu[*itr] ==0){
            parent[*itr] = x;
            DFS;
        }
    }
}


signed main(){
    cin >> n >> m;

    int a,b;
    REP(i,n-1 +m){
        scanf("%lld%lld",&a,&b);
        jisuu[b]++;
        edge[a].push_back(b);
    }
    int root = -1;
    FOR(i,1,n+1){
        if(jisuu[i] ==0){
            root = i;
            break;
        }
    }
    FOR(i,1,n+1) parent[i] = -1;
    parent[root] = 0;
    

    int que[2][MAX];
    int cnt[2];
    que[0][0] = root;
    int ind = 0;
    cnt[0] = 1;
    while(1){
        if(cnt[ind%2] ==0) break;
        cnt[(ind+1)%2] = 0;
        REP(i,cnt[ind%2]){
            int now = que[ind%2][i];
            itrfor(itr,edge[now]){
                jisuu[*itr] --;
                if(jisuu[*itr] ==0){
                    que[(ind+1)%2][cnt[(ind+1)%2]] = *itr;
                    cnt[(ind+1)%2] ++;
                    parent[*itr] = now;
                }
            }
        }
        ind ++;
    }

    FOR(i,1,n+1){
        printf("%lld\n",parent[i]);
    }

}

Measured memory_bytes: 13056
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin >> H >> W;
  vector<string> A(H);
  for(int i = 0; i < H; i++){
    cin >> A.at(i);
  }
  for(int i = 0; i < H+2; i++){
    if( i == 0 || i == H+1 ){
      cout << string(W+2, '#') << endl;
    }else{
      cout << '#' + A.at(i-1) + '#' << endl;
    }
  }
}

Measured memory_bytes: 3632
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	() => ( get().parse::<u64>().unwrap() ) }
	
    let x = get!();
    let y = get!();
    let mut ans = 0;
    
    for i in 0..3 {
    	let mut cnt = 0;
        let mut z = x + i;
        while z <= y {
        	cnt += 1;
            z *= 2;
        }
        ans = std::cmp::max(ans, cnt);
    }
    
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;cin >> N;
    ll A[N],ans = 0;
    REP(i,N) cin >> A[i];
    REP(i,N-1){
        ans += A[i]/2;
        A[i] %= 2;
        if(A[i] == 1 && A[i+1] >= 1){
            --A[i];--A[i+1];++ans;
        }
    }
    if(A[N-1] >= 2){
        ans += A[N-1]/2;
        A[N-1] %= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//221
	string a,b,c;
	cin>>a>>b>>c;
	cout<<a[0]<<b[1]<<c[2];
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const ll MOD = 1000000007;

int main(void) {
  int a;
  cin >> a;
  
  if(a%2==0) cout << a/2 << endl; 
  else cout << 1+a/2 << endl; 
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        char c[105];
        while (cin >> c) {
                int len = strlen(c);
                cout << c[0] << len - 2 << c[len - 1] << endl;
        }
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a;
int b;
int main(){
	ios::sync_with_stdio(false);
	cin>>a;
	for(int i=0;i<a.size();i++){
		if(a[i]=='C'&&b==0){
			b=1;
			//cout<<i<<endl;
		}
		if(a[i]=='F'&&b==1){
			b=2;
			//cout<<i<<endl; 
		}
	}
	if(b==2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)


//#define MAX_V 100001

//MultipleLengthNumber
class MLN{
private:
    string _value;
    
public:
    MLN( string str = "" ):_value(str){}
    
    MLN operator + (MLN obj) {  //verified AOJ0015
        string a = _value, b = obj._value;
        
        if(a.size()<b.size())swap(a,b);         //len(a)>len(b)???
        b = string(a.size()-b.size(),'0')+b;    //b????????????a??¨??????????????????????????????0??§?????????
        
        string ans = string(a.size()+1,'0');    //a?????????+1 ?????????0??§???????????????
        for(int i=(int)a.size()-1;i>=0;i--){    //?¶??????? & ??°????????????
            ans[i+1] += (a[i]-'0') + (b[i]-'0');
            if(ans[i+1]>='0'+10){
                ans[i] += 1;
                ans[i+1] -= 10;
            }
        }
        rep(i,ans.size()){  //??????????????°???0????¶????
            if(ans[i]!='0'||i==ans.size()-1){
                return MLN( ans.substr(i,ans.size()-i) );
            }
        }
        abort();
    }
    
    bool operator > (MLN obj){
        string a = _value, b = obj._value;
        if(a.size() > b.size())return true;
        if(a.size() < b.size())return false;
        
        rep(i,a.size()){
            if(a[i]==b[i])continue;
            if(a[i]>b[i])return true;
            else return false;
        }
        return false;
    }
    
    MLN operator % (MLN obj){
        string a = _value, b = obj._value;
        
        if(MLN(b)>MLN(a))return MLN(a);
        
        string now = a.substr(0,b.size());
        rep(i,a.size()-b.size()+1){
            
        }
        
        return MLN();
    }
    
    
    string value(){
        return _value;
    }
};


int main(){
    int n;
    cin>>n;
    
    rep(i,n){
        string a,b;
        cin>>a>>b;
        string res = (MLN(a)+MLN(b)).value();
        
        if(res.size()>80)cout<<"overflow"<<endl;
        else cout<<res<<endl;
    }
}

Measured memory_bytes: 3116
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long; 
using ld = long double;
#define endl "\n"
//#define int long long
#define all(V) V.begin(),V.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
ll keta(ll n) {
    if (n == 0) return 1;
    ll count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll mch(ll n) {
    if (n == 1) return 1;
    else return n * mch(n - 1);
}
ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}
ll inv_mod(ll a, ll mod) { //逆元
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

//宣言とか
ll dp[100010];
/*signed*/int main(void) {
    int n, w;
    cin >> n >> w;
    vector<ll> val(n);
    vector<ll> wight(n);
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        for (int j = w; j >= 0; j--) {
            if (0 <= j - x) dp[j] = max(dp[j], dp[j - x] + y);
        }
    }
    cout << dp[w] << endl;
    return 0;
}

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

int main() {
  int n;
  while ( cin >> n, n ) {
    vector<int> a(n+1);
    vector<double> d(10001, 100000000.0);
    d[0] = 0;
    vector<int> is(10001, 0);
    a[0] = 0;
    for ( int i = 1; i <= n; i++ ) {
      cin >> a[i];
      is[a[i]] = 1;
    }

    double b;
    cin >> b;
    
    int r;
    double v, e, f;
    cin >> r >> v >> e >> f;

    for ( int i = 0; i < n; i++ ) {
      int x = 0;
      vector<double> dd = d;
      if ( i > 0 ) d[a[i]] += b;      
      for ( int j = a[i]; j < a[n]; j++ ) {
	if ( x >= r ) {
	  d[j+1] = d[j]+(1.0/(v-e*(x-r)));	  
	} else {
	  d[j+1] = d[j]+(1.0/(v-f*(r-x)));	  
	}
	x++;	
      }
      for ( int j = 1; j <= n; j++ ) {
	d[a[j]] = min(d[a[j]], dd[a[j]]);	
      }
    }

    printf("%.12lf\n", d[a[n]]);    
  }
  return 0;
}



Measured memory_bytes: 3248
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
using namespace std;
char name[100];
int main(void){
    long long N;
    cin >> N;
    stack<int> s;
    while(N > 0){
        int n = N % 26;
        s.push(n == 0 ? 26 : n);
        if(n == 0)N-=26;
        N /= 26;
    }
    int i=0;
    while(!s.empty()){
        name[i++] = 96 + s.top();
        s.pop();
    };
    cout << name << endl;
}




Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 200200;
int n;
char s[N];
ll ans = 0;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%s", s);
	n = strlen(s);
	ll bal = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'B')
			bal++;
		else
			ans += bal;
	}
	printf("%lld\n", ans);

	return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    int N,K; cin>>N>>K;
    
    vector<ll> dp;
    dp.push_back(1);
    for (int i=1;;i++) {
        ll d = 2*dp[i-1];
        dp.push_back(d);
        if (d >= K) {
            break;
        }
    }

    // for (int i=0;i<dp.size();i++){
    //     cout << dp[i] << endl;
    // }

    double p=0.0;
    for (int n=1;n<=N;n++) {
        if (n <= K-1) {
            int x;
            for (int i=1;i<dp.size();i++){
                if (dp[i]*n >= K) {
                    x = i;
                    break;
                }
            }
            p += (1.0/N)*pow(1.0/2.0, x);
        } else {
            p += (1.0/N);
        }      
    }

    cout << std::setprecision(15) << p << endl;

    return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    int X, Y;
    cin >> X >> Y;

    for_(a,0,X+1) {
        int b = X - a;
        int y = 2 * a + 4 * b;
        if (y == Y) {
            puts("Yes");
            return 0;
        }
    }

    puts("No");
}

Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

string YorN(bool P) { if (P)return "Yes"; else return "No"; }

int main() {

    string s;
    cin >> s;
    
    s[5] = s[13] = ' ';

    cout << s << endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
long n,k,a=0,i,j,m=1e9+7,v[2<<20];main(){std::cin>>n>>k;for(i=0;i<n;i++)std::cin>>v[i];for(i=0;i<n;i++)for(j=0;j<n;j++){if(i==j)continue;if(v[i]>v[j])(a+=k*(k-1)/2+(i<j?k:0))%=m;}std::cout<<a;}


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

using namespace std;

char str[200005];

int main() {
  scanf("%s",str+1);
  int n=strlen(str+1);
  int s=0,len=0;
  bool v=0;
  for(int i=1;i<=n;i++) {
  	len++;
  	if (i==n||str[i]!=str[i+1]) {
  		if (len%3==0) s+=len/3*2;
		else if (len%3==1) {
		    v=0;
		    s+=len/3*2+1;
		}
		else {
			s+=len/3*2+1;
			if (v) {
				s++;
				v=0;
			}
			else v=1;
		}
		len=0;
	  }
  }
  printf("%d\n",s);
  return 0;
}

Measured memory_bytes: 384
import heapq
import sys
input = sys.stdin.readline
 
 
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    heapq.heapify(A)
 
    BC = []
    for _ in range(M):
        b, c = map(int, input().split())
        BC.append([c*(-1), b])
    heapq.heapify(BC)
    
    flg = True
    while flg:
        if len(BC)==0:
            break
        c, b = heapq.heappop(BC)
        c *= -1
        for _ in range(b):
            a = heapq.heappop(A)
            if a<c:
                heapq.heappush(A, c)
            else:
                heapq.heappush(A, a)
                flg = False
                break

    print(sum(A))
        
 
 
if __name__ == '__main__':
    main()


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n;
    cin >> n;
    int d, x;
    cin >> d >> x;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    for(int i = 0; i < n; i++){
        x++;
        int t = 1;
        while(t*a[i]+1 <= d){
            x++;
            t++;
        }
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,j,lens;
    string s,t;
    char last;
    cin>>s>>t;
    lens=s.length();
    for(i=0; i<lens; i++)
    {
        string r;
        last=s[lens-1];
        r=last+s.substr(0,lens-1);
        if(t==r)
        {
            return cout << "Yes",0;
        }
        s=r;
    }
    return cout << "No",0;
    return 0;
}





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

int main(){
	int a , b ;
	cin >> a >> b ;
	
	if( a < b ){
		cout << "a < b" << endl ;
	} else if( a > b ) {
		cout << "a > b" << endl ;
	} else {
		cout << "a == b" << endl ;
	}

	return 0 ;
} 

Measured memory_bytes: 1156
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class DMaximumSumOfMinimum {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n, a, b;
        in >> n;
        vector<int> g[10010];
        vector<int> c(n, 0);
        rep(i, n-1){
            in >> a >> b;
            a--; b--;
            g[a].push_back(b);
            g[b].push_back(a);
        }
        rep(i, n){
            in >> c[i];
        }

        sort(all(c), greater<int>());
        int cind = 0;
        vector<int> res(n, 0);
        vector<int> visit(n, 0);
        queue<int> q;
        q.push(0);
        while(!q.empty()){
            int u = q.front(); q.pop();
            res[u] = c[cind++];
            visit[u] = 1;
            for(auto const& e : g[u]){
                if(visit[e]) continue;
                q.push(e);
            }
        }

        ll res_score = 0;
        reps(i, 1, c.size()-1){
            res_score += c[i];
        }

        out << res_score << endl;
        rep(i, res.size()){
            out << res[i];
            if(i != res.size()-1) out << " ";
        }
        out << endl;
	}
};


int main() {
	DMaximumSumOfMinimum solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define NIL -1
#define MAX 25

struct Node{
	int parent,left,right;
	Node(){
		parent = NIL;
	}
	};
	
Node node[MAX];

void preParse(int id){
	if(id==NIL){return;}
	cout<<" "<<id;
	preParse(node[id].left);
	preParse(node[id].right);
}

void inParse(int id){
	if(id==NIL){return;}
	inParse(node[id].left);
	cout<<" "<<id;
	inParse(node[id].right);
}

void postParse(int id){
	if(id==NIL){return;}
	postParse(node[id].left);
	postParse(node[id].right);
	cout<<" "<<id;
}

int main() {
	// your code goes here
	int n;
	int id,left,right;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>id>>left>>right;
		node[id].left=left;
		node[id].right=right;
		if(right!=NIL){node[right].parent=id;}
		if(left!=NIL){node[left].parent=id;}
	}
	int root;
	for(int i=0;i<n;i++){
		if(node[i].parent==NIL){
			root = i;
		}
	}
	cout<<"Preorder"<<endl;
	preParse(root);
	cout<<endl<<"Inorder"<<endl;
	inParse(root);
	cout<<endl<<"Postorder"<<endl;
	postParse(root);
        cout<<endl;
	
	return 0;
}

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

int main(){
  int N,Y;
  cin >> N >> Y;
  bool match = false;
  for(int x = 0; x <= N ; x++){
    for(int y = 0; y <= N - x; y++){
      int z = N - x - y;
      if(Y == x*10000 + y * 5000 + z * 1000){
        cout << x << " " << y << " " << z << endl;
        match = true;
        break;
      }
    }
    if(match == true){
      break;
    }
  }
  if(match == false){
    cout << "-1 -1 -1" << endl;
  }
}

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

int main(){
  int i, a, b;
  cin >> i;
  if(i == 1){
    cout << "Hello World" << endl;
  }else if(i == 2){
    cin >> a >> b;
    cout << a+b << endl;
  }else{
    cout << "I like vim!" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iterator>
#include <array>
#include <cmath>

#define int long long

using namespace std;

const int inf = 1e12 + 57;

signed main()
{   
    int n;
    cin >> n;
    cout << (n + 1) / 2;
}

Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main extends App {
  val n = readLine.toInt
  val s = (for(i <- 0 until n) yield readLine.toInt).sorted
  val sum = s.sum
  val m = s.find(_ % 10 != 0)
  if(sum % 10 != 0) println(sum)
  else {
    m match {
      case Some(m) => println(sum - m)
      case _ => println(0)
    }
  }
}

Measured memory_bytes: 27328
S = str(input())
s = S[::-1]
if S == s:
    A = S[:len(S)//2]
    a = A[::-1]
    B = S[len(S)//2+1:]
    b = B[::-1]
    if (A == a)and(B == b):
        print('Yes')
        exit(0)
print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (b < a)
    cout << a-1 << endl;
  else
    cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int N=2e5+5;
const int mo=1e9+7;
int n,x,tot,ans,a[N],f[N],nex[N],p[N];
int read()
{
	int x=0;
	char ch=getchar();
	for (;ch<'0' || ch>'9';) ch=getchar();
	for (;ch>='0' && ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}
int main()
{
	n=read();
	for (int i=1;i<=n;i++) 
	{
		x=read();
		if (x^a[tot]) a[++tot]=x;
	}
	n=tot;
	for (int i=n;i;i--)
	{
		nex[i]=p[a[i]];
		p[a[i]]=i;
	}
	f[1]=1;
	for (int i=1;i<=n;i++)
	{
		f[nex[i]]=(f[nex[i]]+f[i])%mo;
		f[i+1]=(f[i+1]+f[i])%mo;
	}
	printf("%d",f[n+1]);
	return 0;
}



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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }
  vector<int> freqs(10, 0);
  vector<int> thresholds = { 400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 10000 };
  int n = thresholds.size();
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < n; ++j) {
      if (A[i] < thresholds[j]) {
        ++freqs[j];
        break;
      }
    }
  }
  int base = 0, extra = 0;
  for (int i = 0; i < n; ++i) {
    if (freqs[i] > 0) {
      if (i == n - 1) { extra = freqs[i]; }
      else { ++base; }
    }
  }
  int least = base;
  if (extra > 0 and base == 0) { least = 1; }
  int most = base + extra;
  printf("%d %d\n", least, most);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=310;
int n,m,x,y,q;
ll l,z,ans,w[MAXN][MAXN],t[MAXN][MAXN];
int main () {
	memset(w,0x3f,sizeof(w));
	memset(t,0x3f,sizeof(t));
	scanf("%d%d%lld",&n,&m,&l);
	for (int i=1;i<=n;i++) {w[i][i]=t[i][i]=0;}
	for (int i=1;i<=m;i++) {
		scanf("%d%d%lld",&x,&y,&z);
		w[x][y]=w[y][x]=z;
	}
	for (int k=1;k<=n;k++) {
		for (int i=1;i<=n;i++) {
			for (int j=1;j<=n;j++) {
				w[i][j]=min(w[i][j],w[i][k]+w[k][j]);
			}
		}
	}
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=n;j++) {
			if (w[i][j]<=l) {
				t[i][j]=1;
			}
		}
	}
	for (int k=1;k<=n;k++) {
		for (int i=1;i<=n;i++) {
			for (int j=1;j<=n;j++) {
				t[i][j]=min(t[i][j],t[i][k]+t[k][j]);
			}
		}
	}
	scanf("%d",&q);
	for (int i=1;i<=q;i++) {
		scanf("%d%d",&x,&y);
		printf("%lld\n",t[x][y]==0x3f3f3f3f3f3f3f3f?-1:t[x][y]-1);
	}
	return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int n, x, d;
vector<P> robots_finish;
vector<Int> robots_index;

int main(){
    cin >> n;
    for(Int i = 0;i < n;i++){
        cin >> x >> d;
        Int y = x + d;
        robots_finish.push_back(P(y,x));
        robots_index.push_back(x);
    }
    robots_finish.push_back(P(LINF, LINF+1));
    robots_index.push_back(LINF);
    n++;

    sort(robots_finish.rbegin(), robots_finish.rend());
    sort(robots_index.begin(), robots_index.end());

    priority_queue<Int> s;
    map<Int, Int> robot_dict;
    Int r = 0;
    vector<Int> l(n, -1);
    
    for(Int i = 0;i < n;i++){
        robot_dict[robots_index[i]] = i;
    }
    for(Int i = n-1;i >= 0;i--){
        while(r < n && robots_finish[r].first > robots_index[i]){
            s.push(robots_finish[r].second);
            r++;
        }
        while(!s.empty() && s.top() >= robots_index[i]){
            s.pop();
        }
        if(!s.empty())l[i] = robot_dict[s.top()];
    }

    vector<Int> dp(n, 0);
    vector<Int> dp_sum(n, 0);
    
    dp[0] = dp_sum[0] = 1;
    for(Int i = 1;i < n;i++){
        dp[i] = dp_sum[i-1];
        if(l[i]-1 >= 0){
            dp[i] -= dp_sum[l[i]-1];
        }
        if(l[i] == -1){
            dp[i]++;
        }
        dp[i] %= MOD2;
        dp_sum[i] = (dp_sum[i-1] + dp[i]) % MOD2;
    }

    if(dp[n-1] < 0)dp[n-1] += MOD2;

    cout << dp[n-1] << endl;
    
    return 0;
}

Measured memory_bytes: 24684
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd

# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace

# from queue import PriorityQueue as pq

# def reduce(p, q):
#     common = fractions.gcd(p, q)
#     return (p//common , q//common )
# # from itertools import accumulate
# # from collections import deque

# from operator import mul
# from functools import reduce

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

# import random


def main():
    # a,b,c,d = map(int, input().strip().split())
    l_abcd = list(map(int,input().strip()))
    eprint("l_abcd ",end=": ")
    eprint(l_abcd)
    for case in range(2 ** 3):     # 場合ループ # nは人とかモノとかの個数
        l_op_bin = list(map(int,(format(case,'b').zfill(3))))
        # eprint("l_op_bin ",end=": ")
        # eprint(l_op_bin)
        
        #flag=0
        sum_x=l_abcd[0]
        l_op=[]
        for index_location in range(3):      # 人とかモノとかループ
            if l_op_bin[index_location]==1:                   # その桁がyesだと仮定している場合
               sum_x += l_abcd[1+index_location]
               l_op.append("+")
            else:                                 # その桁がnoだと仮定している場合
               sum_x -= l_abcd[1+index_location]
               l_op.append("-")
        if sum_x==7:
            print(l_abcd[0], end="")
            print(l_op[0],end="")
            print(l_abcd[1], end="")    
            print(l_op[1],end="")
            print(l_abcd[2], end="")    
            print(l_op[2],end="")
            print(l_abcd[3], end="=7\n")
            return
if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int h,w,n;
  cin >> h >> w >> n;
  int a[n];
  rep(i,n) R a[i];
  int c[h][w],k=0;
  rep(i,h) {
    if(i%2) {
      rrep(j,w) {
        c[i][j]=k+1;
        a[k]--;
        if(!a[k]) k++;
      }
    } else {
      rep(j,w) {
        c[i][j]=k+1;
        a[k]--;
        if(!a[k]) k++;
      }
    }
  }
  rep(i,h) PR(c[i],w);
}

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


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

#define MAXN 100010

int n,cnt[MAXN],ans[MAXN];
char s[MAXN];

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	int now=0;
	for(int i=1;i<=n;++i)
	{
		if(s[i]=='R')
		{
			++now;
		}
		else
		{
			cnt[i]=now;
			now=0;
		}
	}
	for(int i=n;i>=1;--i)
	{
		if(s[i]=='L')
		{
			++now;
		}
		else
		{
			cnt[i]=now;
			now=0;
		}
	}
	for(int i=1;i<=n;++i)
	{
		if(s[i]=='L')
		{
			ans[i]+=cnt[i]/2;
			ans[i-1]+=(cnt[i]+1)/2;
		}
		else
		{
			ans[i]+=cnt[i]/2;
			ans[i+1]+=(cnt[i]+1)/2;
		}
	}
	for(int i=1;i<=n;++i)printf("%d ",ans[i]);
}

Measured memory_bytes: 1280
int main() {
    int a = 0, b = 0, c = 0;
    int tmp;

    scanf("%d %d %d", &a, &b, &c);
    if(a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    if(b > c) {
        tmp = b;
        b = c;
        c = tmp;
    }
    if(a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    printf("%d %d %d\n", a, b, c);
    return 0;
}


Measured memory_bytes: 2036
#include <stdio.h>
#define SIZE 100
#define MAX 1000

int stack[SIZE];
int size = 0;

int pop()
{
  if (size <= 0) return 0;
  return stack[--size];
}

int push(int a)
{
  stack[size++] = a;
}

int is_digit(char *s)
{
  if (*s == '+' || *s =='-') {
    s++;
    if (*s >= '0' && *s <= '9') return 1;
    return 0;
  }

  if (*s >= '0' && *s <= '9') return 1;
  return 0;
}

int get_number(char *s)
{
  int sign = 0, n = 0;

  if (*s == '+') {
    s++;
  } else if (*s == '-') {
    sign = 1;
    s++;
  }

  while (*s >= '0' && *s <= '9') {
    n = n * 10 + (*s - '0');
    s++;
  }

  if (sign) return -n;
  return n;
}int calc(char *s)
{
  int a, b, n;

  while (*s) {

    if (is_digit(s)) {
      n = get_number(s);
      push(n);
      while (*s == '-' || *s == '+') {
        s++;
      }
      while (n) {
        n /= 10;
        s++;
      }

    } else {
      switch (*s) {
      case '+':
        a = pop();
        b = pop();
        push(b+a);
        break;
      case '-':
        a = pop();
        b = pop();
        push(b-a);
        break;
      case '*':
        a = pop();
        b = pop();
        push(b*a);
        break;   }
      s++;
    }
  }
  return pop();
}
int main()
{
  char s[MAX];
  scanf("%[^\n]*s", s);
  printf("%d\n",calc(s));
  return 0;
}

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

typedef long long ll;

#define F first 
#define S second 
#define PB push_back
#define MP make_pair 
#define rep(i,a,b) for (ll i=a;i<b;i++)

typedef vector<int> vi;
typedef pair<int,int> pi;


int main()
{
    int a,b;
    cin>>a>>b;

    rep(i,1,4)
    {
        if(i!=a && i!=b)
        {
            cout<<i<<endl; 
            return 0; 
        }
    }

    return 0; 
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
	int n,a;
	cin>>n>>a;
	cout<<(n+a-1)/a<<endl;
	return 0;
}

Measured memory_bytes: 256