akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================
//using系

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
using kaage = priority_queue<int, vector<int>, greater<int>>;

// ========================================================================
//define系

//#define int long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)

// ========================================================================


ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll mch(ll n) {
	if (n == 1) return 1;
	else return n * mch(n - 1);
}
//1から整数nまでの階乗を出す(INFで割っていない)
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定
ll modpow(ll a, ll n, ll mod) {
	ll hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return hi;
}
//いろいろやります（ただの前座）
ll mg(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}
//割り算の10^9+7等対策で逆元を出します 




// ========================================================================


/*signed*/int main() {
	ll n; cin >> n;
	vl a(n);
	ll cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] != i + 1) cnt++;
	}
	if (cnt == 0 || cnt == 2) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a": " << a << endl;
#define mst(a, b) memset(a, b, sizeof(a))
inline int lowbit(int x) { return x & -x; }
typedef long long LL;
const int N = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int dp[N];
int h[N];

int main() {
#ifdef purple_bro
    freopen("in.txt","r",stdin);
#endif
    int n, k;

    scanf("%d%d", &n, &k);

    for (int i = 1; i <= n; i++)
        scanf("%d", &h[i]);

    mst(dp, 0x3f);
    dp[n] = 0;

    for (int i = n - 1; i >= 1; i--) {
        for (int j = 1; i + j <= n && j <= k; j++)
            dp[i] = min(dp[i], abs(h[i] - h[i + j]) + dp[i + j]);
    }

    printf("%d\n", dp[1]);

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> ss(h);
  rep(i, h) cin >> ss[i];
  vector<vector<int>> sumv(h, vector<int>(w));

  rep(i, h) {
    vector<int> done(w);
    rep(j, w) {
      if (ss[i][j] == '#') continue;
      if (done[j] == 1) continue;
      int seq = 0;
      while (j+seq < w) {
        if (ss[i][j+seq] == '#') break;
        seq++;
      }
      rep(k, seq) {
        sumv[i][j+k] += seq;
        done[j+k] = 1;
      }
    }
  }
  rep(j, w) {
    vector<int> done(h);
    rep(i, h) {
      if (ss[i][j] == '#') continue;
      if (done[i] == 1) continue;

      int seq = 0;
      while (i+seq < h) {
        if (ss[i+seq][j] == '#') break;
        seq++;
      }

      rep(k, seq) {
        sumv[i+k][j] += seq;
        done[i+k] = 1;
      }
    }
  }

  int ans = 0; 
  rep(i, h) {
    rep(j, w) {
      ans = max(ans, sumv[i][j]-1);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 20096
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
Q_list = []
for i in range(Q):
  Q_list.append(list(map(int, input().split()))) 

my_list = list(range(1,M+1))
x = combinations_with_replacement(my_list, N)
high_score = 0
for i in x:
  score = 0
  for q in Q_list:
    if i[q[1]-1] - i[q[0]-1] == q[2]:
      score += q[3]
  high_score = max(high_score, score)
      
print(high_score)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    string s;   cin >> s;
    ll n=s.size();
    ll res = n*(n-1)/2;
    map<char, ll> mp;
    rep(i, n) mp[s[i]] += 1;
    for(auto x: mp) res -= x.second*(x.second-1)/2;
    cout << res+1 << endl;
}


Measured memory_bytes: 3704
#include <iostream>
#include <algorithm>
#include <cmath>
#define zeinuki(x, y) ceil((x) * 100.0 / (100.0 + (y)))
#define zeikomi(x, y) floor((x) * (100.0 + (y)) / 100.0)
using namespace std;

int main()
{
  while(1){
    double x, y, s;
    cin >> x >> y >> s;
    if(x == 0 && y == 0 && s == 0){
      break;
    }else{
      double ans = 0;
      for(double i = 1; i < s / 2.0 + 1; i++){
        double a = zeinuki(i, x);
        double b = zeinuki(s - i, x);
        if(zeikomi(a, x) + zeikomi(b, x) == s)
          ans = max(ans, zeikomi(a, y) + zeikomi(b, y));
      }
      cout << ans << endl;
    }
  }
}

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

using ll = long long;

#define for_(i, a, b) for(int i = (a);i < (b);++i)
#define rfor_(i, a, b) for(int i = (b)-1;i >= (a);--i)
#define rep(i, n) for_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

int N;
int p, a, l, t;

int main() {
  cin.tie(0);cout.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin>>N;
  cin>>p;
  l = 1;
  rep(i, N-1) {
  	cin>>a;
  	if(p==a)l++;
  	else {
  		t += l/2;
  		l = 1;
  		p = a;
  	}
  }
  t += l/2;
  
  cout<<t<<endl;
  
  return 0;
}


Measured memory_bytes: 384
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int N; cin >> N;
    vector<int> v(N);
    rep(i,0,N) cin >> v[i], v[i]--;

    int ans = 0;
    rep(i,0,N) {
        int to = v[i];
        if(v[to] == i) ans++;
    }
    cout << ans / 2 << endl;
    return 0;
}


Measured memory_bytes: 1024
from sys import stdin


def main():

    K, X = [int(x) for x in stdin.readline().rstrip().split()]

    a = X-(K-1)
    b = X+(K-1)

    if a < -1000000:
        a = -1000000

    if b > 1000000:
        b = 1000000

    # print(a, b)
    c = list(range(a, b+1))

    # print(c)
    print(" ".join(map(str, c)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	char c[4];
	cin >> c[0] >> c[1] >> c[2] >> c[3];

	if ((c[0] == c[1] && c[1] == c[2]) || (c[1] == c[2] && c[2] == c[3]))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

bool getbit(long long x, int pos) {
    return (x >> pos) & 1;
}

int binketa(long long x) {
    int cnt = 0;
    while (x > 0) {
        x >>= 1;
        cnt++;
    }
    cnt--;
    if (cnt == -1)
        cnt = 0;

    return cnt;
}


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

    int maxketa = binketa(k);

    long long maxx = 0;
    for (int top = 0; top < maxketa; top++) {
        long long sumx = 0;
        for (int i = 0; i < n; i++) {
            if (binketa(a[i]) <= top)
                sumx += b[i];
        }
        maxx = max(maxx, sumx);
    }

    vector<int> onepos;
    for (int i = maxketa; i >= 0; i--) {
        if (getbit(k, i))
            onepos.push_back(i);
    }

    for (auto pos : onepos) {
        long long sumx = 0;
        long long kousei = k & ~((1 << pos) - 1);
        kousei &= ~(1 << pos);
        for (int i = 0; i < n; i++) {
            long long tmp = a[i] & ~((1 << pos) - 1);
            if((tmp | kousei) != kousei)
                continue;

            sumx += b[i];
        }
        maxx = max(maxx, sumx);
    }
    long long sumx = 0;
    for (int i = 0; i < n; i++) {
        if ((k | a[i]) != k)
            continue;
        sumx += b[i];
    }
    maxx = max(maxx, sumx);

    cout << maxx << endl;


    // 一番上がmaxketaの場合
    return 0;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> numList = new ArrayList<Integer>();
        while(sc.hasNext()){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a == 0 && b == 0){
                break;
            }
            numList.add(a);
            numList.add(b);
        }
        for(int i = 0; i < numList.size() / 2; i++){
            for(int j = 0; j < numList.get(i * 2); j++){
                for(int k = 0; k < numList.get(i * 2 + 1); k++){
                    if((j + k) % 2 == 0){
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 34992
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int N;
ll W, w[105], v[105];
vector<ll> x[5];

int main(void) {
  cin >> N >> W;
  rep(i, 0, N) cin >> w[i] >> v[i];
  
  ll w0 = w[0];
  
  rep(i, 0, N) x[w[i]-w0].pb(v[i]);
  
  sort(all(x[0]), greater<ll>());
  sort(all(x[1]), greater<ll>());
  sort(all(x[2]), greater<ll>());
  sort(all(x[3]), greater<ll>());
  
  ll ans = 0;
  for (int A=0; A<=sz(x[0]); A++) for (int B=0; B<=sz(x[1]); B++) for (int C=0; C<=sz(x[2]); C++) for (int D=0; D<=sz(x[3]);  D++) {
    if (A*w0+B*(w0+1)+C*(w0+2)+D*(w0+3)>W) continue;
    ll sum = 0;
    for (int i=0; i<A; i++) sum += x[0][i];
    for (int i=0; i<B; i++) sum += x[1][i];
    for (int i=0; i<C; i++) sum += x[2][i];
    for (int i=0; i<D; i++) sum += x[3][i];
    ans = max(ans, sum);
  }
  
  cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	std::vector<char> bt;
	std::string buf;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

	
#if INPUT_FROM_FILE
	while(std::getline(ifs, buf)){
#else
	while(std::getline(std::cin, buf)){
#endif
		std::istringstream stream(buf);

		std::getline(stream, buf, ',');
		std::getline(stream, buf, ',');

		if(buf == "A"){
			bt.push_back('A');
		}
		else if(buf == "B"){
			bt.push_back('B');
		}
		else if(buf == "O"){
			bt.push_back('O');
		}
		else{
			bt.push_back('C');
		}
	}
	std::cout << std::count(bt.begin(), bt.end(), 'A') << std::endl;
	std::cout << std::count(bt.begin(), bt.end(), 'B') << std::endl;
	std::cout << std::count(bt.begin(), bt.end(), 'C') << std::endl;
	std::cout << std::count(bt.begin(), bt.end(), 'O') << std::endl;
	return 0;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

ll solve(ll n){
	if(n == 1){
		return 1;
	}
	else{
		return 2 * solve(n/2) + 1;
	}
}


int main(){
	ll h;cin>>h;
	cout << solve(h) << endl;
	return 0;
}

Measured memory_bytes: 256
import scala.collection.mutable._

object Main {
  def output(kind: String, cards: Map[String, _ <: scala.collection.mutable.Seq[Int]]): Unit = {
    for(i <- (1 to 13) diff cards(kind)) {
      println(s"${kind} ${i}")
    }
  }

  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)
    val cards = Map(
      "S" -> ListBuffer[Int](),
      "H" -> ListBuffer[Int](),
      "C" -> ListBuffer[Int](),
      "D" -> ListBuffer[Int]()
    )

    val n = scanner.nextInt
    for(_ <- 1 to n) {
      cards(scanner.next) += scanner.nextInt
    }

    output("S", cards)
    output("H", cards)
    output("C", cards)
    output("D", cards)
  }
}


Measured memory_bytes: 45196
N,K = map(int,input().split())
A = list(map(lambda x: int(x) -1,input().split()))
gone = [-1]*N
tele = [0]*N
to = 0
cnt = 0
if  N < K:
    while(1):
        tele[cnt] = to
        gone[to] = cnt
        cnt += 1
        to = A[to]
        if gone[to] > 0:
            break

    print(tele[(K-(gone[to]))%(cnt-gone[to]) + gone[to]] + 1) 
else:
    for i in range(K):
        to = A[to]
    print(to + 1)

Measured memory_bytes: 32352
#include "bits/stdc++.h"
using namespace std;


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

	vector<vector<string>> lun;
	lun.push_back({ "1", "2", "3", "4", "5", "6", "7", "8", "9" });
	int cnt = 9;
	while (true) {
		lun.push_back({});
		int num = lun.size();
		for (auto ele : lun.at(num - 2)) {
			char last = ele[ele.size() - 1];
			if (last == '0') {
				lun.at(num - 1).push_back(ele + '0');
				lun.at(num - 1).push_back(ele + '1');
			} else if (last == '9') {
				lun.at(num - 1).push_back(ele + '8');
				lun.at(num - 1).push_back(ele + '9');
			} else {
				int last_int = last - '0';
				lun.at(num - 1).push_back(ele + to_string(last_int - 1));
				lun.at(num - 1).push_back(ele + to_string(last_int));
				lun.at(num - 1).push_back(ele + to_string(last_int + 1));
			}
		}
		cnt += lun.at(num - 1).size();
		if (cnt >= 100000) {
			break;
		}
	}

	vector<string> ans;
	for (auto lun_ele : lun) {
		for (auto lun_ele_ele : lun_ele) {
			ans.push_back(lun_ele_ele);
		}
	}

	cout << ans.at(k - 1) << endl;

}



Measured memory_bytes: 14568
#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
using namespace std;
string val;
int ct[26],ans=0,vis[26],n;
int main() { 
	cin >>n>> val;
	for (int i = 0; i < val.size(); i++) { ct[val[i] - 'a']++; }
	for (int i = 0; i < val.size(); i++) {
		vis[val[i] - 'a']++; ct[val[i] - 'a']--;
		int cv = 0;
		for (int j = 0; j < 26; j++) {
			if (ct[j] > 0 && vis[j] > 0)cv++;
		}
		ans = max(ans, cv);
	}
	cout << ans << endl;
	return 0; 
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double dl;
#define lp1(i,n) for(int i=0;i<n;i++)
#define lp2(i,n) for(int i=1;i<=n;i++)
#define pi cosa(-1)
ll lcm(ll a,ll b)
{
    return a/__gcd(a,b)*b;
}
ll gcd(ll a,ll b)
{
	while(b ^= a ^= b ^= a = a % b);
	return a;
}
std::string s;
void cin_space()
{

    std::getline(std::cin, s);
}
void sortstring(string &str)
{
   sort(str.begin(), str.end());
}
bool check_prime(ll n)
{
    ll q=sqrt(n)+1;
    for(int i=2;i<q;i++)
        if(n%i==0)
            return 0;
    return 1;
}
ll ceil(ll n,ll k){
    return (n+k-1)/k;
}
#define i64 long long
i64 M;
i64 F(i64 N,i64 P)
{
	if(P==0) return 1;
	if(P%2==0)
	{
		i64 ret=F(N,P/2);
		return ((ret%M)*(ret%M))%M;
	}
	else return ((N%M)*(F(N,P-1)%M))%M;

}
ll m;
ll bigmod(ll n,ll p)
{
    if(p==0)
        return 1;
    if(p%2==0)
    {
        ll ret=bigmod(n,p/2);
        return ((ret*m)*(ret*m))%m;
    }
    else
        return ((n%m)*(bigmod(n,p-1)))%m;
}
void solution()
{
    ll n;
    double sum=0.0,x;
    string s;
    cin>>n;
    map<string,int>mp;
    for(int i=1;i<=n;i++){
        cin>>x>>s;
        if(s=="JPY"){
            sum+=x;
        }
        else
        {
            sum+=380000.0*x;
        }

    }
    printf("%lf\n",sum);
    //cout<<sum<<endl;
}

int main()
{   /*ll t;
    cin>>t;
    while(t--){*/
        solution();
    //}

    return 0;
}


Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<ll> segt,h,a;
map<ll,ll> mp;
void update(ll idx,ll b,ll e,ll pos,ll val){
  if(b == e){
    segt[idx] = val;
    return;
  }
  ll mid = (b+e)/2;
  if(pos <= mid) update(2*idx,b,mid,pos,val);
  else update(2*idx+1,mid+1,e,pos,val);
  segt[idx] = max(segt[2*idx],segt[2*idx+1]);
}
ll query(ll idx,ll b,ll e,ll l,ll r){
  if(r < b or e < l or r < l) return 0;
  if(l <= b and e <= r) return segt[idx];
  ll mid = (b+e)/2;
  ll s1 = query(2*idx,b,mid,l,min(r,mid));
  ll s2 = query(2*idx+1,mid+1,e,max(l,mid+1),r);
  return max(s1,s2);
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  segt.resize(4*n+5);
  h.resize(n);
  a.resize(n);
  for(ll i = 0; i < n; ++i){
    cin >> h[i];
    mp[h[i]];
  }
  for(ll i = 0; i < n; ++i) cin >> a[i];
  ll idx = 0;
  for(auto& p : mp){
    mp[p.first] = idx++;
  }
  ll ans = 0;
  for(ll i = 0; i < n; ++i){
    ll ai = query(1,0,n-1,0,mp[h[i]]);
    update(1,0,n-1,mp[h[i]],ai+a[i]);
    ans = max(ans,ai+a[i]);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 25104
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

ll N, K;
ll v[55];
ll mem[111][55][55];

ll rec(ll c, ll l, ll r) {
  if(mem[c][l][r]!=-1) return mem[c][l][r];
  if(l>r) return 0;
  if(c>=K) return 0;
  
  ll res=0;
  chmax(res, v[l]+rec(c+1, l+1, r)); //A
  chmax(res, v[r]+rec(c+1, l, r-1)); //B
  chmax(res, rec(c+2, l+1, r)); //A+C
  chmax(res, rec(c+2, l, r-1)); //B+D
  
  return mem[c][l][r]=res;
}

int main(void) {
  cin >> N >> K;
  memset(mem, -1, sizeof(mem));
  for(ll i=0; i<N; i++) cin >> v[i];
  
  pt(rec(0, 0, N-1));
}



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

int main() {

	int N = 0;
	cin >> N;

	vector<int> vec(N,0);

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

	int count = 0;
	bool evenCheck = true;

	for (;;) {
		for (int i = 0; i < N; ++i) {
			if (vec[i] % 2 != 0) {
				evenCheck = false;
			}
			vec[i] = vec[i] / 2;
		}
		if (evenCheck)
			++count;
		else
			break;
	}
	
	cout << count;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1e9+7
#define ll long long
#define clr(c) memset(c,0,sizeof(c))
const int M=2e6+10;
const int N=1e5+10;
const int mod=1e9+7;
using namespace std;
inline ll read()
{
	ll sum=0,b=1; char c=getchar();
	while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
	while(isdigit(c)){sum=sum*10+c-48; c=getchar();}
	return b*sum;
}
ll n,m,b,k;
ll r1,r2,c1,c2;
ll f[M+10],inv[M+10],Inv[M+10];
int main()	
{	
	ll i,j;
	r1=read(),c1=read(),r2=read(),c2=read();
	f[1]=1; inv[1]=Inv[1]=Inv[0]=1;
	for(i=2;i<=M;i++){
		f[i]=f[i-1]*i%mod;
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	}
	for(i=2;i<=M;i++){
		Inv[i]=Inv[i-1]*inv[i]%mod;
	}
	ll ans=0; 
	for(i=c1;i<=c2;i++)
	{
		ans+=f[r2+i+1]*Inv[i+1]%mod*Inv[r2]%mod;
		ans-=f[r1+i]*Inv[i+1]%mod*Inv[r1-1]%mod;
		ans=(ans%mod+mod)%mod;
	}
	
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 47104
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    int a,b;
    cin>>a>>b;
    string x;
    cin>>x;
    int ok=1;
    for(int i=1;i<=a;++i)
    {
        char c=x[i-1];
        if(!(c>='0'&&c<='9'))
        {
            ok=0;
        }
    }
    if(x[a]!='-')ok=0;
    for(int i=a+1;i<=a+b;++i)
    {
         char c=x[i];
        if(!(c>='0'&&c<='9'))
        {
            ok=0;
        }       
    }
    puts(ok?"Yes":"No");
}





Measured memory_bytes: 256
### main

str = gets.strip
len = str.length

n = 0
k = 0

while k < len
  k0 = str.index('O', k)
  break if k0.nil?

  k1 = k0 + 1
  while str[k1] == 'O'
    k1 += 1
  end

  n0 = k1 - k0

  if k0 >= n0 && (str[k0 - n0, n0] == 'J' * n0) && (str[k1, n0] == 'I' * n0)
    n = n0 if n < n0
    k = k1 + n0
  else
    k = k1
  end
end

puts n

Measured memory_bytes: 9668
#include <stdio.h>
#include <string.h>


int main(){
	char a[101],b[101],c[201];
	int i,j=0,count=0;
	scanf("%s\n%s",&a,&b);
	for(i=0;i<strlen(a);i++){
		c[i]=a[i];
	}
	for(i=0;i<strlen(a);i++){
		c[i+strlen(a)]=a[i];
	}
	
	if(strstr(c,b)!=NULL)printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	int n,f=0;
	cin>>n;
	for(int i=0;i<=n/4;i++)
		for(int j=0;j<=n/7;j++)
			if(i*4+j*7==n){
				f=1;break;
			}
	if(f) cout<<"Yes";
	else  cout<<"No";
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val shift = (-1 .. 1).flatMap{x -> (-1 .. 1).map{y -> Block(x, y)}}
    loop {
        val (h, n) = readLine()!!.trim().split(' ').map(String::toInt)
        if (h == 0 && n == 0) return
        val state = List(h){readBlock()}
        val blocks = List(n){List(2){readBlock()}.filter{it.isNotEmpty()}}
        val results = blocks.fold(listOf(state)) { states, block ->
            shift.map { db ->
                block.map { it.map(db::plus) }
            }.filter { it.all{it.all{it.x in 0..1 && it.y in 0..1 }}}.flatMap{b -> states.map{it.dropBlock(b)}}
        }
        println(((state.sumBy { it.size }) + blocks.sumBy { it.sumBy { it.size } } - results.map{it.sumBy { it.size }}.min()!!) shr 2)
    }
}
inline fun loop(func: (loopCount: Int) -> Unit): Unit {
    var count = 0
    while (true) {
        func(count++)
    }
}
data class Block(val x: Int, val y: Int) {
    operator fun plus(that: Block): Block = Block(x + that.x, y + that.y)
}
fun readBlock(): List<Block> {
    val first = readLine()!!.trim()
    val second = readLine()!!.trim()
    return listOf(first, second).withIndex().flatMap { (x, line) ->
        line.withIndex().mapNotNull{(y, char) ->
            when(char) {
                '#' -> Block(x, y)
                else -> null
            }
        }
    }
}

fun List<List<Block>>.dropBlock(blocks: List<List<Block>>): List<List<Block>> {
    for (h in indices.reversed()) {
        if (blocks.indices.any{i -> i + h in indices && blocks[i].any{it in this[i + h]}}) {
            return merge(blocks, h + 1)
        }
    }
    return merge(blocks, 0)
}
fun List<List<Block>>.merge(blocks: List<List<Block>>, bottom: Int): List<List<Block>> {
    val result = toMutableList()
    for (i in blocks.indices) {
        if (i + bottom in result.indices) {
            result[i + bottom] += blocks[i]
        }else {
            result.add(i + bottom, blocks[i])
        }
    }
    return result.filterNot{ it.size == 4 }
}


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

typedef struct node {
	int val;
} node;

typedef struct {
	bool operator()(node &a, node &b) {
		return a.val < b.val;
	}
} comparison;


typedef long long int lli;

typedef pair<int, int> pii;

typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<lli> vlli;

typedef unordered_map<int, int> umapii;
typedef unordered_map<char, pii> umapcpii;
typedef unordered_map<char, int> umapci;
typedef unordered_map<char, lli> umapclli;
typedef unordered_map<lli, lli> umapllilli;
typedef unordered_map<string, int> umapsi;
typedef unordered_map<string, lli> umapslli;
typedef unordered_map<string, pii> umapspii;

typedef unordered_set<int> usti;
typedef unordered_set<char> ustc;
typedef unordered_set<string> usts;
typedef unordered_set<lli> ustlli;

typedef priority_queue<int> max_heapi;
typedef priority_queue<pii> max_heapii;
typedef priority_queue<lli> max_heaplli;
typedef priority_queue<string> max_heaps;
typedef priority_queue<vi> max_heapvi;

typedef priority_queue<int, vector<int>, greater<int> > min_heapi;
typedef priority_queue<pii, vector<pii>, greater<pii> > min_heapii;
typedef priority_queue<vi, vector<vi>, greater<vi> > min_heapvi;

typedef priority_queue<node, vector<node>, comparison> heap_node;
// change comparison struct for min_heap or max_heap for node


typedef vector<int> edgesi;
typedef vector<edgesi> graphi;

typedef vector<pii> edgespii;
typedef vector<edgespii> graphpii;


vector<vector<int> > delta4 = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
vector<vector<int> > delta8 = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {-1, -1}, {1, -1}, {-1, 1}};


static inline string get_substr(string &a, int &st, int &en) {
	return a.substr(st, en-st+1);
}

void add_element_count_map(umapii &umap, int &a) {
	if (umap.count(a) == 0)
		umap[a] = 1;
	else
		umap[a]++;
}

// static inline convertString(pii &a) {
	// return to_string(a.first) + "_" + to_string(a.second);
// }


static inline bool check_double_equal(double &a, double &b) {
	return abs(a - b) <= 1e-6;
}

// static inline count_number_of_element_sorted_arr(vector<T> &a, T &b) {
	// return upper_bound(a.begin(), a.end(), b) - lower_bound(a.begin(), a.end(), b);
// }


int main(void) {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	lli a, b, n, k, x;
	cin>>a>>b>>n;

	for (k = n/b+1; k >= 0; k--) {
		if (k*b-1 <= n)
			break;
	}
	if (k == 0)
		x = n;
	else
		x = k*b - 1;

	cout<<((a * x)/b - a *(x/b))<<"\n";
	
	return 0;
}	


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


int main() {
  int n;
  cin >> n;
  vector<int>a(n),b(n);
  int ans=n;
  rep(i,n){
    cin>>a.at(i)>>b.at(i);
    ans=ans+b.at(i)-a.at(i);
  }
  
    cout<<ans<<endl;
  
}




Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var x = next();
  return x >= 30 ? "Yes" : "No";
}

Measured memory_bytes: 29524
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
VI G[200011];
int A[200011];

int ans[200011];
int lis[200011];
int INF;

void dfs(int v, int p) {
    int k = lower_bound(lis, lis+N, A[v]) - lis;


    int bk = lis[k];
    lis[k] = A[v];
    ans[v] = lower_bound(lis, lis+N, INF) - lis;
    EACH (e, G[v]) if (*e != p) dfs(*e, v);

    lis[k] = bk;
}

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);
    REP (i, N-1) {
	int x, y;
	scanf("%d%d", &x, &y);
	x--; y--;
	G[x].push_back(y);
	G[y].push_back(x);
    }
    memset(lis, 0x3f, sizeof lis);
    INF = lis[0];
    dfs(0, 0);
    REP (i, N) printf("%d\n", ans[i]);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 31248
using System;
using System.Linq;

namespace Csharp
{
    class Program
    {

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] L = Console.ReadLine().Split(" ").Select(s => int.Parse(s)).ToArray();
            int ans = 0;
            Array.Sort(L);
            for(int i = 0; i < N - 2; i++)
            {
                for(int j = i + 1; j < N-1; j++)
                {
                    if (L[i] >= L[j]) goto idou;
                    int trijouken = L[i] + L[j];
                    for(int k = j + 1; k < N; k++)
                    {
                        if (L[j] < L[k] && (trijouken - L[k]) > 0)
                        {
                            ans++;
                       }
                    }
                    idou:;
                }
            }
            Console.WriteLine(ans);
           


            
        }
        
    }
}


Measured memory_bytes: 28300
def solve():
    n = int(input())
    p = list(map(int, input().split()))
    l = range(1,n+1)
    count = 0
    for i, j in zip(p, l):
        if i != j:
            count += 1
    print('YNEOS'[count>2::2])

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)] # a_0...a_(M-1)

def fib(x): # フィボナッチ数列
    a, b = 1, 1
    if x == 0:
        return a
    elif x == 1:
        return b
    else:
        for i in range(x-1):
            a, b = b, a + b
        return b
"""
# 再帰だとTLEとかREとかになるよ
def fib(x): # フィボナッチ数列
    if x == 0:
        return(1)
    elif x == 1:
        return(1)
    else:
        return(f(x-1) + f(x-2))
"""

ans = 0
MOD = 10**9 + 7

if M == 0:
    ans += fib(N) % MOD
    print(ans)
else:
    ans += fib((a[0]-1) - 0) % MOD # 0段目からa_0-1段目に上る(その後a_0段目を飛ばしてa_0+1段目に上る)
    for i in range(1, M): # iは1からM-1
        stair = (a[i] - 1) - (a[i-1] + 1) # 登る段数
        if stair >= 0:
            ans *= fib(stair) % MOD # a_(i-1)+1段目からa_i-1段目に上る(その後a_i段目を飛ばしてa_i+1段目に上る)
        else:
            ans = 0
            break
    ans *= fib(N - (a[M-1] + 1)) % MOD # a_M-1段目からN段目に上る
    print(ans % MOD)


Measured memory_bytes: 7080
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
using namespace std;
int n;
double x[10];
char u[10][4];
int main() {
	scanf("%d", &n);
	double ans = 0.0;
	for (int i = 0; i < n; i++) {
		scanf("%lf %s", &x[i], u[i]);
		if (u[i][0] == 'J') ans += x[i];
		else ans += x[i] * 380000.0;
	}
	printf("%.9lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
import numpy
import math 
s = input()
s_dic = {i: e for (i,e) in enumerate(list(s))}

output = numpy.zeros(len(s),dtype=int)
r = 0
l = 0
maxi = max(s_dic.keys())
for i,value in s_dic.items():
    if l == 0 and value == "R":
        r += 1
    elif r == 0 and value == "L":
        l += 1
    elif r == 0 and value == "R":
        output[i-l] += math.ceil(l/2)
        output[i-l-1] += l//2
        l = 0
        r += 1 
    elif l == 0 and value == "L":
        output[i] += r//2
        output[i-1] += math.ceil(r/2)
        r = 0
        l += 1
output[i-l+1] += math.ceil(l/2)
output[i-l] += l//2
ret = " ".join([str(e) for e in output.tolist()])
print(ret)

Measured memory_bytes: 29408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  multiset<int> color;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++){
    auto itr = color.upper_bound(-a[i]);
    if(itr != color.end()) color.erase(color.find(*itr));
    color.insert(-a[i]);
  }
  cout << color.size() << endl;
  return 0;
}

Measured memory_bytes: 8288
#include <iostream>
#include <vector>
#include <string>
using namespace std;
 
int main()
{
	int N;
	int Q;
	string S;
	int flug=0;
	int count=0;
	int s1;
	int s2;
	vector<int> vec;

	cin >> N;
	cin >> Q;
	cin >> S;

	for(int i=0;i<S.size();i++)
	{
		if(S[i]=='A')
		{
			flug = 1;
		}
		else if(S[i]=='C'&&flug==1)
		{
			count = count + 1;
			flug = 0;
		}
		else
		{
			flug = 0;
		}
		vec.push_back(count);
	}

	for(int i=0;i<Q;i++)
	{
		cin >> s1;
		cin >> s2;
		cout << vec[s2-1]-vec[s1-1] << endl;
	}
}

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

int main(){

  int n,i,tmp,cnt=0,flag=1;
  int *a;
  
  scanf("%d",&n);

  a = malloc(sizeof(int)*n);

  for(i=0;i<n;i++)scanf("%d",&a[i]);
  
  while(flag==1){
    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;
	cnt++;
      }
    }
  }

  for(i=0;i<n-1;i++)printf("%d ",a[i]);
  printf("%d\n",a[i]);
  printf("%d\n",cnt);
 
  free(a);
  return 0;
}



