akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	//ios::sync_with_stdio(false);
	ll N,A,B;
	while(cin>>N>>A>>B) {
		VI H(N);
		REP(i, N) cin>>H[i];
		ll lo = 0, hi = 1LL<<30;
		while(lo+1<hi) {
			ll mid = (lo+hi)/2;
			ll ca = 0;
			REP(i, N) {
				ll b = H[i] - mid*B;
				if(b>0) {
					ll diff = A-B;
					ca += (b+diff-1)/diff;
				}
			}
			if(ca<=mid) hi=mid; else lo=mid;
		}
		
		cout<<hi<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1024
int main(){
int a,b;
    scanf("%d %d",&a,&b);
    if(a == b){
    printf("a == b\n");
    }
    else if(a < b){
    printf("a < b\n");
    }
    else if(a > b){
    printf("a > b\n");
    }
    return 0;
}



Measured memory_bytes: 1972
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;
extern crate num_bigint; // 0.2.2
extern crate num_traits; // 0.2.8
use num_bigint::BigInt;
use num_traits::Pow;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use libm::*;
use std::cmp::*;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::*;
use std::ops::Range;
use std::str::FromStr;
use superslice::*;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//abc176-B
// #[fastout]
fn main() {
    input![n: String];
    // let mut n: String = String::new("abc");
    const RADIX: u32 = 10;
    let mut summation = 0;

    for c in n.chars() {
        summation += c.to_digit(RADIX).unwrap();
    }

    // eprintln!("{}", summation);
    if summation % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
    // eprintln!("{:#015b}", ans);
    // println!("{}", ans);
}

// use lazy_static::lazy_static;
// use std::sync::Mutex;

// lazy_static! {
//     static ref VALUES: Mutex<Vec<i32>> = Mutex::default();
// }

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);

// -100000000
//  1000000000


Measured memory_bytes: 2436
#include<iostream>
#include <vector>
#include<algorithm>
 
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<long> x(n+1);
    for(int i = 1; i <=n; i++){
        cin >> x[i];
    }
    vector<long> y = x;
    sort(y.begin()+1, y.end());
 
    for(int i = 1; i <=n; i++) {
        if (x[i] <= y[n / 2]) cout << y[n / 2 + 1] << endl;
        else cout << y[n / 2] << endl;
    }
    return 0;
}

Measured memory_bytes: 5376
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 2e5 + 10 , P = 1e9 + 7;
inline void pp(int &x,int d) {if((x+=d)>=P)x-=P;}
int n , par[N];
vi g[N];
struct Dp{
  int a[3];
  Dp() {memset(a,0,sizeof(a));}
};
vector<Dp> dp[N];

int main(){
  scanf("%d",&n);
  rep(i,1,n+1) scanf("%d",par+i),g[par[i]].pb(i);
  int inv2 = P - P / 2;
  Dp uni;uni.a[0]=uni.a[1]=inv2;
  per(i,0,n+1) {
    if(sz(g[i])) {
      int longest = 0;
      per(j,1,sz(g[i])) {
        auto&x=dp[g[i][j-1]],&y=dp[g[i][j]];
        longest = max(longest , sz(y));
        if(sz(x) < sz(y))
          swap(x , y);
        auto merge = [&](Dp&x,Dp y) {
          Dp r;
          rep(i,0,3) rep(j,0,3)
            pp(r.a[min(i+j,2)],ll(x.a[i])*y.a[j]%P);
          x=r;
        };
        rep(i,0,sz(y)) merge(x[sz(x)-(sz(y)-i)],y[i]);
        y.clear();
      }
      swap(dp[i],dp[g[i][0]]);
      rep(j,0,longest) {
        Dp&f=dp[i][sz(dp[i])-1-j];
        pp(f.a[0],f.a[2]);
        f.a[2]=0;
      }
    }
    dp[i].pb(uni);
  }
  int ans = 0;
  for(auto e : dp[0]) pp(ans,e.a[1]);
  rep(i,0,n+1) pp(ans,ans);
  printf("%d\n",ans);
  return 0;
}


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

int main(){
	int a,b;
	int s[5002],t[5002];
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",&s[i]);
	}
	for(int i=0;i<b;i++){
		scanf("%d",&t[i]);
	}

	int ret=0;
	for(int i=0;i<b-ret;i++){
		int p=0,q=i;
		int cnt=0;
		while(1){
			if(s[p]==t[q]){
				cnt++;
				p++;
				q++;
			}
			else {
				p++;
			}
			if(p==a)break;
		}
		ret=max(ret,cnt);
	}

	printf("%d\n",ret);
}

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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    const int mod = 1000000007;
    int N, M;
    cin >> N >> M;

    vector<int> broken(N+1), dp(N+1);
    REP(i, M) {
        int a;
        cin >> a;
        broken[a] = 1;
    }
  
    dp[0] = 1;
    for (int i=1; i<=N; ++i) {
        if (broken[i]) {
            continue;
        } else if (i == 1) {
            dp[i] = dp[0];
        } else {
            dp[i] = (dp[i-1] + dp[i-2]) % mod;
        }
    }
    print(dp[N]);

}

