akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>

using namespace std;

int up(int x){
	return (x-1) - (x-1)%10 + 10;
}

int main() {
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	int m;
	m=min((a-1)%10,min((b-1)%10,min((c-1)%10,min((d-1)%10,(e-1)%10))))+1;
	cout<<up(a)+up(b)+up(c)+up(d)+up(e)+m-10<<endl;
}


Measured memory_bytes: 256
// D - Friend Suggestions
// UnionFinde version (simple)
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

class UF{
	vector<int> prsz;// parent & size
	public:
	UF(int n): prsz(n, -1){}
	int operator[](int v){return prsz[v] < 0? v: prsz[v]=operator[](prsz[v]);}//root
	bool operator()(int v, int u){//unite
		v = operator[](v); u = operator[](u);
		if(v == u) return false;
		if(size(v) < size(u)) swap(v, u);
		prsz[v] += prsz[u];
		prsz[u] = v;
		return true;
	}
	int size(int x){return -prsz[operator[](x)];}
};

int main(){
	int N,M,K; scanf("%d%d%d",&N,&M,&K);
	UF uf(N);
	vi c(N);
	int s,t;
	rp(i,0,M){
		scanf("%d%d",&s,&t); s--; t--;
		uf(s,t);//unite(s,t)
		c[s]++; c[t]++;
	}
	rp(i,0,K){
		scanf("%d%d",&s,&t); s--; t--;
		if(uf[s] == uf[t]) c[s]++, c[t]++;//root(s)==root(t)?
	}
	rp(i,0,N) printf("%d ", uf.size(i)-c[i]-1);
}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	int s = stoi(a+b);
	for (ll i = 1; i <= 1000; i++) {
		if (i*i == s) {
			cout << "Yes" << endl;
			exit(0);
		}
	}

	cout << "No" << endl;
}

Measured memory_bytes: 256
N=int(input())
D=[int(i) for i in input().split()]
M=int(input())
T=[int(i) for i in input().split()]

D.sort()
T.sort()

indexD=0
indexT=0
while indexD<len(D) and indexT<len(T):
	if D[indexD]==T[indexT]:
		indexD+=1
		indexT+=1
	else:
		indexD+=1
if indexT==len(T):
	print("YES")
else:
	print("NO")

Measured memory_bytes: 35556
def main():
    p=input()
    q=input()
    lp=len(p)
    lq=len(q)
    memop=[[0,0] for _ in [0]*(lp+2)]
    memoq=[[0,0] for _ in [0]*(lq+2)]
    memop[lp+1]=[lp+1,lp+1]
    memoq[lq+1]=[lq+1,lq+1]
    memop[lp]=[lp+1,lp+1]
    memoq[lq]=[lq+1,lq+1]
    
    for i in range(lp-1,-1,-1):
        if p[i]=="0":
            memop[i][0]=i+1
            memop[i][1]=memop[i+1][1]
        else:
            memop[i][0]=memop[i+1][0]
            memop[i][1]=i+1
    for i in range(lq-1,-1,-1):
        if q[i]=="0":
            memoq[i][0]=i+1
            memoq[i][1]=memoq[i+1][1]
        else:
            memoq[i][0]=memoq[i+1][0]
            memoq[i][1]=i+1
    
    dp=[dict() for _ in [0]*(lp+2)]
    dp[lp+1][lq+1]=[0,0]
    q=[[0,0]]
    while q:
        i,j=q.pop()
        if j not in dp[i].keys():
            dp[i][j]=[None,None]
            a,b=None,None
        else:
            a,b=dp[i][j]
        if a==None or b==None:
            q.append([i,j])
            if a==None:
                ap,bq=memop[i][0],memoq[j][0]
                if bq not in dp[ap].keys():
                    dp[ap][bq]=[None,None]
                    q.append([ap,bq])
                else:
                    aa,bb=dp[ap][bq]
                    if aa==None or bb==None:
                        q.append([ap,bq])
                    else:
                        dp[i][j][0]=min(aa,bb)+1
            if b==None:
                ap,bq=memop[i][1],memoq[j][1]
                if bq not in dp[ap].keys():
                    dp[ap][bq]=[None,None]
                    q.append([ap,bq])
                else:
                    aa,bb=dp[ap][bq]
                    if aa==None or bb==None:
                        q.append([ap,bq])
                    else:
                        dp[i][j][1]=min(aa,bb)+1

    q=[[0,0]]
    ans=""
    while q:
        i,j=q.pop()
        a,b=dp[i][j]
        if a==0 or b==0:
            break
        if a>b:
            q.append([memop[i][1],memoq[j][1]])
            ans+="1"
        else:
            q.append([memop[i][0],memoq[j][0]])
            ans+="0"
    print(ans)
                
