akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://tenka1-2017.contest.atcoder.jp/tasks/tenka1_2017_d>
問題文============================================================
 非負整数専門店「せいすうや」には、N 個の非負整数が売られています。
 i 個目の非負整数は Ai で、その価値は Bi です。 価値の異なる同じ非負整数が複数売られていることもあります。
 
 高橋君は、「せいすうや」でいくつかの整数を買うことにしました。
 高橋君は、買う整数たちの bitwise or が K 以下になるような 任意の組み合わせで、整数を買うことができます。
 高橋君は、買った整数たちの価値の総和をできるだけ大きくしたいです。
 
 高橋君が達成できる、価値の総和の最大値を求めてください。
 ただし、bitwise or とは、ビットごとの論理和を表します。
=================================================================

解説=============================================================

 K以下であり、極力bitを立たせるには
 
 1010010
 
 という数字があれば、各1に注目して　それより上の位はそのまま、今見ている位は 0 ,それより下の位は全て 1 にすれば良い
 よって
 0111111
 1001111
 1010001
 
 と行ったパターンが考えられる。
 ここで K < 20^30 なので 高々 30パターンしかない
 
 よって、各パターンについて貪欲に確認していけば良い
 
================================================================
*/
ll solve(){
    ll ret = 0;
    ll N,K; cin >> N >> K;
    vector<ll> A(N),B(N);
    for(int i = 0; i < N;i++) cin >> A[i] >> B[i];
    for(int i = 0; i < N;i++) if(K == (K|A[i])) ret += B[i];
    for(ll i = 1; i <= K; i<<= 1){
        if(!(i&K)) continue;
        ll nK = (K^i) | (i-1);
        ll T = 0;
        for(int j = 0; j < N;j++){
            if(nK != (nK|A[j])) continue;
            T += B[j];
        }
        ret = max(ret,T);
    }
    return ret;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 文字列の入力
		String x = sc.next();
        String y = sc.next();
        int xValue = Integer.parseInt(x, 16);
        int yValue = Integer.parseInt(y, 16);
        String ans = "";
        if (x.equals(y)) {
          ans = "=";
        } else if (xValue > yValue) {
          ans = ">";
        } else {
          ans = "<";
        }
    
		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>




typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;



int main(){
    int n;
    cin>>n;
    vector<int> v;
    rep(i,n){
        int a;
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    //rep(i,n) cout<<v[i]<<endl;
    int saichou=0;
    int ans=0;
    rep(i,n-2) {
        for (int j=i+1;j<n-1;j++){
            saichou=v[i]+v[j];
            auto itr=lower_bound(v.begin(),v.end(),saichou);
            //cout<<v[i]<<","<<v[j]<<"notoki"<<saichou<<"ha"<<*itr<<endl;
            ans+=itr-v.begin();
            ans-=j+1;
        }
        
    }
    
    cout<<ans<<endl;
    return 0;
}


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





int main(){
	int P=0;
	int Q=0;
	int R=0;
	cin>>P>>Q>>R;
	int ans;
	int a,b,c;
	a=P+Q;
	b=Q+R;
	c=R+P;
	vector<int>t(4);

	t[0]=a;
	t[1]=b;
	t[2]=c;
	ans =a;
	for(int i=1;i<3;i++){
		if(ans>t[i]){
			ans=t[i];
		}
	}
	cout<<ans;



	
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, m;
    cin >> n >> m;

    vl v(MAX_N);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        v[a]++;  v[b]++;
    }

    rep(i, MAX_N) {
        if(v[i]%2 == 1) {
            out("NO");
            re0;
        }
    }
    
    out("YES");
    re0;
}

Measured memory_bytes: 1152
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

from decimal import Decimal
a,b = (Decimal(x) for x in input().split())
print(int(a*b))


Measured memory_bytes: 73496
while True:
    n=int(input())
    if n==0:
        break
    s=0
    vmin=1001
    vmax=-1
    for i in range(n):
        a=int(input())
        vmin=min(vmin,a)
        vmax=max(vmax,a)
        s+=a
    print((s-vmin-vmax)//(n-2))



Measured memory_bytes: 5588
from sys import stdin
import numpy as np
from numba import njit
def main():
    #入力
    readline=stdin.readline
    n,k=map(int,readline().split())
    a=np.array(list(map(int,readline().split())),dtype=np.int64)

    cnt=0
    while cnt<k:
        s=f(n,a)
        a=np.cumsum(s)
        cnt+=1
        if a[a==n].size==n:
            break

    print(*a)

@njit
def f(n,a):
    s=np.zeros(n,dtype=np.int64)
    for i in range(n):
        x_min=i-a[i]
        x_max=i+a[i]+1
        s[max(0,x_min)]+=1
        if n-1<x_max:
            pass
        else:
            s[x_max]-=1
    return s

if __name__=="__main__":
    main()

Measured memory_bytes: 122520
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

if sum(A) < sum(B):
    print(-1)
    exit()

S = [b - a for a, b in zip(A, B) if a < b]

if sum(S) == 0:
    print(0)
    exit()

T = sorted([a - b for a, b in zip(A, B) if a > b], key=lambda x: -x)

cnt = 0
tmp = sum(S)
for t in T:
    tmp -= t
    cnt += 1

    if tmp <= 0:
        break

if tmp > 0:
    print(-1)
    exit()

print(len(S) + cnt)


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

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

int main()
{
    int n;
    scanf("%d", &n);

    ii inp[n];
    for (int i = 0; i < n; i++) {
        int num;
        scanf("%d", &num);

        inp[i] = {num, i};
    }

    sort(inp, inp + n);

    for (int i = 0; i < n; i++)
        printf("%d%c", inp[i].second + 1, i == n - 1 ? '\n' : ' ');

    return 0;
}


Measured memory_bytes: 1536
#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap, VecDeque};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;
#[allow(dead_code)]
const MOD: i32 = 1000_000_007;
#[allow(dead_code)]
const MODLL: i64 = 1000_000_007;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}



fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.read();
    let a: usize = sc.read();
    let n = n % 500;
    if n <= a {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
x = gets.to_i
ary = []
if x == 1
  puts 1
else
(1..x).each do |i|
  (2..9).each do |k|
    if i == 1
      ary << i
      next
    else
      if i**k <= x
        ary << i**k
      end
    end  
  end
end
puts ary.max
end


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

int main() {
  int N; cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) cin >> L.at(i);
  sort(L.begin(), L.end());
  int ans = 0;
  for (int i = 0; i < N-2; i++) {
    for (int j = i+1; j < N-1; j++) {
      int index = lower_bound(L.begin(), L.end(), abs(L.at(i)+L.at(j))) - L.begin();
      ans += index - j - 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a;i<=b;++i)
#define read(n)  scanf("%d",&n)
#define read2(n,m) scanf("%d%d",&n,&m)
#define ll long long 
int main()
{
	int a,b;
	read2(a,b);
	cout<<a*b;
	return 0;
 } 

Measured memory_bytes: 3684
program trick_or_treat
  implicit none
  integer :: n, k, d, a(100) = 0, c(100) = 1, i, j
  read(*,*) n, k
  do i = 1, k
    read(*,*) d
    read(*,*) a(1:d)
    do j = 1, d
      c(a(j)) = c(a(j))-1
    end do
  end do
  write(*,'(i0)') sum(c(1:n),c(1:n) > 0)
end program trick_or_treat

Measured memory_bytes: 2932
#include <bits/stdc++.h>
#define deb(x)     cerr << (#x) << " : " << (x) << "\n"
#define ll long long int
#define ld long double
#pragma warn +rvl
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
using namespace std;
 
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%MOD+MOD)%MOD){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%MOD+MOD)%MOD; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint operator~() const { return mint(1) / *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=MOD) x-=MOD; return *this;}
  mint& operator-=(const mint& a){ if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=MOD; return *this;}
  mint& operator/=(const mint& a){ (x*=a.ex(MOD-2).x)%=MOD; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  mint operator/(const mint& a)const{ return mint(*this) /= a;}
  mint ex(ll t) const {
    if(!t) return 1;
    mint res = ex(t/2);
    res *= res;
    return (t&1)?res*x:res;
  }
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
 
mint ex(mint x, ll t) { return x.ex(t);}
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x % MOD;return o;}
 
