akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int K;
    cin >> K;
    int ans=0;
    ll sum=0;
    rept(i,1,K+1){
        rept(j,1,K+1){
            rept(k,1,K+1){
                ans=gcd(i,j);
                ans=gcd(ans,k);
                sum+=ans;                
            }
        }
    }
    cout << sum << endl;    
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define endl        '\n'
#define hell        LLONG_MAX
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define int long long
#define sz(x) (int)x.size()
#define mp make_pair
#define fi first
#define se second
#define io ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
#define INF 1e7
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int mgx[]={2,-2,0,0,2,-2,1,1,2,-2,-1,-1,1,1,-1,-1,2,2,-2,-2};
int mgy[]={0,0,2,-2,1,1,2,-2,-1,-1,2,-2,1,-1,1,-1,2,-2,2,-2};
bool isvalid(int x,int y,int h,int w,vector<vector<char> >& graph)
{
	if(x<0||x>=h||y<0||y>=w) return false;
	else if(graph[x][y]=='#') return false;
	else return true;
}
signed main()
{
	io;
	int h,w;
	cin >> h >> w;
	vector<vector<char>> graph(h);
	int xs,ys,xe,ye;
	cin >> xs>>ys;
	cin >> xe>>ye;
	xs--;
	ys--;
	xe--;
	ye--;
	rep(i,0,h)
	{
		rep(j,0,w)
		{
			char a;
			cin >> a;
			graph[i].pb(a);
		}
	}
	int ans=-1;
	int visited[h][w];
	rep(i,0,h)
	{
		rep(j,0,w)
		{
			visited[i][j] = INT_MAX;
		}
	}
	deque<pii> q;
	visited[xs][ys] = 0;
	q.push_front(mp(xs,ys));
	while(!q.empty())
	{
		pii front = q.front();
		q.pop_front();
		int x = front.fi;
		int y = front.se;
		if(x==xe&&y==ye)
		{
			ans = visited[xe][ye];
			break;
		}
		rep(i,0,4)
		{
			int nx =x+dx[i];
			int ny=y+dy[i];
			if(isvalid(nx,ny,h,w,graph))
			{
				if(visited[nx][ny]>visited[x][y])
				{
					visited[nx][ny]=visited[x][y];
					q.push_front(mp(nx,ny));
				}
			}
		}
		rep(i,0,20)
		{
			int nx =x+mgx[i];
			int ny=y+mgy[i];
			if(isvalid(nx,ny,h,w,graph))
			{
				if(visited[nx][ny]>visited[x][y]+1)
				{
					visited[nx][ny]=visited[x][y]+1;
					q.push_back(mp(nx,ny));
				}
			}
		}

	}
	
	cout << ans <<endl;

	
}
 
	
		