if __name__=='__main__':
    main()


Measured memory_bytes: 729476
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;
L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L M(L f){return f?B[f]+M(f^f&-f):0;}
L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}
L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)
  d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,Z[d]=1,D(d),Z[f]+=Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}
int N;
main(){for(cin>>n>>k,N=n;--n;*Z-=T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(a=0);n<N;a=H[P[++n]]-n?n:0)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;
       //*Z-=*O=W(*O=0);
       for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

Measured memory_bytes: 38056
use std::io::*;
    use std::str::*;
     
    fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
        let s = s.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        s.parse::<T>().ok()
    }
     
    fn main(){
        let stdin = stdin();
        let mut stdin = stdin.lock();
        let stdin = &mut stdin;
        let a: i32 = read(stdin).unwrap();
        let b: i32 = read(stdin).unwrap();
        let plus = a + b;
        let minus = a - b;
        let multiple = a * b;
        if plus >= minus && plus >= multiple {
            println!("{}",plus)
        } else if minus >= plus && minus >= multiple {
            println!("{}",minus)
        } else{
            println!("{}",multiple)
        }
    }

Measured memory_bytes: 4352
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

#maincode-------------------------------------------------
k = ini()
a,b = inm()
ans = 'NG'
for i in range(1000):
    if a <= i * k <= b:
        ans = 'OK'
print(ans)

Measured memory_bytes: 62212
using System;
using System.Linq;
 
public class Program
{
	public static void Main()
	{
		long[] size = Console.ReadLine().Split().Select(i => long.Parse(i))
			.OrderBy(i => i).ToArray();
		Console.WriteLine(size.Any(i => i % 2 == 0) ? 0 : size[0] * size[1]);
	}
}

Measured memory_bytes: 3288
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, M): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (a, b): (Vec<i64>, Vec<i64>) = {
        let (mut a, mut b) = (vec![], vec![]);
        for _ in 0..N {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            a.push(iter.next().unwrap().parse().unwrap());
            b.push(iter.next().unwrap().parse().unwrap());
        }
        (a, b)
    };
    let (c, d): (Vec<i64>, Vec<i64>) = {
        let (mut c, mut d) = (vec![], vec![]);
        for _ in 0..M {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            c.push(iter.next().unwrap().parse().unwrap());
            d.push(iter.next().unwrap().parse().unwrap());
        }
        (c, d)
    };

    let ans = (0..N).map(|i|
        (1 + (0..M).min_by_key(|&j| (a[i] - c[j]).abs() + (b[i] - d[j]).abs()).unwrap()).to_string()
    ).collect::<Vec<_>>()
    .join("\n");

    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n, m, c = [int(num) for num in lines.pop(0).split(" ")]
b_list = [int(num) for num in lines.pop(0).split(" ")]
def iter_a_list():
    for line in lines:
        yield [int(num) for num in line.split(" ")]

ans = 0
for a_list in iter_a_list():
    value = sum(a * b for a, b in zip(a_list, b_list))
    if value + c > 0:
        ans += 1