ll powmod(ll a, ll b, ll MOD = MOD){
	if(!a and !b)	return 1ll;
	if(!a)	return a;
	ll res = 1ll;
	b %= (MOD - 1ll), a %= MOD;
	while(b){
		if(b%2 == 1)	res = (res * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}
	return res;
}
  
int main(){

 
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    ll n;
    cin >> n ;
    cout << (n - 1ll) / 2;
}


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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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

int D,T,S;

signed main(){
    cin>>D>>T>>S;
    if(S*T>=D)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3640
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		String b = sc.next();

		switch(b) {
		case "A":
			out.println("T");
			break;
		case "T":
			out.println("A");
			break;
		case "C":
			out.println("G");
			break;
		case "G":
			out.println("C");
			break;
		}

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 23252
/**
 * Heaps - Maximum Heap
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int h = parseInt(br.readLine());
		int[] heap = new int[h + 1];
		StringTokenizer st = new StringTokenizer(br.readLine());
		for (int i = 1; i < h + 1; i++) {
			heap[i] = parseInt(st.nextToken());
		}
		buildMaxHeap(heap);
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i < h + 1; i++) {
			sb.append(" ").append(heap[i]);
		}
		System.out.println(sb.toString());
	} //end main

	static int parent(int i) {
		return i / 2;
	}

	static int left(int i) {
		return i * 2;
	}

	static int right(int i) {
		return i * 2 + 1;
	}

	static void maxHeapify(int[] heap, int i) {
		int left = left(i);
		int right = right(i);
		int largest = i;
		if (left < heap.length && heap[left] > heap[i]) {
			largest = left;
		}
		if (right < heap.length && heap[right] > heap[largest]) {
			largest = right;
		}
		if (largest != i) {
			int tmp = heap[i];
			heap[i] = heap[largest];
			heap[largest] = tmp;
			maxHeapify(heap, largest);
		}
	}

	static void buildMaxHeap(int[] heap) {
		for (int i = (heap.length - 1) / 2; i >= 1; i--) {
			maxHeapify(heap, i);
		}
	}
}

Measured memory_bytes: 76960
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  string s,t; cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if(s<t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100000000000000

/*方針*/
/*x->yへのkを通る最短距離=(k->xの最短距離)+(k->yの最短距離)である*/

//➀それぞれの辺の間の距離をdistに記憶
//➁bfsで頂点kからのそれぞれの頂点に対する最短距離を求める
//➂q個のquestionに対して     (k->xのmin)+(k->yのmin)を足して出力


int main(){
	ll n;cin>>n;//頂点数
	map<pair<int,int>,int> dist;//頂点間距離
	vector<vector<int>> G(n);//隣接行列

/*➀*/		for(int i=0;i<n-1;i++){//辺と距離について
		ll a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
		dist[make_pair(a,b)]=dist[make_pair(b,a)]=c;
		dist[make_pair(i,i)]=0;
	}

	ll q,k;cin>>q>>k;//頂点kを必ず経由
	k--;

	queue<ll> que;
	que.push(k);//kから各頂点への最短距離を知りたい

	vector<bool> visit(n,false);
	vector<ll> distance_from_k(n,0);
	visit[k]=true;

/*➁*/		while(que.size()!=0){
		ll now=que.front();
		que.pop();
		visit[now]=true;

		for(auto next:G[now]){
			if(visit[next]) continue;
			
			distance_from_k[next]=distance_from_k[now]+dist[make_pair(now,next)];
			que.push(next);
		}
	}
	
	vector<pair<int,int>> want(q);//この頂点間最短距離を求める 
	for(int i=0;i<q;i++){
		ll x,y;cin>>x>>y;
		x--;y--;
		want[i]=make_pair(x,y);
	}

/*➂*/		for(int i=0;i<q;i++){
		cout<<distance_from_k[want[i].first]+distance_from_k[want[i].second]<<endl;
	}

	return 0;
}

Measured memory_bytes: 30320
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int x; 
    cin >> x;
    Yes(x>=30); 
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  vector<ll> div = divisor(n);
  int ans = 11;
  for(auto d: div){
    int a_dig = to_string(d).length();
    int b_dig = to_string(n/d).length();
    ans = min(ans, max(a_dig, b_dig));
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
dice = [int(_) for _ in input().split()]
move = [ _ for _ in input()]
dire = {"N": [2,6,3,4,1,5],"S":[5,1,3,4,6,2],
      "E":[4,2,1,6,5,3],"W":[3,2,6,1,5,4]}
em = []
for i in range(len(move)):
    em = dice[:]
    for j in range(len(dice)):
        em[j] = dice[dire[move[i]][j]-1]
    else:
        del dice[:]
        dice.extend(em)
print(dice[0])


Measured memory_bytes: 5604
const bool TEST=1;
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
#include<sstream>
#include<stack>
const int inf=0x7fffffff;
#define IF if(TEST)
#define FI if(!TEST)
#define gts(s) fgets((s),sizeof(s),stdin)
#define ALL(s) (s).begin(),(s).end()
#define MK(a,b) make_pair((a),(b))
typedef long long int LL;
typedef unsigned int U;
typedef unsigned long long ULL;
using namespace std;
typedef pair<int,int> Point;
template <typename T>
void pA(T *begin,int n){ for(int i=0;i<n;i++){ cout<<*(begin++); } printf("\n"); }
ostream&  operator << (ostream &out,const Point &a){ out<<'('<<a.first<<','<<a.second<<')'; return out; }
const int M=1e5;
void sol(){
	int x,i;
	cin>>x;
	i=0;
	LL xx=x;
	xx*=2;
	LL sum = 0 ;
	for(i =1;i<M;i++){
		sum+=i;
		if(sum>=x)break;
	}
	printf("%d\n", i);
}
int main()
{
	sol();
	return 0;
}
//C.cc
//generated automatically at Sat Mar 18 20:05:30 2017
//by xsthunder


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

using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int  ll;

int main(void)
{
    //READ_IN;
     int n; cin >> n;

     int m; cin >> m;

     vector<bool> ck(100006,false);


     int sum = 0;
     int ac = 0;

        map<int,int> mm;

     for(int i=0;i<m;i++)
     {
         int a; string s;

         cin >> a;
         cin.ignore();
         cin >> s;

         if(s=="AC")
         {
             if(ck[a]==false)
             {
                 ck[a]=true;
                 ac++;
                 sum+=mm[a];
             }


         }
         else
         {


             if(ck[a]==true)
             {

                 mm[a]=0;
             }
             else
                mm[a]++;

         }
     }

     cout << ac << " " << sum << endl;

    return 0;
}


Measured memory_bytes: 4992
n, a, b, c, d = list(map(int, input().split()))
s = input()
if '##' in s[a-1:max(c, d)]:
    out = 'No'
elif c < d:
    out = 'Yes'
elif '...' in s[b-2:d+1]:
    out = 'Yes'
else:
    out = 'No'
print(out)

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=5e3+7;
const int mod=1e9+7;
vi G[maxn];
int maxson[maxn],sz[maxn];
int rt,mx=0x3f3f3f3f;
int n;
void getrt(int u,int fa=-1)
{
    sz[u]=1;
    for(auto v:G[u])if(v!=fa)
    {
        getrt(v,u);
        sz[u]+=sz[v];
        maxson[u]=max(maxson[u],sz[v]);
    }
    maxson[u]=max(maxson[u],n-sz[u]);
    if(maxson[u]<mx)
    {
        mx=maxson[u];
        rt=u;
    }
}
void dfs(int u,int fa=-1)
{
    sz[u]=1;
    for(auto v:G[u])if(v!=fa)
    {
        dfs(v,u);
        sz[u]+=sz[v];
    }
}
ll dp[maxn][maxn];
ll C[maxn][maxn];
ll fac[maxn];
void init()
{
    fac[0]=1;
    for(int i=1;i<maxn;i++) fac[i]=fac[i-1]*i%mod;
    for(int i=0;i<maxn;i++)
    {
        C[i][0]=1;
        for(int j=1;j<=i;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
    }
}
int main()
{
    init();
    cin>>n;
    for(int i=1,u,v;i<n;i++)
    {
        cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    getrt(1);
    int cnt=1;
    for(auto v:G[rt])
    {
        if(maxson[v]==mx) cnt++;
    }
    if(cnt==2)
    {
        ll ans=1;
        assert(n%2==0);
        for(int i=1;i<=n/2;i++) ans=ans*i%mod;
        print(ans*ans%mod);
    }
    else if(cnt==1){
        int cc=0;
        //dbg(rt);
        vi T;
        for(auto v:G[rt])
        {
            dfs(v,rt);
            cc++;
            T.push_back(sz[v]);
        }
        dp[0][0]=1;
        for(int i=1;i<=cc;i++)
        {
            for(int k=0;k<=n;k++)
            {
                if(!dp[i-1][k]) continue;
                for(int j=0;j<=T[i-1];j++)
                    dp[i][j+k]=(dp[i][j+k]+dp[i-1][k]*C[T[i-1]][j]%mod*C[T[i-1]][j]%mod*fac[j]%mod)%mod;
            }
        }
        ll ans=0;
        for(int i=0;i<=n-1;i++)
        {
            ll cur=dp[cc][i]*fac[n-i]%mod;
            //dbg(dp[cc][i]);
            if(i&1) ans=(ans-cur+mod)%mod;
            else ans=(ans+cur)%mod;
        }
        print(ans);
    }
    else assert(false);
}

Measured memory_bytes: 390400
h, w = map(int, input().split())
s = [["a"]*(w + 2)]

for i in range(h):
    a = list("a" + input() + "a")
    s.append(a)

s.append(["a"]*(w + 2))

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if s[i][j] == ".":
            cnt = s[i - 1][j - 1: j + 2].count("#")
            cnt += s[i][j - 1: j + 2].count("#")
            cnt += s[i + 1][j - 1: j + 2].count("#")
            s[i][j] = str(cnt)

for i in range(1, h + 1):
    print("".join(s[i][1:-1]))

Measured memory_bytes: 3188
import java.io.*;
public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader reader = new BufferedReader( new InputStreamReader(System.in));
    int a = Integer.parseInt(reader.readLine());
   
    double r = 0.0;
    String[] s =  reader.readLine().split(" ");
    for(int i =0;i<a;i++){
      r = r+ 1.0/(double)Integer.parseInt(s[i]);}
 
      System.out.println(1.0/r);}
}

Measured memory_bytes: 23124
import heapq
import numpy as np

n = int(input())
a = list(map(int, input().split()))
s_front = [0] * (n + 1)
s_back = [0] * (n + 1)

a_front = a[:n]
heapq.heapify(a_front)
s_front[0] = sum(a_front)
for k in range(n):
    heapq.heappush(a_front, a[n + k])
    b = heapq.heappop(a_front)
    s_front[k + 1] = s_front[k] + a[n + k] - b

a_back = [(-x, x) for x in a[2 * n:]]
heapq.heapify(a_back)
s_back[0] = sum([x[1] for x in a_back])
for k in range(n):
    heapq.heappush(a_back, (-1 * a[2 * n - k - 1], a[2 * n - k - 1]))
    b = heapq.heappop(a_back)[1]
    s_back[k + 1] = s_back[k] + a[2 * n - k - 1] - b

s_front = np.array(s_front)
s_back = np.array(s_back[::-1])
print(max(s_front - s_back))

Measured memory_bytes: 46084
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int a[3];
    rep(i,3)cin >> a[i];
    sort(a,a+3);
    cout << a[0]*a[1]/2 << endl;
}


Measured memory_bytes: 256
//it was hard to write
//so it should be hard to read
#include <bits/stdc++.h>
#define sz size
#define pb push_back
#define ll long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define last(x) (x).size() - 1
#define mp make_pair

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef double ld;

const int MAXN = 1e6 + 5;
const ll INF = 1e18 + 7;
const int inf = 1e9 + 7;
const double EPS = 1e-9;

int n, a, b;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(9);
	cout << fixed;
	cin >> n >> a >> b;
	cout << min(n * a, b);
	return 0;
}     

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


int main()
{  
   int a,b,c;
   scanf("%d%d%d",&a,&b,&c);
    if((a-b)>=c)
        printf("0");
  
    else
       printf("%d",c-(a-b));
  
   
}

Measured memory_bytes: 256
from itertools import *
from bisect import *
from operator import *
import math

def comb(n, r):
    return math.factorial(n) / (math.factorial(r) * math.factorial(n-r))

n = int(input())
a = list(map(int, input().split()))

a_item = sorted(a)
a_max = a_item[-1]
a_item = a_item[:-1]
bisect_l_item = bisect_left(a_item, a_max//2)
#import pdb; pdb.set_trace()
if bisect_l_item >= n - 1:
    bisect_l = a_item[bisect_l_item - 1]
else:
    bisect_l = a_item[bisect_l_item]

bisect_r = a_item[bisect_l_item - 1]
if abs(bisect_r - a_max/2) <= abs(bisect_l - a_max/2):
    print(a_max, bisect_r)
else:
    print(a_max, bisect_l)
#print(bisect_l_item, bisect_l, bisect_r)
#idea_l = comb(a_max, bisect_l)
#idea_r = comb(a_max, bisect_r)



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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  string a,b,c;
  cin >> a >> b >> c;

  if((a[a.size()-1] == b[0]) && (b[b.size()-1] == c[0])){
    printf("YES\n");
  }
  else printf("NO\n");
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double xs = sc.nextDouble();
		double ys = sc.nextDouble();
		double xt = sc.nextDouble();
		double yt = sc.nextDouble();
		int N = sc.nextInt();
		double[] x = new double[N];
		double[] y = new double[N];
		double[] r = new double[N];
		for (int i = 0; i < N; ++i) {
			x[i] = sc.nextDouble();
			y[i] = sc.nextDouble();
			r[i] = sc.nextDouble();
		}
		double[][] d = new double[N + 2][N + 2];
		d[N][N + 1] = d[N + 1][N] = pointToPointDistance(xs, ys, xt, yt);
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				if (i == j)
					continue;
				d[i][j] = circleToCircleDistance(x[i], y[i], r[i], x[j], y[j], r[j]);
			}
		}
		for (int i = 0; i < N; ++i) {
			d[N][i] = d[i][N] = circleToPointDistance(x[i], y[i], r[i], xs, ys);
			d[N + 1][i] = d[i][N + 1] = circleToPointDistance(x[i], y[i], r[i], xt, yt);
		}
		double[] distFromS = new double[N + 2];
		Arrays.fill(distFromS, Double.MAX_VALUE);
		distFromS[N] = 0;
		PriorityQueue<State> que = new PriorityQueue<>();
		que.add(new State(0, N));
		while (!que.isEmpty()) {
			State s = que.poll();
			if (s.d > distFromS[s.id])
				continue;
			for (int i = 0; i < N + 2; ++i) {
				double nd = s.d + d[s.id][i];
				if (distFromS[i] > nd) {
					distFromS[i] = nd;
					que.add(new State(nd, i));
				}
			}
		}
		System.out.println(distFromS[N + 1]);
	}

	static class State implements Comparable<State> {
		double d;
		int id;

		public State(double d, int id) {
			this.d = d;
			this.id = id;
		}

		@Override
		public int compareTo(State o) {
			return Double.compare(this.d, o.d);
		}

	}

	static double circleToCircleDistance(double x1, double y1, double r1, double x2, double y2, double r2) {
		double d = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) - r1 - r2;
		if (d < 0)
			d = 0;
		return d;
	}

	static double circleToPointDistance(double x1, double y1, double r1, double x2, double y2) {
		double d = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) - r1;
		if (d < 0)
			d = 0;
		return d;
	}

	static double pointToPointDistance(double x1, double y1, double x2, double y2) {
		return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	}
}


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