Measured memory_bytes: 12560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string s,ss;
ll ar[100009];
ll br[100009];
vector<char>v;
char ch;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll n,ans,res,i,j,c=0,f=0,len1,len2;
    double a,b;
    cin>>n;
    ans=(n*(n+1))/2;
    cout<<ans-n<<endl;
   return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    long long n;
    cin>>n;
    int ans=11;
    for(long long a=1;a<=sqrt(n);a++){
        if(n%a==0){
            long long b=n/a;
            string sb=to_string(b);
            //string sa=to_string(a);
            int bs=sb.size();
            ans=min(ans,bs);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;

int main(){
    int x,ans;
    cin >> x;
    if(x%1000 == 0) ans = 0;
    else ans = 1000 - x%1000;

    cout << ans;
    return 0;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-

N = int(input())

a = []

for i in range(N):
    a.append(int(input()))

ans = 0
b_now = 1
loop = []

for i in range(N):
    b_now = a[b_now - 1]
    ans += 1
    if b_now == 2:
        print(ans)
        exit()

print(-1)

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

using namespace std;

// Header files, namespaces,
// macros as defined above
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define f first
//#define s second
#define db long double
#define pb push_back
#define sz(c) (c).size()
#define all(c) (c).begin(),(c).end()

typedef long long ll;
typedef pair <int , int> ii;
typedef pair <ii , int> iii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;
typedef vector <vii> vvii;

const ll mod = 1e9+7;
const int MAX = 1e3+5;
const db eps = 1e-13;

bool mk[MAX][MAX];
int dp[MAX][MAX];


int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    cout<<setprecision(0)<<fixed;
    int n , m;
    cin>>n>>m;

    for( int i = 1; i <= n ; i++ )
        for( int j = 1; j <= m ; j++ )
        {
            char c;cin>>c;
            if( c == '#' ) {
                mk[i][j] = true;
//                cout<<i<<" "<<j<<" "<<mk[i][j]<<"\n";
            }
        }
    dp[1][1] = 1;
    mk[1][1] = true;

    for( int i = 1; i <= n ; i++ )
        for( int j = 1; j <= m ; j++ )
            if( mk[i][j]==false )
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;

//    for( int i = 1; i <= n ; i++ ) {
//        for( int j = 1; j <= m ; j++ )
    cout<<dp[n][m]<<" ";
//            cout<<"\n";
//    }


}


Measured memory_bytes: 5248
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n,m=map(int,input().split())
a=sorted([list(map(int,input().split())) for _ in range(n)])
#print(a)
cnt,can=0,0
for i in range(n):
    if can+a[i][1]<m:
        cnt+=a[i][0]*a[i][1]
        can+=a[i][1]
    else:
        cnt+=a[i][0]*(m-can)
        break
    #print(cnt)
print(cnt)

Measured memory_bytes: 28572
s=input()
check=list(s)
n=len(s)
cntb=0
for i in check:
    if i=='B':
        cntb+=1
minus=sum([i+1 for i in range(n) if check[i]=='B' ])
plus=sum(range(n-cntb+1,n+1))
print(plus-minus)

Measured memory_bytes: 18604
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define INF 1e9
using ll = std::int64_t;

template <class T>
bool chmax(T &a, const T &b);
template <class T>
bool chmin(T &a, const T &b);
//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b);
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb);
//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str);
//素数判定
bool is_prime(std::int64_t n);
// 約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n);
// 素因数分解
std::map<std::int64_t, std::int64_t> prime_factor(std::int64_t n);

//10^9 + 7
#define yojo 1000000007
#define MAX_NUM 200001

void Main()
{
  int n, T;
  cin >> n >> T;
  vector<int> t(n);
  rep(i, n) cin >> t[i];
  
  int ans = 0;
  rep(i, n - 1){
    if (t[i + 1] - t[i] < T)
    {
      ans += t[i + 1] - t[i];
    }
    else
    {
      ans += T;
    }
    
  }

  std::cout << ans + T << std::endl;

  return;
}

int main()
{
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return true;
  }
  return false;
}

//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b)
{
  // a >= b && b != 0
  std::int64_t c;
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//最大公約数安全版
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb)
{
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0)
  {
    return -1;
  }
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str)
{
  std::vector<std::pair<char, std::int64_t>> data;
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++)
  {
    if (i == str.size())
    {
      data.push_back(make_pair(str[i - 1], count));
      break;
    }
    else if (now != str[i])
    {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return data;
}

//素数判定
bool is_prime(std::int64_t n)
{
  for (std::int64_t i = 0; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      return false;
    }
  }

  return n != 1;
}

//約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n)
{
  std::vector<std::int64_t> res;
  for (int i = 0; i < n; i++)
  {
    if (n % i == 0)
    {
      res.push_back(i);
      if (i != n / i)
        res.push_back(n / i);
    }
  }
  return res;
}

// 素因数分解
std::map<std::int64_t, std::int64_t> prime_factor(std::int64_t n)
{
  std::map<std::int64_t, std::int64_t> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      ++res[i];
      n /= i;
    }
  }

  if (n != 1)
  {
    res[n] = 1;
  }

  return res;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    string s;
    cin >> s;
    int cntRed  = 0;
    int cntBlue = 0;
    cntRed      = count(all(s), '1');
    cntBlue     = count(all(s), '0');
    cout << min(cntBlue, cntRed) * 2 << endl;

    return 0;
}


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    int h, w;
    cin >> h >> w;
    rep(i, h)
    {
        string temp;
        cin >> temp;
        cout << temp << endl;
        cout << temp << endl;
    }
    return 0;
}

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

using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "{" << p.first << ", " << p.second << "}";
    return os;
}

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

const int INF = (ll) 1e9;
const ll INFLL = (ll) 1e18 + 1;
const ll MOD = (ll) 1e9 + 7;
const double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    vector<int> v;
    rep(i,N){
        if(S[i] == 'o')v.emplace_back(i+1);
    }
    //前から見たときのやつ
    map<int, int> mae;
    int sz = v.size();
    int pre = v[0];
    int cnt = 1;
    mae[cnt] = pre;
    while(cnt < K){
        int next = *lower_bound(all(v), pre + C+1);
        cnt++;
        mae[cnt] = next;
        pre = next;
    }

    //逆から
    map<int, int> usi;
    pre = v[sz-1];
    cnt = K;
    usi[cnt] = pre;
    while(cnt > 1){
        int idx = upper_bound(all(v), pre - C - 1) - v.begin();
        int next = v[idx-1];
        cnt--;
        usi[cnt] = next;
        pre = next;
    }
    rep1(i,K+1){
        if(mae[i] == usi[i]){
            cout << mae[i] << endl;
        }
    }
}