print(ans)


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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  for (int i = 0; i < N - 1; i++) {
    if (S[i] == S[i + 1]) {
      cout << i + 1 << " " << i + 2 << endl;
      return 0;
    }
  }
  for (int i = 0; i < N - 2; i++) {
    if (S[i] == S[i + 2]) {
      cout << i + 1 << " " << i + 3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
use std::io::BufRead;
use std::str::FromStr;

fn main() {
    let stdin = std::io::stdin();
    let mut t = Tokenizer::new(stdin.lock().lines().map(|x| x.unwrap()));

    let n: i32 = t.take();
    let mut d: Vec<i32> = Vec::new();
    for _i in 0..n {
        d.push( t.take() );
    }
    let ans = problem( n,d );
    println!("{}",ans);
}

fn problem( n: i32, d: Vec<i32> ) -> i64 {
    let mut sum: i64 = 0;
    for i in 0..n {
        for j in i+1..n {
            if i == n {
                continue;
            }
            sum += (d[i as usize]*d[j as usize]) as i64;
        }
    }
    sum
}

#[cfg(test)]
mod test {
    use super::*;
    #[test]
    fn test1() {
        let result = problem( 3, vec![3,1,2] );
        assert_eq!(result,11);
    }
    #[test]
    fn test2() {
        let result = problem( 7, vec![5,0,7,8,3,3,2] );
        assert_eq!(result,312);
    }
}


struct Tokenizer<S: Iterator<Item = String>> {
    input: S,
    items: Vec<String>,
}

impl<S: Iterator<Item = String>> Tokenizer<S> {
    pub fn new(input: S) -> Self {
        Tokenizer {
            input: input,
            items: Vec::new(),
        }
    }

    pub fn take<T: FromStr>(&mut self) -> T {
        loop {
            if let Some(r) = self.items.pop() {
                return r.parse().ok().expect("parse failed");
            }
            let mut items = self
                .input
                .next()
                .unwrap()
                .split_whitespace()
                .map(|x| x.to_string())
                .collect::<Vec<String>>();
            items.reverse();
            self.items = items;
        }
    }
}


Measured memory_bytes: 4352
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

auto readNum(T)(){
  return readln.chomp.to!T;
}

auto readNums(T)(){
  return readln.chomp.split.to!(T[]);
}

void main(){
  auto ab = readNums!int;
  if(ab[0] <= 5){
    writeln(0);
  } else if(ab[0] <= 12){
    writeln(ab[1] / 2);
  } else {
    writeln(ab[1]);
  }
}


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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int n, y;
int ans[3] = {-1, -1, -1};

int main()
{
    cin >> n >> y;
    REP(a, 2001)
    {
        REP(b, 2001)
        {
            int nn = n - a - b;
            int yy = y - a * 10000 - 5000 * b;
            if (nn < 0 || yy < 0)
            {
                continue;
            }
            int c = yy / 1000;
            if (c == nn)
            {
                ans[0] = a;
                ans[1] = b;
                ans[2] = c;
                break;
            }
        }
    }
    cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
}

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

using namespace std;

class AbsBit
{
public:
    AbsBit(int64_t offset) : bit_(2 * offset + 2, 0), offset_(offset) {}

    void Add(int64_t pos);

    int64_t CountSmaller(int64_t pos) const;

private:
    static int64_t Lsb(int64_t num) { return num & -num; }

    vector<int64_t> bit_;
    int64_t offset_;
};

void AbsBit::Add(int64_t pos)
{
    pos += offset_;
    while (pos < (int64_t)bit_.size()) {
        bit_[pos] += 1;
        pos += Lsb(pos);
    }
}

int64_t AbsBit::CountSmaller(int64_t pos) const
{
    pos += offset_;

    int64_t count = 0;
    while (pos > 0) {
        count += bit_[pos];
        pos -= Lsb(pos);
    }
    return count;
}

int64_t CountBigSubs(int64_t med, const vector<int64_t> &vec)
{
    int64_t balance = 0;
    int64_t subs = 0;
    AbsBit bit(vec.size() + 1);

    for (const auto &num : vec) {
        balance += (num >= med ? 1 : -1);
        subs += bit.CountSmaller(balance) + (balance >= 0 ? 1 : 0);
        bit.Add(balance);
    }
    return subs;
}

bool SmallEnough(int64_t med, const vector<int64_t> &vec)
{
    int64_t total_subs = 1LL * vec.size() * (vec.size() - 1) / 2 + vec.size();
    int64_t half_subs = (total_subs + 1) / 2;

    return CountBigSubs(med, vec) >= half_subs;
}

int MedianOfMedians(const vector<int64_t> &vec)
{
    int res = 0;
    int pow = (1 << 30);

    while (pow > 0) {
        auto next_res = res + pow;
        pow >>= 1;

        if (SmallEnough(next_res, vec)) {
            res = next_res;
        }
    }
    return res;
}

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

    vector<int64_t> vec(n);
    for (auto &num : vec) {
        cin >> num;
    }

    auto res = MedianOfMedians(vec);
    cout << res << "\n";

    return 0;
}


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

int main(){
    int n;
    int x;
    int t;

    cin >> n >> x >> t;

    int count = 0;
    while(true){
        n -= x;
        count += t;
        if(n <= 0)
            break;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3672
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

string S,T;
 
string ans = "Yes";
 
void solve(){
    int N = S.size();
    //TとSの、文字の対応を管理
    vector<char> TtoS(26,'-');
    vector<char> StoT(26,'-');
    for(int i=0;i<N;i++){
        if(TtoS[T[i]-'a']==S[i] && StoT[S[i]-'a']==T[i]) continue;
        if(TtoS[T[i]-'a']=='-' && StoT[S[i]-'a']=='-'){
            TtoS[T[i]-'a'] = S[i];
            StoT[S[i]-'a'] = T[i];
            continue;
        }
        ans = "No";
        return;
    }
}
 
int main(){
    cin >> S;
    cin >> T;
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define ll long long
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mem(a,t) memset(a,t,sizeof(a))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define sz(v) ((int)sizeof(v))
const int inf=1e9;
const int N=1e5+5;
const int mod=1e9+7;
int main(){
    ios_base::sync_with_stdio(false);
    ll n,m;
    ll ans=1;
    cin>>n>>m;
    if(n<m) swap(n,m);
    if(!(n==m||n==m+1)){
        cout<<0<<endl;
        return 0;
    }
    for(int i=1;i<=n;++i){
        ans=ans*i;
        ans%=mod;
    }
    for(int i=1;i<=m;++i){
        ans*=i;
        ans%=mod;
    }
    if(n==m) ans=(ans*2)%mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;

int main(){
	long q, h, s, d, n;
	scanf("%ld%ld%ld%ld%ld", &q, &h, &s, &d, &n);
	if(q*4 < s){
		s = q*4;
	}
	if(h*2 < s){
		s = h * 2;
	}
	if(2*s < d){
		printf("%ld\n", s * n);
	}else{
		printf("%ld\n", (n/2)*d + (n%2) * s);
	}
	return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll h, w, m;
    cin >> h >> w >> m;


    map<ll,ll> ch, cw;
    map<pair<ll,ll>, bool> mp;
    rep(i, m){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        mp[{a, b}] = 1;
        ch[a]++;
        cw[b]++;
    }

    ll mah = 0;
    ll maw = 0;
    ll mahi = 0;
    ll mawi = 0;
    for(auto &i : ch){
        if(mah < i.second){
            mah = i.second;
            mahi = i.first;
        }
    }

    for(auto &i : cw){
        if(maw < i.second){
            maw = i.second;
            mawi = i.first;
        }
    }

    ll ans = 0;
    for(auto &i : ch){
        ll tmp = i.second + maw;
        if(mp[{i.first, mawi}]){
            tmp--;
        }
        ans = max(ans, tmp);
    }

    for(auto &i : cw){
        ll tmp = i.second + mah;
        if(mp[{mahi, i.first}]){
            tmp--;
        }
        ans = max(ans, tmp);
    }

    cout << ans << endl;




}   

Measured memory_bytes: 97260
n = int(input())
r = []
if n%2==0:
    c = 1
else: 
    c = 0
for i in range(1, n+1):
    for j in range(i+1, n+1):
        if n-i+c == j:
            continue
        else:
            r.append([i, j])
print(len(r))
for i in r:
    print(*i)

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



using namespace std;


int main()
{
	int n, m;
	cin >> n >> m;

	vector<int> a;
	vector<int> b;

	a.resize(m);
	b.resize(m);

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

	int count;

	for (int i = 0;i < n;i++)
	{
		count = 0;
		for (int j = 0;j < m;j++)
		{
			if (a[j] == i + 1)
			{
				count++;
			}
			if (b[j] == i + 1)
			{
				count++;
			}
		}
		cout << count << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include <iomanip>
using namespace std;
int main(){
  cout << fixed << setprecision(12);
    int N, K;
    cin >> N >> K;
    double tempResult = 0;
    for  (int i = 1; i <= N; i++){
        int tempNumber = i;
        int count = 0;

        while(1){
            if(tempNumber >= K){
                break;
            }
            tempNumber = tempNumber * 2;
            count++;
        }

        tempResult += 1.0/N * pow(0.5,count);
    }
    cout << tempResult << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define MAX 50022

void sieve(void);

int prime[MAX] = {1, 1};

int main(void) {
    int i, j, n;
    for(sieve(); ~scanf("%d", &n); printf("%d %d\n", i, j)) {
        for(i = ~-n; prime[i]; i--);
        for(j = -~n; prime[j]; j++);
    }
    return 0;
}

void sieve(void) {
    int i, j, n = sqrt(MAX);
    for(i = 2; i < MAX; prime[i += 2]++);
    for(i = 3; i <= n; i += 2) {
        if(!prime[i]) {
            for(j = i * 2; j < MAX; j += i) {
                prime[j]++;
            }
        }
    }
}

Measured memory_bytes: 788
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        s: Chars,
    }
    let b = s.iter().position(|c| *c == 'B');
    if let Some(b) = b {
        let tmp: Vec<_> = s
            .iter()
            .enumerate()
            .skip(b)
            .filter(|(_, c)| **c == 'W')
            .map(|(i, _)| i - b)
            .collect();
        println!(
            "{}",
            tmp.iter().enumerate().map(|(i, j)| j - i).sum::<usize>()
        );
    } else {
        println!("0");
    }
}


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

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;



int main(){
    bool flag=true;
    ll ans=0,sum=0;
    int n,m=100001;
    cin >>n;
    vector< pair<int,int> > b(n-1);
    vector<int> a(n);

    fill(all(a),-1);

    for (int i = 0; i < n-1; i++){
        int bi;
        cin >>bi;
        b[i] = mkp(bi,i);
    }

    sort(all(b));
    
    for (int i = 0; i < n-1; i++){
        int x=b[i].second;
        int v=b[i].first;

        if(a[x]==-1)a[x]=v;
        if(a[x+1]==-1)a[x+1]=v;
    }
    
    for (int i = 0; i < n; i++)ans += a[i];
    



    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = sorted(list(map(int, input().split())))
ans = 1

if n%2 == 0:
    for i in range(0, n, 2):
        if a[i] != i + 1 or a[i + 1] != i + 1:
            print(0)
            exit()
else:
    if a[0] != 0:
        print(0)
        exit()
    for i in range(1, n, 2):
        if a[i] != i + 1 or a[i + 1] != i + 1:
            print(0)
            exit()

for i in range(n//2):
    ans = ans*2%(10**9 + 7)

print(ans)

Measured memory_bytes: 20592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    int r;
    cin >> r;
    double x = double(2*r*PI);
    printf("%.10f\n", x);
    return 0;
}

Measured memory_bytes: 3788
import numpy
N, K  = map(int, input().split(' '))
right = 0
s = 0
for i in range(K, N+2):
    mi = (i-1)*i/2
    ma = (2*N-i+1)*i/2
    s += (ma - mi) + 1
print(int(s%(1e9+7)))



Measured memory_bytes: 27132
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <vector>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt;
ll a[1000001],idx=1;

ll gcd(ll a,ll b) { 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

int main(){
	ll n;
	cin>>n;
	string s=to_string(n);
	bool ok=false;
	for(ll i=0; i<s.size(); i++){
		if(s[i]=='7') ok=true;
	}
	if(ok==true) cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 3132
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, H[int(1e5+5)];
bool checked[int(1e5 + 5)];

int main(){
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; i++) scanf("%d", H + i);
  fill(checked, checked + N, true);

  for (int i = 0; i < M; i++){
    int A, B; scanf("%d%d", &A, &B);
    A--; B--;
    if (H[A] < H[B]){
      checked[A] = false;
    }else if (H[A] > H[B]){
      checked[B] = false;
    }else{
      checked[A] = false; checked[B] = false;
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++){
    if (checked[i]) ans++;
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 4304
//ABC149 D

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = s; i < (int)(n); i++)
const lint mod = 1000000007;


lint ans = 0;
lint n,k;
lint r,s,p;
string t;

int main() {
  cin >> n >> k;
  cin >> r >> s >> p;
  cin >> t;
  
  rep(i,k){
    string tmp = "x";
    string before = "x";
    int j = 0;
    while(i+j*k<n){
      tmp = t[i+j*k];
      j++;

      if(tmp == "r" && before != "r"){
        ans += p;
        before = tmp;
      }
      else if(tmp == "s" && before != "s"){
        ans += r;
        before = tmp;
      }
      else if(tmp == "p" && before != "p"){
        ans += s;
        before = tmp;
      }
      else before = "x";
      }
  }

  printf("%lld\n",ans);
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

int main(void){
    int S,W; cin >> S >> W;
    cout << (W >= S ? "unsafe" : "safe") << en;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll a,b;

int main(){
  cin >> a >> b;
  if(a == b) cout << a + b << endl;
  else cout << max(a,b)+max(a,b)-1 << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <math.h> // sqrt()
#include <iomanip>
#define rep(i , n) for (int i = 1; i <= (int)(n); i++)
#define repz(i , n) for (int i = 0; i < (int) n; i++)
#define repi(i , r, n) for (int i = r; i <= (int)(n); i++)
#define repd(i , r, n) for (int i = r; i >= (int)(n); i--)


using namespace std;


int main(){
    int n , m , p;
    int64_t y;
    cin >> n >> m;
    vector< vector<int64_t >> kentoyear(n + 1);
    vector<vector<int64_t>> pair( m + 1);
    rep( i , m){
        cin >> p;
        pair[i].push_back(p);
        cin >> y;
        pair[i].push_back(y);
        kentoyear[p].push_back(y);
    }
    rep(i , n) {
        if ( kentoyear[i].size())
            sort(kentoyear[i].begin(), kentoyear[i].end());
    }
    rep( i , m){
        auto it = find(kentoyear[pair[i][0]].begin(), kentoyear[pair[i][0]].end(), pair[i][1]);
        int index = int(distance(kentoyear[pair[i][0]].begin(), it));
        printf("%06d" , int(pair[i][0]));
        printf("%06d\n" , index + 1);
    }
}


Measured memory_bytes: 13984
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

x, y, z = mi()

print(z, x, y)

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

using namespace std;

int k;
string s;

int main()
{
    cin >> k;
    cin >> s;
    if(k > s.length()-1)
    {
        cout << s << endl;
    }
    else
    {
        s.erase(k,s.length()-k);
        s += "...";
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
x = input()
a = int(x[0])
bcd = list(map(int, [x[1], x[2], x[3]]))

for j in range(8):
    n = []
    op = []
    for i in range(3):
        if (j >> i) & 1:
            n.append(bcd[i])
            op.append("+")
        else:
            n.append(-bcd[i])
            op.append("-") if bcd[i] == 0 else op.append("")
    if a + sum(n) == 7:
        print(f"{a}{op[0]}{n[0]}{op[1]}{n[1]}{op[2]}{n[2]}=7")
        break

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, M, X;
  cin >> N >> M >> X;
  int a, counta = 0, countb = 0;
  for (int i = 0; i < M; i++) {
    cin >> a;
    if(a < X) counta++;
    else countb++;
  }
  cout << min(counta, countb) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main() 
{
    int i, x;
    for( i=1; i <= 10000 ; i++)
    {   
        cin >> x;
        if (x == 0)
        break;
        cout << "Case " << i << ": "  << x << endl;
      
       
    }
}


Measured memory_bytes: 3012
#include <iostream>

using namespace std;

typedef long long ll;
int ans[100005];

int main(int argc, char *argv[])
{
	string S;

	cin >> S;

	int len = S.size();

	int c = 0;
	int ri = 0, li = 0;
	int er = 0, odr = 0, el= 0, odl = 0;
	int eo = 0;
	for (int i = 0; i < len; i++) {
		if (i < len - 1 && S[i] == 'R' && S[i + 1] == 'L') {
			if (eo % 2 == 0) {
				er++;
				ans[i] += er;
				ans[i + 1] += odr;
			} else {
				odr++;
				ans[i] += odr;
				ans[i + 1] += er;
			}
			li = i + 1;
			odr = 0;
			er = 0;
			eo = 0;
		} else if (i < len - 1 && S[i] == 'L' && S[i + 1] == 'R') {
			if (eo % 2 == 0) {
				el++;
				ans[li] += el;
				ans[li - 1] += odl;
			} else {
				odl++;
				ans[li] += odl;
				ans[li - 1] += el;
			}
			odl = 0;
			el = 0;
			eo = 0;
		} else {
			if (S[i] == 'R') {
				if (eo % 2 == 0) {
					er++;
				} else {
					odr++;
				}
			} else {
				if (i == len - 1) {
					if (eo % 2 == 0) {
						el++;
						ans[li] += el;
						ans[li - 1] += odl;
					} else {
						odl++;
						ans[li] += odl;
						ans[li - 1] += el;
					}
				} else {
					if (eo % 2 == 0) {
						el++;
					} else {
						odl++;
					}
				}
			}
			eo++;
		}
	}

	for (int i = 0; i < len; i++) {
		printf("%d ", ans[i]);
	}
	puts("");

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++) cin >> d[i];
    sort(d.begin(), d.end());
    int mid = d[n / 2];
    int left = d[n / 2 - 1];
    cout << mid - left << endl;
    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
using namespace std;

 ll mod=1e9 +7;

ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

ll get_val(vector<ll>&ft,ll index)
{
  ll res=0;
  for(;index>=0;index=(index & (index+1))-1)
    res+=ft[index];
  return res;
}

void update(vector<ll>&ft,ll index,ll val)
{
  for(;index<(ll)ft.size();index|=index+1)
    ft[index]+=val;
}

ll func(ll x,ll y, ll z)
{
  return x*x + y*y + z*z + x*y + x*z + z*y;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //   #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    
    // Sieve();
   ll tests=1;
 // cin>>tests;
  // ll t=1;
    while(tests--)
    {
      ll i,j,k,n;
      cin>>n;
      vector<ll>a(n+1,0);
      rep(i,1,sqrt(n))
      {
        rep(j,1,sqrt(n))
        {
          rep(k,1,sqrt(n))
          {
            ll tmp=func(i,j,k);
            if(tmp<=n) a[tmp]++;
          }
        }
      }

      rep(i,1,n)
      {
        cout<<a[i]<<"\n";
      }

    }

    return 0;
   }

Measured memory_bytes: 14104
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

getInt = readInt <$> BS.getLine

calc :: [Int] -> Int -> Int -> Int -> Int
calc (n : ns) c i x
  | (c + n) >= x = i
  | otherwise = calc ns (c + n) (i + 1) x

main = do
  x <- getInt
  print $ calc [1 ..] 0 1 x


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

struct time {
	int a;
	int b;
};

int cmp(const void* p, const void* q) {
	return (*(struct time*)p).b - (*(struct time*)q).b;
}

int main(void) {
	int n;
	struct time work[200000];
	scanf("%d", &n);
	for (size_t i = 0; i < n; i++) {
		scanf("%d%d", &work[i].a, &work[i].b);
	}
	qsort(work, n, sizeof(struct time), cmp);
	long long sum = 0;
	for (size_t i = 0; i < n; i++) {
		sum += work[i].a;
		if (sum > work[i].b) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  int n, m; cin >> n >> m;
  n = n * (n-1) / 2;
  m = m * (m-1) / 2;
  cout << (n+m) << nl;
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  string n;
  cin >> n;
  for (int i = 0; i < n.size();++i)
  {
    if(n[i]=='7')
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<cstdio>
#include<cstring>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod=998244353;
#define N 400020
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,bit[N],b[N],bn;
ll dp[N];
struct Rob{
	int x,d;
}a[N];
bool cmp(Rob a,Rob b){
	return a.x<b.x;
}
inline int lowbit(int x){
	return x&(-x);
}
void Add(int x,int d){
	while(x){
		bit[x]=max(bit[x],d);
		x-=lowbit(x);
	}
}
int Ask(int x){
	int ans=0;
	while(x<=bn){
		ans=max(ans,bit[x]);
		x+=lowbit(x);
	}
	return ans;
}
int cnt,head[N];
struct Edge{
	int to,nxt;
}edge[N<<1];
void add(int a,int b){
	cnt++;
	edge[cnt].to=b;
	edge[cnt].nxt=head[a];
	head[a]=cnt;
}
void dfs(int u){
	dp[u]=1;
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		dfs(v);
		dp[u]=dp[u]*(dp[v]+1)%mod;
	}
}
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		a[i].x=read(),a[i].d=read()+a[i].x;
		b[++bn]=a[i].x,b[++bn]=a[i].d;
	}
	sort(b+1,b+bn+1);
	bn=unique(b+1,b+bn+1)-b-1;
	for(int i=1;i<=n;i++){
		a[i].x=lower_bound(b+1,b+bn+1,a[i].x)-b;
		a[i].d=lower_bound(b+1,b+bn+1,a[i].d)-b;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++){
		int tmp=Ask(a[i].x+1);
		if(!tmp){
			add(n+1,i);
		}
		else{
			add(tmp,i);
		}
		Add(a[i].d,i);
	}
	dfs(n+1);
	printf("%lld\n",dp[n+1]);
	return 0;
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef long long int ll;

using namespace std;

int t[100001];
int main() {
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  int cnt = 0;
  FOR(i, 1, N) {
    if (S[i - 1] == 'A' && S[i] == 'C') cnt++;
    t[i] = cnt;
  }
  REP(i, Q) {
    int l, r;
    cin >> l >> r;
    cout << t[r - 1] - t[l - 1] << endl;
  }
}

Measured memory_bytes: 1408
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

ll toInt(string s){
    ll ret=0;
    rep(i,s.size()){
        ret*=10;
        ret+=s[i]-'0';
    }
    return ret;
}

bool solve(){
    char a,b;cin>>a>>b;
    string A,B;
    rep(i,b-'0')A.push_back(a);
    rep(i,a-'0')B.push_back(b);
    cout<<max(toInt(A),toInt(B))<<endl;
    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 256
n = int(input())

lista = [int(i) for i in input().split()]

res = []
for i,v in enumerate(lista):
    res.append((i,v))


res.sort(key= lambda x: x[1])

for i in res[:-1]:
    print(i[0]+1, end=' ')
    
print(res[-1][0]+1)

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

int main() {
  int width, height, N;
  std::cin >> width >> height >> N;
  std::vector<std::vector<int>> data(height,std::vector<int>(width));
  for (int i=0; i<N; i++) {
    int temp_x,temp_y,flag;
    std::cin >> temp_x >> temp_y >> flag;
    if (flag == 1) {
      for (int y = 0; y < height; y++) {
        for (int x = 0; x < temp_x; x++) {
          data.at(y).at(x) = 1;
        }
      }
    }
    else if (flag == 2) {
      for (int y = 0; y < height; y++) {
        for (int x = temp_x; x < width; x++) {
          data.at(y).at(x) = 1;
        }
      }
    }
    else if (flag == 3) {
      for (int y = 0; y < temp_y; y++) {
        for (int x = 0; x < width; x++) {
          data.at(y).at(x) = 1;
        }
      }
    }
    else if (flag == 4) {
      for (int y = temp_y; y < height; y++) {
        for (int x = 0; x < width; x++) {
          data.at(y).at(x) = 1;
        }
      }
    }
  }
  int sum = 0;
  for (int y=0; y < height; y++) {
    for (int x=0; x < width; x++) {
      if (data.at(y).at(x) == 0) {
        sum++;
      }
    }
  }
  std::cout << sum << std::endl;
}
      


Measured memory_bytes: 256