int main(){
  int n,s,t,a[3000],b[3000],dp[2][3001];
  scanf("%d %d %d",&n,&t,&s);
  for(int i=0;i<n;i++) scanf("%d %d",a+i,b+i);
  for(int i=0;i<=n;i++){
    for(int j=0;j<=t;j++){
      if(i==0||j==0) dp[i%2][j] = 0;
      else if(j<=s){
        if(j-b[i-1]>=0) dp[i%2][j] = max(dp[(i-1)%2][j-b[i-1]]+a[i-1],dp[(i-1)%2][j]);
        else dp[i%2][j] = dp[(i-1)%2][j];
      }else{
        if(j-b[i-1]>=s) dp[i%2][j] = max(dp[(i-1)%2][j-b[i-1]]+a[i-1],dp[(i-1)%2][j]);
        else dp[i%2][j] = dp[(i-1)%2][j];
      }
    }
  }
  int ans = 0;
  for(int i=0;i<=t;i++) ans = max(ans,dp[n%2][i]);
  printf("%d\n",ans);
  return 0;
}

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

mlis = []
jblis= []
for _ in range(n):
    a, b = input().split()
    mlis.append(float(a))
    jblis.append(b)
    
    
total = 0
for i in range(n):
    if jblis[i] == 'JPY':
        total += mlis[i]
    else:
        total += mlis[i]*380000.0