Measured memory_bytes: 21260
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define mod 10e9+7
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  ll a,b,c;
  string s,t;
  cin >> a >> b;
  if(500*a>=b)
  cout << "Yes" << endl;
  else 
  cout <<"No"<<endl;
}
   



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val abcd = readLine()!!
    val len = abcd.length

    for (bit in 0 until (1 shl len-1)) {
        var ans = abcd[0].toString()
        var sum = abcd[0] - '0'
        for (i in 0 until len-1) {
            if (bit and (1 shl i) != 0) {
                // +
                sum += abcd[i + 1] - '0'
                ans += "+" + abcd[i + 1]
            } else {
                // -
                sum -= abcd[i + 1] - '0'
                ans += "-" + abcd[i + 1]
            }
        }
        if (sum == 7) {
            println("$ans=7")
            break
        }
    }
}

Measured memory_bytes: 31944
// B - Varied
#include <bits/stdc++.h>
using namespace std;

int main(){
	string s; cin>>s;
	for(int i=0; i<s.size(); ++i){
		for(int j=i+1; j<s.size(); ++j){
			if(s[i]==s[j]){
				puts("no");
				return 0;
			}
		}
	}
	puts("yes");
}

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


int main()
{
  int N;
  long K;
  cin >> N >> K;
  vector<long> nums(N);
  vector<int> count(40);
  for (int i = 0; i < N; i++)
  {
    cin >> nums[i];
    for (int j = 39; j >= 0; j--)
    {
      if (nums[i] & (1L << j))
      {
        count[j]++;
      }
    }
  }
  long X = 0;
  for (int j = 39; j >= 0; j--)
  {
    if ((X + (1L << j)) <= K)
    {
      if (count[j] < N - count[j])
      {
        X += (1L << j);
      }
    }
  }
  long result = 0;
  for (int i = 0; i < N; i++)
  {
    result += X ^ nums[i];
  }

  cout << result << endl;
  return 0;
}


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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="7767555555555555555555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REP2(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<pair<int, int> > vec(n);
    rep(i, n){
        int a; cin >> a;
        vec[i] = {a, i};
    }

    // aでソート
    sort(vec.begin(), vec.end());

    vector<int> ans(n);
    rep(i, n){
        if(i == n - 1){
            ans[vec[i].second] = vec[n - 2].first;
        }else{
            ans[vec[i].second] = vec[n - 1].first;
        }
    }
    rep(i, n) OP(ans[i]);
}


Measured memory_bytes: 3968
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdint>
#include <utility>
#include <iomanip>
#include <cstring>
using namespace std;

int kaisu(int k,int a) {//k:K a:initial points
    int ret = 0;
    for(int i = a;i < k;) {
        ret ++;
        i = i * 2;
    }
    return ret;
}