Measured memory_bytes: 2048
n = int(input())
ab = []
ans = 0
for i in range(n):
    a,b = map(int,input().split())
    ab.append([a+b,b])
    ans -= b
ab.sort(reverse=True)
for i in range(n):
    if i%2 == 0:
        ans += ab[i][0]
print(ans)


Measured memory_bytes: 58840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int h = 0;
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        h = max(h, a[i]);
        ans += h - a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4024
def fac(num)
  return [0] if num < 2
  ans = Array.new(0)
  tmp = num
  for div in 2..(10**6)
    while tmp % div == 0
      ans.push(div)
      tmp /= div
    end
    break if tmp == 1
  end
  ans.push(tmp) if tmp > 1
  return ans
end

n = gets.to_i

a = fac(n)
fs = Hash.new(0)
a.each{|e| fs[e] += 1}

ans = 0
fs.each do |k,v|
  val = v
  cnt = 1
  while val-cnt >= cnt+1
    val -= cnt
    cnt += 1
    ans += 1
  end
  ans += 1 if val > 0
end
if n > 1
  puts ans
else
  puts 0
end

Measured memory_bytes: 14380
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    vector<int> as(3);
    for (int i = 0; i < 3; i++) {
        cin >> as[i];
    }

    cout << *max_element(as.begin(), as.end()) - *min_element(as.begin(), as.end()) << endl;

    return 0;
}


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