signed main() {
    solve();
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
using namespace std;
typedef  long long ll;
const int maxn=1e6+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;


int main()
{
    int n;
    cin>>n;
    int ac=0;
    int wa=0;
    int tle=0;
    int re=0;
    string s;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        if(s=="AC") ac++;
        else if(s=="WA") wa++;
        else if(s=="TLE") tle++;
        else if(s=="RE") re++;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",ac,wa,tle,re);
    return 0;
}


Measured memory_bytes: 3684
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
ans = 0
for ws0 in s:
    point = 0
    for ws1 in s:
        if ws0 == ws1:
            point += 1
    for wt in t:
        if ws0 == wt:
            point -= 1
    ans = max(ans, point)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std ; 
#define ll long long
#define flp(i ,a ,b) for(int  i = a ; i<b ; i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define blp(i, a , b) for(int  i = a ; i>=b ; i--)
#define lol 1000000007

 
long long binpow(long long a, long long b, long long m) {
	a %= m;
	long long res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}


int main()
{	

	int h  , w ; 
	cin>>h>>w  ; 
	char a[h][w] ; 
	flp(i,0,h)
	{
		flp(j,0,w)
		{
			cin>>a[i][j] ; 
		}
	}

	int dp[h][w] ; 
	dp[0][0] = 1 ; 
	flp(i,1,w)
	{
		if(a[0][i]!='#')
		{
			dp[0][i] = dp[0][i-1] ; 
		}
		else
		{
			dp[0][i] = 0 ; 
		}
	}
	flp(i,1,h)
	{
		if(a[i][0]!='#')
		{
			dp[i][0] = dp[i-1][0] ; 
		}
		else
		{
			dp[i][0] = 0 ; 
		}

	}
	flp(i,1 , h)
	{
		flp(j,1,w)
		{
			if(a[i][j]!='#')
			{
				dp[i][j]=dp[i-1][j] + dp[i][j-1] ;
			}
			else
			{
				dp[i][j] = 0 ; 
			}
			dp[i][j] = dp[i][j]%lol ; 
		}
	}
	cout<<dp[h-1][w-1]<<"\n";
	

}

Measured memory_bytes: 5120
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <time.h>

#define mst(a,b)memset(a, b, sizeof(a))
#define repi(a,b)for(ll i = a; i < b; i++)
#define repj(a,b)for(ll j = a; j < b; j++)
#define pii pair<int,int>
#define print_time()cout<<clock()/CLOCKS_PER_SEC<<" s"<<endl;

#ifdef LOCAL
#define fre()freopen("in.txt","r",stdin)
#endif
#ifndef LOCAL
#define fre()
#endif

//static int x = []() {
//	std::ios::sync_with_stdio(false);
//	std::cin.tie(NULL);
//	return 0;
//}();

#define FASTIO
#ifdef FASTIO
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//#define scanf abcabc
//#define printf abcabc
#endif
//#ifndef FASTIO
//#define cin abcabc
//#define cout abcabc
//#endif

typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

using namespace std;


ll a[100010], n, d[100010];
int main() {
	IOS;
	cin >> n;
	repi(1, n + 1)cin >> a[i];
	repi(1, n - 1)d[i] = (a[i + 1] - a[i]) * 2;
	ll tmp = 2 * (a[n] - a[1]);
	repi(2, n - 1) {
		tmp = tmp - d[i];
		i++;
	}
	ll ans = tmp + 2 * a[n - 1] >> 1;
	ll x = a[n] * 2 - ans;
	cout << x << " ";
	repi(2, n) {
		x = a[i - 1] * 2 - x;
		cout << x << " ";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
int main(void)
{
	int a[5],b[5];
	int i;
	int sum[5];
	int max;
	char banmax,ban[5]={'A','B','C','D','E'};
	
	while(scanf("%d %d",&a[0],&b[0])!=EOF){

		if(a[0] == 0 && b[0] == 0)	break;
		sum[0]=a[0]+b[0];
		max=sum[0];
		banmax='A';

		for(i=1;i<5;i++){
			scanf("%d %d",&a[i],&b[i]);
			sum[i]=a[i]+b[i];
		}
		for(i=0;i<5;i++){
			if(max<sum[i]){
				max=sum[i];
				banmax=ban[i];
			}
		}
		printf("%c %d\n",banmax,max);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <cstdint>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); i++)

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

const int N = 100000;
pii mem[N];
vector<int> tree[N + 1];
int max_color = 0;

void dfs(pii now) {
  int next_color = 1;
  for (auto child : tree[now.first]) {
    if (next_color == now.second)
      next_color += 1;
    max_color = max(max_color, next_color);
    mem[child].second = next_color;
    dfs(mem[child]);
    next_color += 1;
  }
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b)
      swap(a, b);
    mem[i] = {b, 0};
    tree[a].push_back(i);
  }
  dfs({1, 0});
  cout << max_color << endl;
  for (int i = 0; i < n - 1; i++) {
    cout << mem[i].second << endl;
  }
}


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

int main(){
	int N;
	cin >> N;
	vector<int> L(N);
	rep(i, N) cin >> L[i];
	
	sort(L.begin(), L.end());
	
	int64_t count = 0;
	for(int i = 0; i < N-2; ++i){
		for(int j = i + 1; j < N - 1; ++j){
			int th = L[i] + L[j];
			auto itr = lower_bound(L.begin(), L.end(), th);
			count += (int64_t)(itr - L.begin() - (j + 1));
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
pair<int,int>path[3];
int xu[3]={0,1,2},cnt[4];
int main()
{
	for(int i=0;i<3;i++)
	{
		cin>>path[i].first>>path[i].second;
		path[i].first--;
		path[i].second--;
		cnt[path[i].first]++;
		cnt[path[i].second]++;
	}
	sort(cnt,cnt+4);
	for(int i=0;i<4;i++)
	{
		if(cnt[i]!=i/2+1)
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long

#define _CRT_SECURE_NO_DEPRECATE
const int N = 33003;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;

int main(){
string s1,s2,s3;
cin>>s1>>s2>>s3;
int x=0,y=0,z=0;
int a=1;
while(1)
{
if(a==1)
{


	if(x>=s1.size())
	{
		cout<<"A";
		return 0;
	}
	
	a=(s1[x]-'a')+1;
	x++;
}
else if(a==2)
{

	if(y>=s2.size())
	{
		cout<<"B";
		return 0;
	}
	
	a=(s2[y]-'a')+1;
	y++;
}
	else
	{
		//z++;
		if(s3.size()<=z)
		{
			cout<<"C";
			return 0;
		}
	
		a=(s3[z]-'a')+1;
			z++;
	}
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>s;
    rep(i,Size(s))ans+=(s[i]-'0');
    ans=max(ans,(ll)((s[0]-'0')-1+9*(Size(s)-1)));
    Cout(ans);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vi> graph;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int a, b, c;
	cin >> a >> b >> c;
	cout << min(c, b / a) << "\n";
	return 0;
}

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
template <typename T>
constexpr T GCD(T a, T b) {
  if(!b) return a;
  while(b){
    swap(a, b);
    b %= a;
  }
  return a;
}
template <typename T>
constexpr T LCM(T a, T b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  using boost::multiprecision::cpp_int;
  using boost::multiprecision::integer_modulus;
  ll n;
  cin >> n;
  cpp_int a, g, c = 1, ans = 0;
  rep(i, n){
    cin >> a;
    g = GCD(c, a);
    ans *= integer_modulus(a / g, MOD);
    ans += integer_modulus(c / g, MOD);
    c /= g;
    c *= a;
  }
  print(ans%MOD);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int MAX = 2e6;
vll L(MAX / 2 + 2), R(MAX / 2 + 2);
ll cnt = 0;
inline void merge(vll &a, ll left, ll mid, ll right) {
	ll n1 = mid - left;
	ll n2 = right - mid;
	rep(i, 0, n1) L[i] = a[left + i];
	rep(i, 0, n2) R[i] = a[mid + i];
	L[n1] = R[n2] = 1e9;
	ll i = 0, j = 0;
	rep(k, left, right) {
		if(L[i] <= R[j]) {
			a[k] = L[i];
			++i;
		} else {
			a[k] = R[j];
			++j;
			cnt = cnt + n1 - i;
		}
	}
}
inline void mergeSort(vll &a, ll left, ll right) {
	if(left + 1 < right) {
		ll mid = (left + right) / 2;
		mergeSort(a, left, mid);
		mergeSort(a, mid, right);
		merge(a, left, mid, right);
	}
}
int main() {
	int n; cin >> n;
	vll a(n); rep(i, 0, n) cin >> a[i];
	mergeSort(a, 0, n);
	P(cnt);
	return 0;
}

Measured memory_bytes: 19864
#include <cstdio>
#include <algorithm>
using namespace std;

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define iter_r(i, n) for (int i = n; i >= 1; --i)
#define forw(i, a, b) for (int i = a; i <= b; ++i)

typedef long long i64;

#define NR 5010

int n, m, a[NR], b[NR][210], stk[210][NR], top[210];
i64 d[NR], c[NR], ans;

int main() {
	scanf("%d%d", &n, &m);
	iter(i, n - 1) scanf("%d", &a[i]);
	iter(i, n) iter(j, m) scanf("%d", &b[i][j]);

	iter(i, m) stk[0][i] = n + 1;
	iter_r(i, n) {
		iter(j, n) d[j] = 0;
		iter(j, m) {
			int *s = stk[j], &k = top[j];
			for (; k && b[s[k]][j] < b[i][j]; --k) {
				d[s[k]] -= b[s[k]][j];
				d[s[k - 1]] += b[s[k]][j];
				//inc(RT, s[k], s[k - 1] - 1, -b[s[k]][j]);
			}
			s[++k] = i;
			d[s[k]] += b[i][j];
			d[s[k - 1]] -= b[i][j];
			//inc(RT, s[k], s[k - 1] - 1, b[i][j]);
		}
		if (i < n) d[i + 1] -= a[i];
		//inc(RT, i + 1, n, -a[i]);
		i64 cur = 0;
		forw(j, i, n) {
			cur += d[j], c[j] += cur;
		//	printf("l=%d r=%d a=%lld\n", i, j, c[j]);
			ans = max(ans, c[j]);
		}
	}

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

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

using namespace std;

const long long MAXN = 1e7 + 10;
const long long MOD = 998244353;

vector<long long> fact(MAXN);

long long gcde(long long a, long long b, long long *x, long long *y)
{
  if(a == 0)
  {
    *x = 0, *y = 1;
    return b;
  }
  long long x1, y1;
  long long gcd = gcde(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}

long long inv(long long a)
{
  long long x, y;
  long long g = gcde(a, MOD, &x, &y);
  assert(g == 1);
  long long res = (x % MOD + MOD) % MOD;
  return res;
}

void evalf()
{
  fact[0] = 1;
  for(int i = 1; i < MAXN; i++)
  {
    fact[i] = (fact[i - 1] * i) % MOD;
  }
}

long long binary_expo(long long a, long long n)
{
  if(n == 0) return 1;
  if(n == 1) return a;
  long long p = binary_expo(a, n / 2);
  (p *= p) %= MOD;
  if(n & 1) (p *= a) %= MOD;
  return p;
}

long long ncr(long long n, long long r)
{
  long long ans = (fact[n] * inv(fact[n - r])) % MOD;
  (ans *= inv(fact[r])) %= MOD;
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  evalf();
  long long n;
  cin >> n;
  long long ans = 1, nans = 0;
  for(int i = (n / 2) + 1; i <= n; i++)
  {
    long long ts = binary_expo(2, n - i);
    (ts *= ncr(n, i)) %= MOD;
    (nans += ts) %= MOD;
  }
  for(int i = 0; i < n; i++)
  {
    (ans *= 3) %= MOD;
  }
  (nans *= 2) %= MOD;
  ans = (((ans - nans) % MOD) + MOD) % MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 78336
def main():
    N, K = map(int, input().split())

    res = 0

    for i in range(1, N + 1):
        tmp_prob = 1 / N
        tmp_val = i
        while tmp_val < K:
            tmp_val *= 2
            tmp_prob /= 2

        res += tmp_prob

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39152
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s;
    int k;
    cin>>k>>s;
    int n=s.size();
    if(n>k){
        rep(i,k) cout<<s[i];
        cout<<"...";
    }
    else cout<<s;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
vector<int> A;
vector<int> B;
//=============================
void input()
{
    cin>>N>>M>>K;
}
//=============================
void func(){}
//=============================
void solve()
{
    int a,b,c;
    a=N;b=M;c=K;
    int hairu = a-b;

    cout<<max(0LL,c-hairu)<<endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int m;
    cin>>m;
    string s;
    cin>>s;
    vector<ll> x(10);
    int n = s.size();
    int top = s[0]-'0';
    rep(i,n){
        rep(j,10)(x[j]*=10)%=mod;
        x[s[i]-'0']++;
    }
    vector<ll> p(10);
    iota(p.begin(),p.end(),0);
    do{
        if(p[top]==0&&s.size()>=2)continue;
        ll res = 0;
        rep(j,10)res += p[j]*x[j]%mod;
        if(res%mod==m){
            rep(i,n){
                int x = s[i]-'0';
                cout<<p[x];
            }
            cout<<endl;
            return 0;
        }
    }while(next_permutation(p.begin(), p.end()));
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3340
import java.util.Scanner;

public class Main {

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

	    int n=gi();
	    int m=gi();
	    long[] a=new long[n];
	    long[] b=new long[n];
	    long[] c=new long[m];
	    long[] d=new long[m];

	    for (int i=0; i<n;i++) {
	    	a[i]=gl();
	    	b[i]=gl();
	    }
	    for (int i=0; i<m;i++) {
	    	c[i]=gl();
	    	d[i]=gl();
	    }

	    for (int i=0; i<n;i++) {
	    	long min=Long.MAX_VALUE;
	    	long minind = 0;
	    	for (int j=0; j<m;j++) {
	    		long man = Math.abs(a[i]-c[j]) + Math.abs(b[i]-d[j]);
	    	    if (min > man) {
	    	    	min = man;
	    	    	minind=j+1;
	    	    }
	    	}
	    	System.out.println(minind);
	    }


        //System.out.println(f(n));
//        if (a<b) {
//        	System.out.print(Math.max(b-a-w, 0));
//        }else {
//        	System.out.print(Math.max(a-b-w, 0));
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

typedef long long LL;

const int N=18,M=262144,mod=1000000007;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

int n,a[M+9];

void into(){
  scanf("%d",&n);
  for (int i=1<<n-1;i<1<<n;++i){
	scanf("%d",&a[i]);
    a[i]+=(1<<n-1)-1;
  }
}

int now[M+9];

void Dfs_now0(int k,int v){
  if (k>=1<<n-1){
	for (smul(v,k=a[k]);k;smul(v,k>>=1)) sadd(now[k],v);
    return;
  }
  Dfs_now0(k<<1,mul(v,k<<1));
  Dfs_now0(k<<1|1,mul(v,k<<1|1));
}

int Dfs_ans(int k,int v){
  if (k>=1<<n-1){
	int res=0,t=0;
	for (smul(v,k=a[k]);k;smul(v,k>>=1)) sadd(res,mul(now[k^1],mul(v,k>>1)));
	return res;
  }
  return add(Dfs_ans(k<<1,mul(v,k<<1)),Dfs_ans(k<<1|1,mul(v,k<<1|1)));
}

void Dfs_now1(int k){
  if (k>=1<<n-1){
	for (k=a[k];k;k>>=1) now[k]=0;
    return;
  }
  Dfs_now1(k<<1);
  Dfs_now1(k<<1|1);
}

int ans;

void Get_ans(){
  for (int i=1;i<1<<n-1;++i){
	Dfs_now0(i<<1,mul(i,i<<1));
	sadd(ans,Dfs_ans(i<<1|1,i<<1|1));
	Dfs_now1(i<<1);
  }
}

void work(){
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 5356
import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {

    var i = 1
    while(true){
      val in = StdIn.readInt()
      if(in == 0){
        return
      } else {
        println("Case " + i + ": " + in)
      }
      i += 1
    }
 }
}

Measured memory_bytes: 50680
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt(), b = scanner.nextInt(), c = scanner.nextInt(), count = 0;
		for (int i = a; i <= b; i++)
			if (c % i == 0)
				count++;

		System.out.println(count);
	}
}

Measured memory_bytes: 26232
import sys
readline = sys.stdin.readline

inf = 10**18+3
def merge(d1a, d2a, d1b, d2b):
    la = len(d1a)
    lb = len(d1b)
    k = la+lb
    res1 = [inf]*k
    res2 = [inf]*k
    for i in range(la):
        for j in range(lb):
            res1[i+j] = min(res1[i+j], d1a[i]+d1b[j], d1a[i]+d2b[j], d2a[i]+d1b[j])
            res2[i+j] = min(res2[i+j], d2a[i]+d2b[j])
    
    for j in range(lb):
        if d1b[j] < 0 or d2b[j] < inf:
            for i in range(la):
                res1[i+j+1] = min(res1[i+j+1], d1a[i])
                res2[i+j+1] = min(res2[i+j+1], d2a[i])
    return res1, res2

def parorder(Edge, p):
    N = len(Edge)
    par = [0]*N
    par[p] = -1
    stack = [p]
    order = []
    visited = set([p])
    ast = stack.append
    apo = order.append
    while stack:
        vn = stack.pop()
        apo(vn)
        for vf in Edge[vn]:
            if vf in visited:
                continue
            visited.add(vf)
            par[vf] = vn
            ast(vf)
    return par, order

def getcld(p):
    res = [[] for _ in range(len(p))]
    for i, v in enumerate(p[1:], 1):
        res[v].append(i)
    return res


N = int(readline())
A = list(map(int, readline().split()))
Edge = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)

P, L = parorder(Edge, 0)
#C = getcld(P)

dp1 = [[A[i] if A[i] < 0 else inf] for i in range(N)]
dp2 = [[A[i] if A[i] > 0 else inf] for i in range(N)]

for l in L[:0:-1]:
    p = P[l]
    dp1[p], dp2[p] = merge(dp1[p], dp2[p], dp1[l], dp2[l])
    
    
ans = N-1
for i in range(N):
    if dp1[0][i] < 0 or dp2[0][i] < inf:
        ans = i
        break
print(ans)


Measured memory_bytes: 207748
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, A, B;
  cin >> N >> A >> B;
  const int64_t AplusB = A + B;
  const int64_t count = N / AplusB;
  const int64_t residual = N % AplusB;
  const int64_t a = min(A, residual);
  // const int64_t b = residual - a;
  cout << A * count + a << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn = 300300;
char s[maxn];
int p[maxn];
int main(){
    int n;
    cin >> n;
    scanf("%s", s + 1);
    for(int e = 1; e <= n; e++) p[e] = p[e-1] + (s[e] == 'E');
    int r = n;
    for(int e = 1; e <= n; e++){
        if(true){
            int u = e - 1 - p[e - 1];
            u += p[n] - p[e];
            r = min(r, u);
        } else {
            int u = p[e - 1];
            u += (n - e) - (p[n] - p[e]);
            r = min(r, u);
        }
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> r(n);
	for (int i = 0; i < n; i++) {
		cin >> r.at(i);
	}
	int min = r.at(0);
	int ans = r.at(1) - min;
	for (int i = 1; i < n - 1; i++) {
		if (r.at(i) < min) min = r.at(i);
		int profit = r.at(i + 1) - min;
		if (profit > ans) ans = profit;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3508
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;


int main(){
    int a, b, flag = 1;
    cin >> a >> b;
    for (int i = 1; i <= 1000; i++){
        if (((int)(i*(0.08)) == a)&&((int)(i*(0.1)) == b)){
            cout << i;
            flag = 0;
            break;
        }
    }
    if (flag) cout << -1;
    return 0;
}



Measured memory_bytes: 256
def main():
    sx, sy, tx, ty = map(int, input().split())
    move1 = []
    move2 = []
    for i in range(abs(sx-tx)):
        if sx > tx:
            move1.append("L")
        else:
            move1.append("R")

    for j in range(abs(sy-ty)):
        if sy > ty:
            move2.append("D")
        else:
            move2.append("U")

    move3 = [reverse(m) for m in move1]
    move4 = [reverse(m) for m in move2]
    
    move5 = [reverse(move2[0])] + move1
    move5.append(move1[-1])
    
    move6 = [move2[0]] + move2
    move6.append(reverse(move1[0]))

    move7 = [reverse(m) for m in move5]
    move8 = [reverse(m) for m in move6]

    move = move1 + move2 + move3 + move4 + move5 + move6 + move7 + move8
    move_str = ""

    for m in move:
        move_str += m
    print(move_str)    


def reverse(m):
    if m == "D":
        return "U"
    elif m == "U":
        return "D"
    elif m == "R":
        return "L"
    else:
        return "R"

    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include <iostream>
using namespace std;
int main()
{
    while(1)
    {
        int n;
        cin>>n;if(!n)return 0;
        int pm[10000],pe[10000],pj[10000],sc[10000]={0};
        for(int i=0;i<n;++i){
            cin>>pm[i]>>pe[i]>>pj[i];
        	if((pm[i]+pe[i]+pj[i])/3>=50&(pm[i]>=80|pe[i]>=80))
                sc[i]=1;
            if((pm[i]+pe[i]+pj[i])/3>=70)
                sc[i]=1;
            if((pm[i]+pe[i]+pj[i])/3>=80)
                sc[i]=2;
            if((pm[i]+pe[i])/2>=90)
                sc[i]=2;
            if(pm[i]==100|pe[i]==100|pj[i]==100)
                sc[i]=2;
            if(!sc[i])cout<<'C'<<endl;
            if(sc[i]==1)cout<<'B'<<endl;
            if(sc[i]==2)cout<<'A'<<endl;
        }
    }
}

Measured memory_bytes: 1212
#include "stdio.h"

int main(){
    int A,B,K,i=0;
    scanf("%d%d%d",&A,&B,&K);
    if(B-A+1<2*K){
        for(i=A;i<=B;i++){
            printf("%d\n",i);
        }
    }
    else{
        
      for(i=0;i<K;i++){
            printf("%d\n",A);
            A++;
        }
        B-=K;
        for(i=0;i<K;i++){
            B++;
            printf("%d\n",B);
        }
    }
    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define int ll
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
signed main(){
    int k,s;
    cin>>k>>s;
    vi dp(10000,0);
    vb check(10000,true);
    rep(i,k+1)rep(j,k+1){
        if(i==j&&check[i]){dp[i+j]++;check[i]=false;}
        else if(i!=j)dp[i+j]++;
    }
    int ans=0;
    rep(i,k+1)if(s-i>=0)ans+=dp[s-i];
    cout<<ans<<endl;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**7)
input=sys.stdin.readline
n,m=map(int,input().split())
s=set()
edge=[[] for _ in range(n)]
edgerev=[[] for _ in range(n)]
for _ in range(n+m-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    edge[a].append(b)
    edgerev[b].append(a)
    s.add(b)
for i in range(n):
    if i not in s:
        root=i
        break
visited=[False]*n
to=[] #topological order
def dfs(root):
    if visited[root]:
        return
    visited[root]=True
    for i in edge[root]:
        dfs(i)
    to.append(root)
dfs(root)
to=to[::-1]
#print(to)
result=[0]*n
for i in range(n):
    result[to[i]]=i #頂点の順番
#print(result)
#print(edgerev)
for i in range(n):
    if not edgerev[i]:
        print(0)
        continue
    order=-1
    for j in edgerev[i]:
        if order<result[j]:
            ans=j
            order=result[j]
    print(ans+1)

Measured memory_bytes: 120612
def main():
  N = int(input())
  A = [0]
  A.extend(list(map(int, input().split())))
  A.append(0)
  ans_def = 0
  for i in range(1, N+2):
    ans_def += abs(A[i]-A[i-1])
  for i in range(1, N+1):
    print(ans_def-abs(A[i-1]-A[i])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))
if __name__ == "__main__":
  main()

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

using namespace std;
int n, a, b;
int cnt[108000];
int main(){
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a >> b;
		cnt[a]++;
		cnt[b+1]--;
	}
	for(int i = 1;i < 108000;i++){
		cnt[i] += cnt[i-1];
	}
	for(int i = 107000;i >= 0;i--){
		if(cnt[i+1] >= i){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


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

int main() {
	int n;
	scanf("%d", &n);
	int *a = malloc((n+1) * sizeof(int));
	int result = 0;
	for(int i=1; i<=n; i++){
		scanf("%d", &a[i]);
	}
	for(int i=1; i<=n; i++){
		if(a[i] == i) continue;
		int j = a[i];
		if(j && (a[j]==i)){
			result+=1;
			a[i] = 0;
			a[j] = 0;
		}
	}
	printf("%d", result);
}

Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

H, W = [int(_) for _ in input().split()]
N = int(input())
A = [int(_) for _ in input().split()]
ai = 0
for i in range(H):
    ans = []
    for j in range(W):
        if A[ai] <= 0: ai += 1
        ans.append(ai + 1)
        A[ai]-=1
    if i %2==1:
        print(*reversed(ans))
    else:
        print(*ans)


Measured memory_bytes: 3700
#include <stdio.h>
int main(void){
    int n, k;
    double p[200000+5];
    scanf("%d %d", &n, &k);
    for(int i=0; i<n; i++)scanf("%lf", &p[i]);
    for(int i=0; i<n; i++)p[i]=(double)(p[i]+1)/2;
    
    double s[200000+5];    // 累積和
    s[0]=p[0];
    for(int i=1; i<n; i++)s[i]=s[i-1]+p[i];
    
    float ans=s[k-1];
    for(int i=0; i<n-k; i++){
        if(ans<s[i+k]-s[i]){
            ans=s[i+k]-s[i]; 
        }
    }
    
    printf("%f\n", ans);
    return 0;
}


Measured memory_bytes: 4868
n=gets.chomp.to_i
h = gets.split(" ").map(&:to_i)
result = true
i = 0
while(i < n - 1) do 
  if h[i + 1] > h[i] 
    h[i + 1] -= 1 
  elsif h[i + 1] != h[i]
    if (h[i + 1] < h[i] && h[i + 1] - 1 < h[i])
      result = false
      break
    end
  end
  i+=1
end

a = result == true ? "Yes" : "No"
puts a

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

const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> box(N, 1);
    vector<bool> is_red(N, false);
    is_red[0] = true;
    for(int i=0;i<M;i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        if(is_red[x]){
            if(box[x] == 1) is_red[x] = false;
            is_red[y] = true;
        }
        box[x]--;
        box[y]++;
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        if(is_red[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>


int main()
{
	char S[3] = { 'S', 'S', 'S' };
	char T[3] = { 'S', 'S', 'S' };

	std::cin >> S[0] >> S[1] >> S[2];
	std::cin >> T[0] >> T[1] >> T[2];

	int matchNum = 0;
	for (int i = 0; i != 3; ++i)
	{
		if (S[i] == T[i]) matchNum++;
	}

	std::cout << matchNum << std::endl;

	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> mp(n, 0);
    rep(i, k) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            a--;
            mp[a]++;
        }
    }
    int ans = 0;
    for (auto kv : mp) {
        if (kv == 0) ans++;
    }
    cout << ans << endl;
}

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

struct Robot {
    int64_t X, L;
};

int main() {
    int64_t N;
    cin >> N;
    vector<Robot> robots(N);
    for (Robot& r : robots) {
        cin >> r.X >> r.L;
    }

    sort(robots.begin(), robots.end(), [](Robot& lhs, Robot& rhs){
        int64_t lhs_l = lhs.X - lhs.L;
        int64_t lhs_r = lhs.X + lhs.L;
        int64_t rhs_l = rhs.X - rhs.L;
        int64_t rhs_r = rhs.X + rhs.L;
        return (lhs_r != rhs_r ? lhs_r < rhs_r : lhs_l < rhs_l);
    });

    int64_t limit = INT_MIN;
    int64_t ans = 0;
    for (const Robot& r : robots) {
        if (r.X - r.L >= limit) {
            ans++;
            limit = r.X + r.L;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
int main()
{
    int n,a[102],b[102],c[102],m[102],e[102];
    int maxn;
    while(~scanf("%d",&n))
    {
        memset(c,0,102);
        memset(m,0,102);
        maxn=0;c[0]=0;m[n+1]=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            c[i]=c[i-1]+a[i];
           // printf("c[i]=%d ",c[i]);
        }
        for(int j=1;j<=n;j++)
        {
            scanf("%d",&b[j]);
        }
       for(int j=n;j>=1;j--)
       {
           m[j]=m[j+1]+b[j];
         //  printf("m[%d]=%d",j,m[j]);
       }
       //printf("\n");
        for(int k=1;k<=n;k++)
        {
            if(maxn<c[k]+m[k])
                maxn=c[k]+m[k];
        }
        printf("%d\n",maxn);
    }
    return 0;
}


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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;
string str[100];
string check[100];
int clear[100] = {0};
int t[100];
int counter = 0;
int characters = 0;

int main() {
    int n, h; cin >> n >> h;
    REP(i, n){
        cin >> str[i] >> t[i];
        check[i] = str[i];
        transform(ALL(check[i]), check[i].begin(), ::tolower);
    }
    REP(i, n){
        while(clear[i] < str[i].length()){
            cout << "? " << str[i] << endl << flush;
            char c[2];
            scanf("%s", c);
            if(c[0] == check[i][clear[i]]){
                str[i][clear[i]] = '_';
                clear[i]++;
                characters++;
            } else {
                t[i]--;
                if(t[i] < 0){
                    h--;
                    if(h <= 0){
                        printf("! Game Over\n"); fflush(stdout);
                        return 0;
                    }
                    clear[i] = str[i].length();
                }
            }
            counter++;
        }
    }
    double success_type_rate = double(characters) / double(counter) * 1000;
    success_type_rate = floor(success_type_rate);
    success_type_rate /= 10;
    printf("! Game Clear %.1lf\n", success_type_rate); fflush(stdout);
    return 0;
}

Measured memory_bytes: 1300
/*input
2 3
1 2 3
0 1 1
*/

#include <bits/stdc++.h>
using namespace std;
int grid[505][505];

int main()
{
	int a, b;
	cin >> a >> b;
	if((a&1)==0 || (b&1)==0)
        printf("No\n"), exit(0);
    printf("Yes\n");

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define REPo(i, n) FORe((i), 1, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int k;
  cin >> k;
  ll ans = 0;
  REPo(i, k) REPo(j, k) REPo(h, k) ans += gcd(i, gcd(j, h));
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3640
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=[-_ for _ in a]
import heapq
heapq.heapify(a)
for i in range(m):
  temp=-heapq.heappop(a)
  heapq.heappush(a,-(temp//2))
  
print(-sum(a))

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    if (N%2==0){
        cout << 0.5 << endl;
    }
    else{
        int k= N/2;
        double ans = (double) (k+1)/N;
        cout << fixed;
        cout << setprecision(10);
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int N = Integer.parseInt(strSplit[0]);
            int D = Integer.parseInt(strSplit[1]);
            
            int ans = 0;
            for(int i=0; i<N; i++){
                String pqSplit[] = br.readLine().split(" ");
                long p = Integer.parseInt(pqSplit[0]);
                long q = Integer.parseInt(pqSplit[1]);
                
                double pq = Math.sqrt(p*p + q*q);
                
                if(pq <= D){
                    ans++;
                }
            }
            
            System.out.println(ans);
            
        }catch(Exception e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 54924
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;

    int aIdx, zIdx;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'A') {
            aIdx = i;
            break;
        }
    }
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'Z') {
            zIdx = i;
        }
    }
    cout << zIdx - aIdx + 1 << endl;
}

Measured memory_bytes: 640