int main() {
    double r = 0;
    int k,n;
    cin >> n >> k;
    for(int i = 1;i <= n;i++) {
        r += pow(0.5,kaisu(k,i));
    }
    cout << setprecision(20) << r/(double)n << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
struct NODE{
	int x1,y1,x2,y2,d;
	NODE(int a,int b,int c,int D,int e){
		x1 = a , y1 = b , x2 = c , y2 = D , d = e;
	}
};
bool done[52][52][52][52] = {0};
bool data[52][52];
int main(){
	int W,H;
	while(cin >> W >> H , W){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		rep(i,52)rep(j,52)data[i][j] = true;
		rep(i,H)rep(j,W)cin >> data[i+1][j+1];
		queue<NODE> Q;
		Q.push(NODE(a,b,c,d,0));
		int ans = -1;
		rep(i,52)rep(j,52)rep(k,52)rep(l,52)
			done[i][j][k][l] = 0;
		
		while(Q.size()){
			NODE q = Q.front(); Q.pop();
			if(q.d >= 100) break;
			if(done[q.y1][q.x1][q.y2][q.x2])continue;
			else done[q.y1][q.x1][q.y2][q.x2] = true;
			
			if(q.x1 == q.x2 && q.y1 == q.y2){
				ans = q.d;
				break;
			}
			rep(i,4){
				int A = q.x1 + dx[i] , B = q.y1 + dy[i];
				int C = q.x2 - dx[i] , D = q.y2 - dy[i];
				if(data[B][A])A = q.x1 , B = q.y1;
				if(data[D][C])C = q.x2 , D = q.y2;
				Q.push(NODE(A,B,C,D,q.d+1));
			}
		}
		if(~ans){
			cout << ans << endl;
		}else{
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 8968
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main(){
	int n,ans=0,b,bb;
	cin>>n;
	cin>>b;
	ans+=b;
	for(int i=1;i<n-1;i++){
		cin>>bb;
		ans+=min(b,bb);
		b=bb;
	}
	cout<<ans+b<<endl;
	return 0;
}

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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(a>b)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

//without rank
struct unionfind{
	vi p,s;
	unionfind(int n):p(n,-1),s(n,-1){}
	int find(int a){
		return p[a]==-1?a:(p[a]=find(p[a]));
	}
	//set b to a child of a
	bool unite(int a,int b){
		a=find(a);
		b=find(b);
		if(a==b)return false;
		p[b]=a;
		s[a]+=s[b];
		return true;
	}
	bool same(int a,int b){
		return find(a)==find(b);
	}
};

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

	int n,q;cin>>n>>q;
	unionfind uf(n);
	
	rep(_,q){
		int c,x,y;
		cin>>c>>x>>y;
		if(c==0)
			uf.unite(x,y);
		else
			cout<<uf.same(x,y)<<"\n";
	}
}



Measured memory_bytes: 3336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>a>>b>>c;
	if(a+b>=c) return cout<<b+c<<endl,0;
	else return cout<<a+b+b+1<<endl,0; 
}

Measured memory_bytes: 256
// atcoder/abc043/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  int n;
  while (cin >> n) {
    cout << n * (n + 1) / 2 << endl;
  }

  return 0;
}


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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

int main()
{
    long H, W; cin >> H >> W;
    if(H==1 || W==1) cout << 1 << endl;
    else if(H%2==0 && W%2==0) cout << H*W/2 << endl;
    else if(H%2==0 && W%2!=0) cout << H/2*W << endl;
    else if(H%2!=0 && W%2==0) cout << W/2*H << endl;
    else cout << (H*W+1)/2 << endl; 
    
    return 0;
    
}



Measured memory_bytes: 256
package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	if !s.Scan() {
		log.Fatal("scan error")
	}

	var w = bufio.NewWriter(os.Stdout)

	n, _ := strconv.Atoi(s.Text())
	mp := make(map[string]int)
	for i := 0; s.Scan() && i < n; i++ {
		switch s.Text() {
		case "insert":
			s.Scan()
			mp[s.Text()] = 0
		case "find":
			s.Scan()
			if _, ok := mp[s.Text()]; ok {
				fmt.Fprintln(w, "yes")
			} else {
				fmt.Fprintln(w, "no")
			}
		default:
		}
	}

	if s.Err() != nil {
		log.Fatal(s.Err())
	}
	_ = w.Flush()

}



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

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

    vector<ll> x(N);
    rep(i, N) cin >> x[i];

    int zero_i = lower_bound(all(x), 0) - x.begin();

    vector<ll> plus(N - zero_i);
    vector<ll> minus(zero_i);


    rep(i,N){
        if(zero_i - i>0) minus[zero_i - i - 1] = -1 * x[i];
        else plus[i-zero_i] = x[i];
    }

    ll ans = 1e14;
    rep(i,plus.size()){
        ll tmp_ans = 0;
        ll k = K;
        k -= i+1;
        tmp_ans += plus[i];
        if(minus.size() < k) continue;
        if(k>0) tmp_ans += (plus[i] + minus[k-1]);
        ans = min(ans,tmp_ans);
    }

    rep(i,minus.size()){
        ll tmp_ans = 0;
        ll k = K;
        k -= i+1;
        tmp_ans += minus[i];
        if(plus.size() < k) continue;
        if(k>0) tmp_ans += (minus[i] + plus[k-1]);
        ans = min(ans,tmp_ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <numeric>
#include <vector>

int main() {
  using namespace std;
  int N;
  cin >> N;
  vector<int> B(N - 1);
  for (auto &e : B)
    cin >> e;

  auto res = B[0];
  for (auto i = 1; i < B.size(); ++i) {
    res += min(B[i - 1], B[i]);
  }
  res += B.back();

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

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Exchange
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, b, k;
  scanf("%d%d%d", &a, &b, &k);

  for (int i = 0; i < k; i++) {
    if (! (i & 1))
      a /= 2, b += a;
    else
      b /= 2, a += b;
  }

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


Measured memory_bytes: 256
# 2^100
# WAが残ったので解説見た
def main(N, S):
    total = sum(S)
    if total % 10 != 0:
        return total
    victim = sorted(x for x in S if x % 10 != 0)
    if len(victim) == 0:
        return 0
    else:
        return total - victim[0]

N = int(input())
S = [None] * N
for i in range(N):
    S[i] = int(input())
print(main(N, S))


Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a, newa;

int main(){
	cin >> n >> a;
	
	int flag = 0;
	ll cnt = 1;
	for(ll i = 2; i <= n; i++){
		cin >> newa;
		if(flag == 0){
			if(newa < a){flag = -1;}
			if(newa > a){flag = 1;}
		}
		else{
			if(flag == 1 && newa < a){
				flag = 0;
				cnt++;
			}
			if(flag == -1 && newa > a){
				flag = 0;
				cnt++;
			}
		}
		a = newa;
	}
	
	cout << cnt << endl;
	return 0;
}

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

namespace A_ABC155
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            if((s[0]==s[1]&&s[1]!=s[2]) || (s[0]==s[2]&&s[1]!=s[2]) || (s[1]==s[2]&&s[0]!=s[2]) ){
                WriteLine("Yes");
            }else{
                WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
 
int main(){ 
int n,k,h;
cin>>h>>n;
  int s=0;
for(int i=0; i<n; i++){
  int a;
  cin>>a;
  s+=a;
}
if(h<=s)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}

Measured memory_bytes: 256
A,B,K=map(int,input().split())
l=[int(i) for i in range(A,min(B+1,A+K))]
s=[int(i) for i in range(max(B-K+1,A+K-1),B+1)]
l=l+s
L=list(set(l))
L.sort()
for i in L:
    print(i)

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

int main(){
  vector<vector<int>> a(3, vector<int>(3));
  rep(i,3){
    rep(j,3){
      cin >> a[i][j];
    }
  }
  int n;
  int counts =0;
  cin >> n;
  rep(i,n){
    int b;
    cin >> b;
      rep(i,3){
        rep(j,3){
          if(a[i][j]==b) a[i][j] = 200;
        }
      }
  }
  rep(i,3){
    rep(j,3){
      if(a[i][j] == 200) counts++;
    }
  }
  int ans = 0;
  if(counts < 3) cout << "No" << endl;
  else {
    rep(i,3){
    if(a[i][0] ==200 && a[i][1] ==200 && a[i][2] ==200 ) ans++;
  }
      rep(i,3){
    if(a[0][i] ==200 && a[1][i] ==200 && a[2][i]==200) ans++;
  }
    if(a[0][0] ==200 && a[1][1] ==200 && a[2][2]==200) ans++;
    if(a[0][2] ==200 && a[1][1] ==200 && a[2][0]==200) ans++;


  if(ans != 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  }
}


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

using namespace std;

#define endl '\n'
#define Opy ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)

typedef long long ll;

int main()
{
    //Opy;

/*-------------------------------------------------
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
-------------------------------------------------*/
    string A, B;

    cin>> A>> B;

    if(A.size() > B.size()) cout<< "GREATER\n";

    else if(A.size() < B.size()) cout<< "LESS\n";

    else
    {
        if(A > B) cout<< "GREATER\n";

        else if(A < B) cout<< "LESS\n";

        else cout<< "EQUAL\n";
    }

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
//---------------------------

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



  int x,a,b;cin >> x >> a >> b;
  int ax = abs(x-a);
  int bx = abs(x-b);
  if (ax > bx) {
    P("B");
  }else{
    P("A");
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>
#include <numeric>
#include <string>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )
#define ullrep(i, a, b) for(ull i = (a); i < (b); ++i )
#define ullrrep(i, a, b) for(ull i = (a); i > (b); --i )
#define ullREP(i, a, b) for(ull i = (a); i <= (b); ++i )
#define ullRREP(i, a, b) for(ull i = (a); i >= (b); --i )
int N;
int A[100];
int main() {
    //N = 2;
    //A[0] = 1;
    //A[1] = 3;
    //A[2] = 3;
    //A[3] = 4;
    //rep(i, 0, N)
    //    rep(j, 0, N)
    //        rep(k, 0, N)
    //            rep(l, 0, N)
    //                rep(m, 0, N) {
    //                    int sum = A[i] + A[j] + A[k] + A[l] + A[m];
    //                    if (((sum %2) != 0) && ((sum %3) != 0)) {
    //                        cout << sum << endl;
    //                    }
    //                    }
    cin >> N;
    int cnt = 0;
    int i = 2;
    while (cnt < 56) {
        bool flag = false;
        for (int j = 2; j < i; j++) {
            if (i % j == 0) {
                flag = true;
                break;
            }
        }
        if (!flag && ((i % 10) == 1)) {
            A[cnt++] = i;
        }
        i++;
    }
    rep(k, 0, N) {
        if(k) cout << " ";
        cout << A[k];
    }
    cout << endl;
}

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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main() {
	ll N;
	cin >> N;
	ll sum = 0;
	rep(i,1,N+1) {
		if (i % 3 != 0 && i % 5 != 0) {
			sum += i;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3632
using System;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        int max = rint();
        int[] read = inta();
        int breaking = -1;
        for(int i=0;i<max;i++){
            if(breaking == -1 && read[i] == 1){
                breaking = 1;
            }else if(read[i] == breaking + 1){
                breaking++;
            }
        }
        if(breaking == -1){
            WriteLine(breaking);
        }else{
            WriteLine(max - breaking);
        }
    
    
    
    
    
    
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static long rlong(){
        return long.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    // A/B小数点以下切上
    static int divideup(int divided,int divid){
        int temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
}


Measured memory_bytes: 34780
N = int(input())
S = list(input())
al = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
dic1 = dict(zip(al,list(range(len(al)))))
tmp = []
for i in S:
    tmp.append((dic1[i]+N)%26)
dic2 = dict(zip(list(range(len(al))),al))
ans = []
for j in tmp:
    ans.append(dic2[j])
print(*ans,sep="")

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

int main(){
  int n, i, tmp;
  int count = 0;
  int flag = 1;

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

  while(flag){
    flag = 0;
    for(i = n-1; i > 0; i--){
      if(a[i] < a[i-1]){
        tmp = a[i];
        a[i] = a[i-1];
        a[i-1] = tmp;
        flag = 1;
        count++;
      }
    }
  }

  for(i = 0; i < n-1; i++){
    cout<<a[i]<<" ";
  }
  cout<<a[n-1]<<endl<<count<<endl;

}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
int n;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	double k=floor(n/1.08);
	if(floor(k*1.08)==n){
		printf("%.0f",k);
		return 0;
	}
	if(floor((k+1)*1.08)==n){
		printf("%.0f",k+1);
		return 0;
	}
	puts(":(");
	return 0;
}

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

using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<n; i++)


int main() {
    string S, T;

    cin >> S >> T;
    
    if(S.length() == T.length()-1){
        rep(i,S.length()){
            if (!(S[i] == T[i])){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
using namespace std;

int main() {
  string S; cin >> S;
  deque<string> qs;
  qs.push_back(S);
  int Q; cin >> Q;
  int reverse_count = 0;
  for(int i = 0; i < Q; i++) {
    int t; cin >> t;
    if(t == 1) {
      reverse_count++;
    } else {
      int f; cin >> f;
      string c; cin >> c;
      if(f == 1) {
        if(reverse_count%2==0) {
          qs.push_front(c);
        } else {
          qs.push_back(c);
        }
      } else {
        if(reverse_count%2==0) {
          qs.push_back(c);
        } else {
          qs.push_front(c);
        }
      }
    }
  }
  string ans;
  for(string c: qs) {
    ans+=c;
  }
  if(reverse_count%2==1) reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12128
#include<stdio.h>
int main(void)
{
	int N,i,x,y,b,p,f,c;
	scanf("%d",&N);
	for(i=0;i!=N;i++){
		scanf("%d%d%d%d",&x,&y,&b,&p);
		f=x*b+y*p;
		if(b<5){
			b=5;
		}
		if(p<2){
			p=2;
		}
		c=(x*b+y*p)/5*4;
		if(f<c){
			printf("%d\n",f);
		}
		else{
			printf("%d\n",c);
		}
	}
	return 0;
}

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

template <typename T> struct SegmentTree {
  struct Node {
    T v;
    Node(T v) : v(v) {}

    Node operator*(const Node &r) const {
      return Node(min(v, r.v));
    }
  };

  Node e = Node((1ll << 31) - 1);
  size_t sz;
  vector<Node> seg;

  SegmentTree(int n) {
    sz = 1;
    while (sz < n) sz <<= 1;
    seg.assign(2 * sz - 1, e);
  }

  void update(int k, const Node &x) {
    k += sz - 1;
    seg[k] = x;
    while (k) {
      k = (k - 1) / 2;
      seg[k] = seg[2 * k + 1] * seg[2 * k + 2];
    }
  }

  Node query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return e;
    if (a <= l && r <= b) return seg[k];
    return query(a, b, 2 * k + 1, l, (l + r) / 2) * query(a, b, 2 * k + 2, (l + r) / 2, r);
  }

  void update(int k, T x) {
    update(k, Node(x));
  }

  T query(int a, int b) {
    return query(a, b, 0, 0, sz).v;
  }
};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A&lang=jp
int main() {
  int n, q;
  cin >> n >> q;

  SegmentTree<int> seg(n);
  while (q--) {
    int com;
    cin >> com;

    if (com) {
      int l, r;
      cin >> l >> r;
      cout << seg.query(l, r + 1) << endl;
    } else {
      int v, x;
      cin >> v >> x;
      seg.update(v, x);
    }
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
int imos[111111];

int main(){
	cin.sync_with_stdio(false);
  cin>>n;
  rep(i,n){
    int a,b;
    cin>>a>>b;
    a--; b--;
    imos[a]++; imos[b+1]--;
  }
  rep(i,101010)imos[i+1]+=imos[i];
  int res=0;
  //rep(i,10)dbg(imos[i]);
  rep(i,111111){
    if(imos[i]>=i)maxch(res,i);
  }
  cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3476
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))

left = 0
right = max(A)

while right - left > 1:
    mid = (left + right) // 2
    jk = 0
    for i in range(N):
        jk += A[i] // mid - 1
        if A[i] % mid != 0: jk += 1
    if jk <= K:
        right = mid
    else:
        left = mid

print(right)

Measured memory_bytes: 31148
use std::io::prelude::*;
use std::io;
use std::process;

fn f(n: i32) -> i32 {
    if n % 2 == 0 {
        n / 2
    } else {
        3 * n + 1
    }
}

fn main() {
    let mut stdin = io::stdin();
    let mut buf = String::new();

    stdin.read_to_string(&mut buf).unwrap();

    let s: i32 = buf.split_whitespace().next().unwrap().parse().unwrap();
    
    let mut a_n = s;
    let mut m = 1;
    let mut a: Vec<i32> = Vec::new();
    
    while !a.contains(&a_n) {
        a.push(a_n);
        a_n = f(a_n);
        m += 1;
        if m > 100000 {
            process::exit(0);
        }
    }
    println!("{}", m);

}

Measured memory_bytes: 4352
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

int main() {
 LL L, R;
 cin >> L >> R;
 R = min(R, L + 2020);

 LL res = -1;
 for (LL i = L; i <= R; i ++) {
  for (LL j = i + 1; j <= R; j ++) {
    LL rem = (i * j) % 2019;
    if (res == -1) res = rem;
    else res = min(res, rem);
  }
 }
 cout << res << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


const int PS = 1000000;
int prime[PS];
int set_prime(){
	rep(i,PS)prime[i]=1;
	prime[0]=prime[1]=0;
	rep(i,PS){
		if(prime[i]==0)continue;
		for(int j=i*2;j<PS;j+=i)prime[j]=0;
	}
}

int ss[PS]={0};
	
int main(){
	
	int cnt = 1;
	
	set_prime();
	
	rep(i,PS){
		if(prime[i]==1){
			ss[cnt]=ss[cnt-1]+i;
			cnt++;
		}
	}
	
	
	
	int n;
	while(cin>>n,n){
		printf("%d\n",ss[n]);
	}
	
}

Measured memory_bytes: 7212
#include <queue>
#include <set>
#include <unordered_set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef pair<int,int> pii;

/// pair<int,int> hasher
namespace std{
	template<typename I>
	class hash<pair<I,I>>{
		public:
		size_t operator()(const pair<I,I> &p) const {return hash<long long>() (((long long)(p.first))<<32|p.second);}
	};
}

double solve(const vector<pii> &a){
	set<int>ys;
	for(auto &e:a)ys.insert(e.second);
	int n=a.size();
	vector<double>mx,my;
	mx.reserve(n*2);
	my.reserve(n*2);
	for(int i=0;i<n;i++){
		mx.push_back(a[i].first);
		my.push_back(a[i].second);
		if(i==n-1)continue;
		//??????????????§y??§?¨??????????ys?????????????????????
		if(a[i].second<a[i+1].second){ //??????i????°???§??????
			for(auto it=ys.begin();it!=ys.end();++it){
				if(a[i].second<*it && *it<a[i+1].second){
					double dy=a[i+1].second-a[i].second;
					double dx=(a[i+1].first-a[i].first)/dy*(*it-a[i].second);
					mx.push_back(a[i].first+dx);
					my.push_back(*it);
				}
			}
		}else{ //??????i????±±??§??????
			for(auto it=ys.end();it--!=ys.begin();){
				if(a[i+1].second<*it && *it<a[i].second){
					double dy=a[i+1].second-a[i].second;
					double dx=(a[i+1].first-a[i].first)/dy*(*it-a[i].second);
					mx.push_back(a[i].first+dx);
					my.push_back(*it);
				}
			}
		}
	}
	int m=mx.size();
	priority_queue<pair<double,pii>>q;
	unordered_set<pii>se;
	q.push({0,{0,m-1}});
	for(;!q.empty();){
		double c=q.top().first;
		int l=q.top().second.first;
		int r=q.top().second.second;
		q.pop();
		if(se.find({l,r})!=se.end())continue;
		se.insert({l,r});
		if(l==r)return -c;
		for(int i=-1;i<2;i++)for(int j=-1;j<2;j++){
			if((i||j) && 0<=l+i&&l+i<m && 0<=r+j&&r+j<m && fabs(my[l+i]-my[r+j])<1e-9)
				q.push({c-hypot(mx[l]-mx[l+i],my[l]-my[l+i])-hypot(mx[r]-mx[r+j],my[r]-my[r+j]),{l+i,r+j}});
		}
	}
	abort();
}

int main(){
	int N,x,y;
	for(;scanf("%d",&N),N;){
		vector<pii>a(N);
		for(int i=0;i<N;i++)scanf("%d%d",&a[i].first,&a[i].second);
		printf("%f\n",solve(a));
	}
}

Measured memory_bytes: 4432
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

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

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int n;
    cin >> n;

    vll L(n);
    REP(i, n) cin >> L[i];

    ll cnt = 0;
    REP(i, L.size()) FOR(j, i + 1, L.size()) FOR(k, j + 1, L.size()) {
        vector<ll> v = {L[i], L[j], L[k]};
        sort(ALL(v));
        if (v[0] + v[1] > v[2] && v[0] != v[1] && v[1] != v[2] && v[2] != v[0]) {
            cnt++;
        }
    }

    print(cnt);
    
}


Measured memory_bytes: 3644
#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:tt)*) => (if cfg!(debug_assertions) {print!("[DEBUG] "); println!($($arg)*)});
}

const MOD: i64 = 1e9 as i64 + 7;
const N: usize = 40;
const B: usize = 17;
const MASK: usize = (1 << B) - 1;

fn main() {
    let mut rd = reader::Reader::new();

    let n = rd.next();
    let x: i64 = rd.next();
    let y: i64 = rd.next();
    let z: i64 = rd.next();

    let s = (1 << (x + y + z)) | (1 << y + z) | (1 << z);

    let mut dp = vec![vec![0i64; 1 << B]; N + 1];
    dp[0][1] = 1;
    let mut ans = 0;
    for i in 0..n {
        ans *= 10;
        ans %= MOD;
        for d in 1..11 {
            for b in 0..(1 << B) as usize {
                if dp[i][b] == 0 {
                    continue;
                }
                let nb = (b << d) | 1;
                debug!("b = {:b}, nb = {:b}", b, nb);
                if (s & nb) != s {
                    let nb = (nb & MASK) as usize;
                    dp[i + 1][nb] += dp[i][b];
                    dp[i + 1][nb] %= MOD;
                } else {
                    ans += dp[i][b];
                    ans %= MOD;
                }
            }
        }
    }
    println!("{}", ans);
}

mod reader {
    use std::fmt::Debug;
    use std::str::FromStr;
    use std::collections::VecDeque;
    use std::io::{self, Read};

    fn _read_line() -> String {
        let mut buf = String::new();
        let _ = io::stdin().read_to_string(&mut buf);
        buf
    }

    fn _read_vec_deque_string() -> VecDeque<String> {
        _read_line()
            .split_whitespace()
            .map(|s| s.to_string())
            .collect()
    }

    #[allow(dead_code)]
    pub struct Reader {
        buf: VecDeque<String>,
    }

    #[allow(dead_code)]
    impl Reader {
        pub fn new() -> Reader {
            Reader { buf: VecDeque::new() }
        }

        fn update_buf(&mut self) {
            if self.buf.is_empty() {
                self.buf = _read_vec_deque_string();
            }
        }

        pub fn next<T>(&mut self) -> T
            where
                T: FromStr,
                T::Err: Debug,
        {
            self.update_buf();
            self.buf.pop_front().unwrap().parse::<T>().unwrap()
        }

        pub fn next_n<T>(&mut self, n: usize) -> Vec<T>
            where
                T: FromStr,
                T::Err: Debug,
        {
            let mut vec: Vec<T> = Vec::with_capacity(n);

            for _ in 0..n {
                vec.push(self.next());
            }
            vec
        }
    }
}


Measured memory_bytes: 86268
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    string s; cin >> s;
    int x = 0, ans = 0;;
    for(int i = 0; i < s.size(); i++) {
        if (s[i] == 'I') x++;
        else x--;
        ans = max(ans, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256