print(total)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[4];
    rep(i,4){
        cin >> A[i];
    }
    // sort(A,A+3);
    cout << ((abs(A[2]-A[1])<=A[3]&&abs(A[1]-A[0])<=A[3])|| abs(A[2]-A[0])<=A[3] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
line = input()
n, a, b = line.split(" ")
n = int(n)
a = int(a)
b = int(b)

num = 0
i = 0
i = int(n / (a + b)) + 1
if ((a + b)*i) - n <= b:
    print(a * i)
else:
    num1 = ((a + b)* i) - n
    num2 = a * i
    num3 = num1 - b
    print(num2 - num3)

Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
INF = 1000000000
count = 0
def merge(A, left, mid, right):
  L = A[left:mid] + [INF]
  R = A[mid:right] + [INF]
  global count
  i, j = 0, 0
  for k in range(left, right):
    if L[i] <= R[j]:
      A[k] = L[i]
      i += 1
      count += 1
    else:
      A[k] = R[j]
      j += 1
      count += 1

def mergeSort(A, left, right):
  if left + 1 < right:
    mid = int((left+right)/2)
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    merge(A, left, mid, right)
  return

mergeSort(a, 0, n)
print(*a)
print(count)


Measured memory_bytes: 63428
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int n;

int main() {
    cin >> n;
    int t[n],x[n],y[n];
    for(int i=0;i<n;i++){
        cin >> t[i];
        cin >> x[i];
        cin >> y[i];
    }
    int p=0,q=0,r=0;
    bool flag=true;
    for(int i=0;i<n;i++){
        int temp=abs(x[i]-p)+abs(y[i]-q);
        if (temp<=t[i]-r and (t[i]-r-temp)%2==0) p=x[i],q=y[i],r=t[i];
        else{
            flag=false;
            break;
        }
    }
    if (flag==false) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 1408
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[]) throws Exception
    {
        FastReader sc=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt();
        while(t-->0)
        {
           //int d=sc.nextInt(),tt=sc.nextInt(),s=sc.nextInt(),z=0;long ans=0
           String s=sc.next(),st=sc.next();
           if(s.contains(st))
           pw.println(0);
           else{
               int l=s.length(),l1=st.length(), ans=Integer.MAX_VALUE;;
               for(int i=0;i<=l-l1;i++)
               {
                   String str=s.substring(i,i+l1);int c=0;
                   for(int j=0;j<l1;j++)
                   {
                       if(str.charAt(j)!=st.charAt(j))
                       c++;
                   }
                   ans=Math.min(ans,c);
               }
            pw.println(ans);
           }
        }
           pw.close();
    }
}
  