int main(void){
  int n,count[4] = {0},c = 0;
  char s[100];
  cin >> n;
  for(int i = 0; i < n;i ++){
    cin >> s[i];
  }
  for(int i = 0; i < n;i ++){
   switch(s[i]){
     case 'P':
       count[0]++;
       break;
     case 'W':
       count[1]++;
       break;
     case 'G':
       count[2]++;
       break;
     case 'Y':
       count[3]++;
       break;
   }
  }
  for(int i = 0;i < 4;i ++){
    if(count[i] > 0)c++;
  }
  if(c == 3)cout << "Three" << endl;
  else cout << "Four" <<endl;
}


Measured memory_bytes: 256
import heapq
def double(x):
    return int(x) * -1
n, m = map(int, input().split())
A = list(map(double, input().split()))

heapq.heapify(A)

for i in range(m):
  te = heapq.heappop(A)
  heapq.heappush(A,(te*-1//2)*-1)
  
print(sum(A)*-1)



Measured memory_bytes: 14252
#include<stdio.h>
int main(){
    int l, r, d;
    scanf("%d%d%d",&l,&r,&d);
    int ans = 0;
    for(int i = l; i <= r; i++)
        if(i % d == 0)
            ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1708
use std::io::stdin;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let member: u32 = buf.trim().parse().unwrap();

    buf.clear();
    stdin().read_line(&mut buf).unwrap();
    let mut line = buf.split_whitespace();
    let days: u32 = line.next().unwrap().parse().unwrap();
    let last: u32 = line.next().unwrap().parse().unwrap();

    let mut intervals = Vec::new();
    for _ in 0..member{
        let mut buf = String::new();
        stdin().read_line(&mut buf).unwrap();
        let interval:u32 = buf.trim().parse().unwrap();
        intervals.push(interval);
    }

    println!("{}", solve(days, last, intervals));
}

fn solve(days: u32, last: u32, mut intervals: Vec<u32>) -> u32{
    let mut result = 0;
    intervals.sort();

    let mut current_interval = 0;
    let mut temp_counter = 0;
    for interval in intervals{
        if interval == current_interval{
            result += temp_counter;
        } else {
            current_interval = interval;
            temp_counter = (days - 1) / interval + 1;
            result += temp_counter;
        }
    }
    result + last
}

Measured memory_bytes: 4352
#include <algorithm>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

int main()
{
  long long x, y;
  long long cnt = 0;
  long long value;
  scanf("%lld%lld", &x, &y);
  value = x;
  while(value <= y) {
    value = 2 * value;
    cnt++;
  }
  printf("%lld\n", cnt);
  return 0;
}


Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramC
    {
        static void Main()
        {
            int n = NextInt;
            var list = IntList;
            int count = 0, now = 0;

            while (now < n)
            {
                if (list[now] == 0)
                {
                    now++;
                    continue;
                }

                for (int j = now; j < n && list[j] != 0; j++)
                {
                    list[j]--;
                }

                count++;
            }

            System.Console.WriteLine(count);
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


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

typedef long long ll;

const int MOD = 1000000007;
ll fact[200010];
 
// a^b % MOD を計算して返す
ll power(ll a, ll b) {
  if (b == 0) {
    return 1;
  } else {
    ll ans = power(a, b / 2); ans = ans * ans; ans = ans % MOD;
    if (b % 2 == 1) ans = ans * a;
    ans = ans % MOD;
    return ans;
  }
}
 
 // nCr % MOD を計算して返す
ll choose(ll n, ll r) {
  ll ans = fact[n];
  ans = fact[n] * power(fact[r], MOD-2); ans = ans % MOD;
  ans = ans * power((fact[n-r] + MOD) % MOD, MOD-2); ans = ans % MOD;
  return ans;
}

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  fact[0] = 1;
  for (int i = 0; i <= n*m; ++i) {
    fact[i+1] = fact[i]*(i+1)%MOD;
  }
  ll ans = 0;
  for (ll i = 1; i < n; ++i) {
    ans += i * (n-i) * m * m % MOD;
    ans %= MOD;
  }
  for (ll i = 1; i < m; ++i) {
    ans += i * (m-i) * n * n % MOD;
    ans %= MOD;
  }
  ans = ans * choose(n*m-2, k-2) % MOD;
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    if(x==1||x==2||x==3||x==5||x==6||x==9||x==10||x==13||x==17){
        cout << "No" << endl;
    }
    else cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

ll n, m, i;

int main()
{
   // freopen("test.in","r",stdin);

    cin >> n >> m;
    cout << (1LL << m) * (m * 1900 + (n - m) * 100);


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 3005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
ll dp[maxn][maxn];
string s,t;
ll sl,tl;
ll go(ll i,ll j){
    if(i==sl||j==tl) return 0;
    ll &ans=dp[i][j];
    if(ans!=-1) return ans;
    if(s[i]==t[j]) ans=1+go(i+1,j+1);
    else ans=max(go(i,j+1),go(i+1,j));
    return ans;
}
int main()
{
    boost;
    ll i,j,x,y;
    cin>>s>>t;
    sl=s.size();
    tl=t.size();
    SET(dp,-1);
    ll cnt=go(0,0);
    string ans="";
    i=j=0;
    while(cnt>0){
        if(cnt==1&&s[i]==t[j]){
            ans+=s[i];
            cnt--;
        }
        else if(dp[i][j]==dp[i+1][j]) i++;
        else if(dp[i][j]==dp[i][j+1]) j++;
        else if(dp[i][j]==dp[i+1][j+1]+1) {
            cnt--;
            ans+=s[i];
            i++;
            j++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 71040
import math
a, b, h, m = map(int, input().split())

a_theta = (h / 12 + m / 720) * 2 * math.pi
b_theta = m / 60 * 2 * math.pi

a_cos = a * math.cos(a_theta)
a_sin = a * math.sin(a_theta)
b_cos = b * math.cos(b_theta)
b_sin = b * math.sin(b_theta)

print(math.sqrt(math.pow(a_cos - b_cos, 2) + math.pow(a_sin - b_sin, 2)))


Measured memory_bytes: 62460
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main()
{
	long long n,a,b,c;
	while(cin >> n, n)
	{
		vector<long long>  v;
		map<long long,long long> m;

		while(n--)
		{
			cin >> a >> b >> c;
			if(m.insert(pair<long long,long long>(a,b*c)).second)
			{
				v.push_back(a);
			}
			else
			{
				m[a] += b*c;
			}
		}

		bool f=true;
		for(int i=0; i<v.size(); i++)
		{
			if(m[v[i]]>=1000000)
			{
				f=false;
				cout << v[i] << endl;
			}
		}
		if(f) cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n: u32 = read();
    let mut a: Vec<u32> = (0..n).map(|_| read()).collect();
    a.sort_by(|x, y| x.cmp(y).reverse());
    let mut alice = 0;
    let mut bob = 0;
    for (i, &x) in a.iter().enumerate() {
        if i % 2 == 0 {
            alice += x;
        } else {
            bob += x;
        }
    }

    println!("{}", alice - bob);
}

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

using namespace std;
using ll = long long;

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

	int n, k;
	cin >> n >> k;

	cout << (n >= 2*k-1 ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 256