Measured memory_bytes: 33416
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


int main(){
	int n,q;
	cin>>n>>q;
	int a;
	string s;
	string ans="kogakubu10gokan";
	rep(i,n){
		cin>>a>>s; 
		if(a<=q){
			ans=s;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 1e3 + 3;

string kata[maxn];

const int mod = 1e9 + 7;

int dp[maxn][maxn];
int h,w;

int solve(int r, int c) {
	if(r == (h-1) && c == (w-1)){return 1;}
	if(dp[r][c] != -1){return dp[r][c];}
	int ans = 0;
	if(r == (h-1)){
		if(kata[r][c+1] == '.'){
			ans += solve(r, c+1);
			ans %= mod;	
		}
		
	}else if(c == (w-1)){
		if(kata[r+1][c] == '.'){
			ans += solve(r+1, c);
			ans %= mod;	
		}
		
	}else{
		if(kata[r][c+1] == '.'){
			ans += solve(r, c+1);
			ans %= mod;	
		}
		if(kata[r+1][c] == '.'){
			ans += solve(r+1, c);
			ans%= mod;	
		}
		
		
	}
	return dp[r][c] = ans;
}

int main(){
	int i,j;
	scanf("%d %d",&h,&w);

	for(i=0;i<h;i++){
		cin>>kata[i];
	}
	memset(dp, -1, sizeof dp);

	printf("%d\n",solve(0,0));
	// dp[h-1][w-1] = 1;
	// for(i=0;i<h;i++){
	// 	for(j=0;j<w;j++){
	// 		printf("%d ",dp[i][j]);
	// 	}
	// 	printf("\n");
	// }
	return 0;
};

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

ll a,b,c;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> a >> b;
    if( a!=1 && b!=1 ) cout << 1;
    if( a!=2 && b!=2 ) cout << 2;
    if( a!=3 && b!=3 ) cout << 3;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;

int msb(i64 x)
{
	for(int i = 62; i >= 0; --i) {
		if(x & (1LL << i))
			return i;
	}
	return -1;
}

i64 simple(i64 a, i64 lb)
{
	if(lb == 0) return 0;
	if(lb >= a - 1) return 0;

	int msb_lb = msb(lb);
	i64 maxi = (1LL << (msb_lb + 1)) - 1;
	i64 count = min(maxi, a - 1) - lb;
	return count;
}

i64 compute(i64 a, i64 b)
{
	int ma = msb(a);
	int mb = msb(b);
	//printf("msb: %d %d\n", ma, mb);

	if(ma == mb) {
		if(ma == -1) return 0;
		return compute(a ^ (1LL << ma), b ^ (1LL << mb));
	}

	i64 lb = b ^ (1LL << mb);

	i64 s = 0;

	// a .. 9999
	s += (1LL << mb) - max(lb + 1, a);
	//printf("a .. 9999 -> %lld - %lld\n", (1LL << mb), max(lb + 1, a));

	// (lb+1) .. (a-1)
	s += simple(a, lb);
	//printf("simple %lld %lld -> %lld\n", a, lb, simple(a, lb));

	return s;
}

int main()
{
	i64 a, b;
	scanf("%lld%lld", &a, &b);
	i64 ans = b - a + 1 + compute(a, b);
	printf("%lld\n", ans);
	return 0;
}

/* waffle */


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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}

template<class T>
void print_array(T a[],int n){
  REP(n-1)cerr<<a[i]<<",";
  cerr<<a[n-1]<<endl;
}

int N,K;
ll X[100000];
ll m[100001],p[100001];
int m_n,p_n;

int main(){
  cin>>N>>K;
  REP(N)cin>>X[i];
  sort(X,X+N);
  int s = lower_bound(X,X+N,0)-X;
  m_n=s+1;
  p_n=N-s+1;
  for (int i = 0; i < s; i++) {
    m[i+1]=-X[i];
  }
  sort(m,m+s+1);
  for (int i = s; i < N; i++) {
    p[i-s+1]=X[i];
  }
  ll ans=LLONG_MAX;
  print_array(m,m_n);
  print_array(p,p_n);
  for (int i = min(K,s); i >= max(0,K-p_n+1); i--) {
    ll tmp=min(m[i]*2+p[K-i],m[i]+p[K-i]*2);
    cerr<<i<<":"<<tmp<<endl;
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
import sys
from collections import Counter

read = sys.stdin.read


# 最小素因数を求める（エラトステネスの篩の亜種？）
def min_factor(n):
    sieve = list(range(n + 1))
    sieve[2::2] = [2] * (n // 2)
    for i in range(3, int(n ** 0.5) + 2, 2):
        if sieve[i] == i:
            sieve[i * i::2 * i] = [i] * ((n - i * i - 1) // (2 * i) + 1)
    return sieve


# 素因数分解
def prime_factorize(n):
    a = []
    while n != 1:
        b = table[n]
        a.append(b)
        n //= b
    return a


N, *A = map(int, read().split())
mod = 10 ** 9 + 7

table = min_factor(10 ** 6)
dic = {}

for i in A:
    if i == 1:
        continue

    for key, value in Counter(prime_factorize(i)).items():
        # print(key, value)
        if dic.get(key):
            if dic[key] < value:
                dic[key] = value
        else:
            dic[key] = value


lcm = 1
for i, j in dic.items():
    lcm *= pow(i, j, mod)
    lcm %= mod

answer = sum(lcm * pow(i, mod - 2, mod) for i in A) % mod
print(answer)


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

#define INF 1e15
#define rep(i, n) for (i = 0; i < n; i++)

ll d[50][50], col[505][505], sum[3][50];
int main() {
  ll n, c, ans = INF, i, j, k, val;
  cin >> n >> c;
  rep(i, c) {
    rep(j, c) { cin >> d[i][j]; }
  }
  rep(i, n) {
    rep(j, n) {
      cin >> col[i][j];
      col[i][j]--;
    }
  }
  rep(i, n) {
    rep(j, n) {
      val = (i + j) % 3;
      rep(k, c) { sum[val][k] += d[col[i][j]][k]; }
    }
  }
  rep(i, c) {
    rep(j, c) {
      rep(k, c) {
        if (i != j && j != k && i != k)
          ans = min(ans, sum[0][i] + sum[1][j] + sum[2][k]);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5552
import Data.Int

solve :: [Int64] -> Int64
solve rest =
    if f_ then s_ else s_ - m_ - m_
    where 
        func a (s,m,f) = 
            (s + a_, min m a_, (0 <= a) == f)
            where
                a_ = abs a
        (s_,m_,f_) = foldr func (0, maxBound,True) rest

main = interact $ show.solve.tail.map read.words

Measured memory_bytes: 79228
import java.util.*;
//import java.lang.Math;
public class Main{
    public static boolean reach[][]=new boolean[50][50];
    public static int W;
    public static int H;
    public static int S[][]=new int[50][50];
    public static void dfs(int h,int w){
        if(h<0 || h>=H || w<0 || w>=W) return;
        if(reach[h][w]) return;
        if(S[h][w]==0) return;
        reach[h][w]=true;
        dfs(h,w+1);
        dfs(h,w-1);
        dfs(h+1,w);
        dfs(h-1,w);
        dfs(h+1,w+1);
        dfs(h+1,w-1);
        dfs(h-1,w-1);
        dfs(h-1,w+1);
    }
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            W=sc.nextInt();
            H=sc.nextInt();
            for(int i=0;i<H;i++) for(int j=0;j<W;j++) reach[i][j]=false;
            if(H+W==0) break;
            for(int i=0;i<H;i++) for(int j=0;j<W;j++) S[i][j]=sc.nextInt();
            for(int i=0;i<50;i++) for(int j=0;j<50;j++) if(i>=H || j>=W) S[i][j]=0;
            int ans=0;
            for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(!reach[i][j]) if(S[i][j]==1) {
                dfs(i,j);
                ans++;
            }
            System.out.println(ans);
        }
    }
}


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

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

Measured memory_bytes: 3636
#!/usr/bin/env python3
#ABC140 E
#類題 AGC5 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

lst = LI()
if lst.count(1) == 1:
    if lst.count(7) == 1:
        if lst.count(9) == 1:
            if lst.count(4) == 1:
                print('YES')
                quit()
print('NO')



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

int calc(string s,string op){
  int ans = s.at(0) - '0';
  if (op.at(0) == '+') ans += s.at(1) - '0';
  else ans -= s.at(1) - '0';
  if (op.at(1) == '+') ans += s.at(2) - '0';
  else ans -= s.at(2) - '0';
  if (op.at(2) == '+') ans += s.at(3) - '0';
  else ans -= s.at(3) - '0';
  return ans;
}

string solve(string s,string op,int n){
  if (n==3){
    int buf = calc(s,op);
    if (buf == 7){
      string buf = "";
      string anss = buf+s.at(0)+op.at(0)+s.at(1)+op.at(1)+s.at(2)+op.at(2)+s.at(3);
      return anss;
    }else return "";
  }
  op.at(n) = '+';
  string ans1 = solve(s,op,n+1);
  op.at(n) = '-';
  string ans2 = solve(s,op,n+1);
  if (ans1 != "") return ans1;
  else return ans2;
}

int main() {
  string s; cin >>s;
  int a,b,c,d;
  a = s.at(0); b = s.at(1); c = s.at(2); d = s.at(3);
  string op = "...";
  string ans = solve(s,op,0);
  cout <<ans <<"=7" <<endl;
}


Measured memory_bytes: 256