akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <stack>
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <typeinfo>
#include <queue>
#include <set>
#include <sstream>

using namespace std;

#define RSORT(c) sort((c).begin(),(c).end(),std::greater<int>())
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SORT(c) sort((c).begin(),(c).end())

static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
#define MAX 200000
#define SENTINEL 10000000000
typedef long long ll;


void c1(){
  int n;
  cin >> n;
  vector< vector<int> > v;
  vector< vector<int> > m;
  v.resize(2);
  m.resize(2);
  //vector<int> m(2,n);
  int tmp;
  v[0].resize(n);
  v[1].resize(n);
  m[0].resize(n);
  m[1].resize(n);
  REP(i,n){
    cin >> tmp;
    v[0][i] = tmp;
  }
  REP(i,n){
    cin >> tmp;
    v[1][i] = tmp;
  }

  int res = 0;
  m[0][0]= v[0][0];
  FOR(i,1,n){
    m[0][i] = m[0][i-1] + v[0][i];
  }
  m[1][0] = v[1][0] + v[0][0];
  FOR(i,1,n){
    m[1][i] = v[1][i] + max(m[0][i], m[1][i-1]);
  }

  if(n==1){
    cout << v[1][0] + v[0][0] << endl;
  }
  else{  //REP(i,n)
    cout << m[1][n-1] << endl;
  }

  //cout << s << endl;
}



void c2(){

  int n,m;
  cin >> n >> m;
  int li,ri,di;
  vector< vector<int> > h;
  h.resize(m);
  REP(i,m){
    h[i].resize(3);
  }
  REP(i,m){
    cin >> li >> ri >> di;
    h[i][0] = li-1;
    h[i][1] = ri-1;
    h[i][2] = di;
  }
  int li2,ri2,di2,li3,ri3,di3,tmp3;
  REP(i,m){
    li = h[i][0];
    ri = h[i][1];
    REP(j,m){
      if(i==j){
        continue;
      }
      li2 = h[j][0];
      ri2 = h[j][1];
      di2 = h[j][2];
      if(li==li2){
        tmp3 = ri2;
        REP(k,m){
          if(j==k){
            continue;
          }
        }
      }
    }
  }
  
  // REP(i,n){
  //   REP(j,n){
  //     if(i >= j){
  //       continue;
  //     }
  //     REP(k,n){
  //       if(j >= k){
  //         continue;
  //       }
  //       REP(i,m){
          
  //       }
  //     }
  //   }
  // }
  //cout << s << endl;
}

void c3(){
  int s=3;
}



int main(){
  c1();
}


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

using namespace std;
using ll = long long;

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

  int n, m, x;
  cin >> n >> m >> x;

  vector<int> c(n);
  vector<vector<int>> a(n);
  for (int i = 0; i < n; i++) {
    vector<int> aa(m);
    cin >> c[i];
    for (int j = 0; j < m; j++) {
      cin >> aa[j];
    }
    a[i] = aa;
  }

  const int inf = 1e9;
  int ans = inf;
  for (int b = 0; b < (1 << n); b++) {
    vector<int> u(m, 0);
    int sum = 0;
    for (int i = 0; i < n; i++) {
      if (!(b & (1 << i)))
        continue;
      sum += c[i];
      for (int j = 0; j < m; j++) {
        u[j] += a[i][j];
      }
    }
    if (all_of(u.begin(), u.end(), [&](int uu) { return uu >= x; })) {
      ans = min(ans, sum);
    }
  }

  if (ans == inf) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
ll a[200000], b[200000];
priority_queue<pl, vector<pl>> pq;

int main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	rep(i,n) {
		if (b[i] < a[i]) {
			cout << -1 << endl;
			return 0;
		}
		if (b[i] > a[i]) pq.push(pl(b[i], i));
	}
	ll ans = 0;
	bool ok = true;
	while (!pq.empty()) {
		pl t = pq.top(); pq.pop();
		int i1 = (t.second+1)%n;
		int i2 = (t.second-1+n)%n;
		ll z = max(a[t.second]+1,max(b[i1], b[i2]));
		ll s = b[i1] + b[i2];
		ll c = (t.first - z) / s + 1;
		ans += c;
		t.first -= c * s;
		if (t.first < a[t.second]) {
			ok = false;
			break;
		}
		b[t.second] = t.first;
		if (t.first > a[t.second]) {
			pq.push(pl(t.first, t.second));
		}
	}
	if (!ok) cout << -1 << endl;
	else cout << ans << endl;
}

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

bool solve();

int main()
{
	if (solve()) puts("Yes");
	else puts("No");

	return 0;
}

bool solve()
{
	std::string S, T;
	std::cin >> S >> T;
	std::vector<int> table(26, -1), rev_table(26, -1);
	for (int i{}; i < (int)S.size(); i++)
	{
		if (table[S[i] - 'a'] < 0)
		{
			if (rev_table[T[i] - 'a'] >= 0) return false;
			table[S[i] - 'a'] = T[i] - 'a';
			rev_table[T[i] - 'a'] = S[i] - 'a';
		}
		else if (table[S[i] - 'a'] + 'a' != T[i])
			return false;
	}
	return true;
}

Measured memory_bytes: 776
import java.util.Scanner;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int c = s.nextInt();
        int sum = s.nextInt();
        int ans = 0;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                for (int k = 0; k <= c; k++) {
                    if (500 * i + 100 * j + 50 * k == sum) {
                        ans++;
                    }
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21712
import sys
sys.setrecursionlimit(300000)
from collections import Counter

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N = I()
A = LMI()

div = set(A)
cnt = Counter(A)
M = max(A)
ng = [False] * (M + 1)
for a in A:
    n = a * 2
    while n <= M:
        ng[n] = True
        n += a
ans = 0
for a in A:
    if cnt[a] >= 2:
        continue
    if ng[a]:
        continue
    ans += 1

print(ans)

Measured memory_bytes: 152704
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
  string s;
  cin >> s;
  int n = 3;
  int tem = 0;
  vector<int> lan(0);
  for(int l = 0; l < n;){
    int r = 0;
    for(; l + r < n && s[l] == s[l+r]; r++){}
    if(s[l] == 'R'){
      lan.push_back(r);
    }
      l += r;
      r = 0;
  }
  lan.push_back(0);
  cout << *max_element(lan.begin(), lan.end());
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

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

    int n = sc.nextInt();

    int[] x = new int[n];
    for (int i = 0; i < n; i++) {
        x[i] = sc.nextInt();
    }

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (isPrime(x[i])) cnt++;
    }

    System.out.println(cnt);
  }

  public static boolean isPrime(int n) {
      if (n == 1) return false;
      
      for (int i = 2; i <= Math.sqrt(n); i++) {
          if (n % i == 0) return false;
      }
      return true;
  }
}


Measured memory_bytes: 42080
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
signed main(){
	bitset <4000100> b; 
	int n; cin >> n;
	int sum = 0;
	b[0] = 1;
	for (int i=0; i<n; i++){
		int u; cin >> u;
		sum += u;
		b |= (b<<u);
	}
	int ans = (sum+1)>>1;
	while (ans<=sum){
		if (b.test(ans)){
			cout << ans;
			return 0;
		}
		ans++;
	}
	cout << -1;
}



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

using namespace std;

const int max_n = 200222, inf = 1000111222;

int n, u, v;
long long ans;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        ans += 1LL * i * (n - i + 1);
    }
    for (int i = 1; i < n; ++i) {
        scanf("%d%d", &u, &v);
        if (u > v) {
            swap(u, v);
        }
        ans -= 1LL * u * (n - v + 1);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3764
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect


def main():
    N = int(input())
    S, T = input().split()

    ret = ""
    for i in range(N):
        ret += S[i]
        ret += T[i]

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/

using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

map<string, int> memo;
int main() {
	string s, t,u;
	int a, b;
	cin >> s >> t >> a >> b>> u;
	if (s == u) a -= 1;
	if (t == u) b -= 1;
	cout << a <<" "<< b;
	
	return 0;
}









Measured memory_bytes: 256
fn main() {
    let n = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut es = vec![0; n];
    let mut ws = vec![0; n];
    for i in 0..n {
        if i > 0 {
            ws[i] += ws[i - 1];
        }
        if s[i] == 'W' {
            ws[i] += 1;
        }
    }
    for i in (0..n).rev() {
        if i < n - 1 {
            es[i] += es[i + 1];
        }
        if s[i] == 'E' {
            es[i] += 1;
        }
    }
    let mut ans = 1000000000;
    for i in 0..n {
        ans = std::cmp::min(ans, es[i] + ws[i] - 1);
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 10492
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

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

    for(int i = 0; i < s.size(); i++){
        int cnt = 0;
        int idx_s = i;
        int idx_t = 0;
        while(cnt < s.size()){
            if(s[idx_s] == t[idx_t]){
                idx_t++;
                idx_s = (idx_s+1)%s.size();
                cnt++;
            } else {
                break;
            }
        }
        if(cnt == s.size()){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, a[200005];
ll ans;
int main() {
    cin >> n;
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a, a+n, greater<int>());
    
    for (int i=0; i<n-1; i++) ans+=a[(i+1)/2];
    cout << ans;
}

Measured memory_bytes: 4420
#include<iostream>
#include<vector>
#include<string>

using ll = long long;

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

int main(){
    ll n;
    std::cin >> n;
    std::vector<ll> a(n);

    std::cin >> a[0];
    ll g = a[0];
    for(int i = 1; i < n; i++){
        std::cin >> a[i];
        g = gcd(a[i], g);
    }

    // 1つ抜きの最大公約数の最大を求めれば良い
    // まず左からn個の最大公約数
    std::vector<ll> left(n);
    left[0] = a[0];
    for(int i = 1; i < n; i++){
        left[i] = gcd(left[i - 1], a[i]);
    }
    // 右からn個の最大公約数
    std::vector<ll> right(n);
    right[0] = a[n - 1];
    for(int i = 1; i < n; i++){
        right[i] = gcd(right[i - 1], a[n - i - 1]);
    }


    // 1つ抜きの最大公約数の最大値
    // 左端と右端は例外処理
    ll ans = left[n - 1]; // 1つも書き換えない場合
    ans = std::max(ans, left[n - 2]);
    ans = std::max(ans, right[n - 2]);
    for(int i = 1; i < n - 1; i++){
        // i個目を抜く
        ll tmp = gcd(left[i - 1], right[n - i - 2]);
        ans = std::max(ans, tmp);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  string s; cin >> s;
  cout << ((s.length() % 2 == 0) ^ (s.front() == s.back()) ? "Second\n" : "First\n");
  return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int n; cin>>n;
    string x; cin>>x;
    int cnt=0;
    for(int i=0;i<(int)x.size();i++){
		if(x[i]=='R'){
			cnt++;
		}
    }
    int res=0;
    for(int i=0;i<cnt;i++)
		if(x[i]=='W')
			res++;
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

// https://atcoder.jp/contests/agc005/submissions/904878

const int N = 200001;
vector<int> pos(N);
int main() {
    int n;
    cin >> n;
    
    rep(i, n) {
        int tmp;
        cin >> tmp;
        pos[tmp] = i + 1;
    }
    
    vector<int> pr(N + 1), ne(N + 1);
    // posに対して左右にどれだけ延ばせるか
    
    rep(i, n + 1) {
        pr[i] = i - 1; // i - (i - 1) で長さ1
        ne[i] = i + 1;
    }
    // 大きい数から見たとき、長さ1
    
    ll ans = 0;
    for (int i = n; i >= 1; --i) {
        int j = pos[i];
        ans += i * 1LL * (j - pr[j]) * (ne[j] - j);
        // out(j << " " << pr[j] << " " << ne[j]);
        
        // あるposに対しての範囲があり、その範囲内の数は自分より大きいので更新しなくていい
        // 大きい順に見てるから
        // 範囲が1, 5とする
        // 5のprを1に、1のneを5に更新する
        pr[ne[j]] = pr[j];
        ne[pr[j]] = ne[j];
    }
    
    out(ans);
}



Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int dy[] = {-1, 1, 0, 0};
const int dx[] = {0, 0, 1, -1};

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    queue<pair<int, int> > q;
    for(int y=0; y<h; ++y){
        cin >> s[y];
        for(int x=0; x<w; ++x){
            if(s[y][x] == '#')
                q.push(make_pair(y, x));
        }
    }

    int ans = -1;
    while(!q.empty()){
        ++ ans;
        int n = q.size();
        while(--n >= 0){
            int y, x;
            tie(y, x) = q.front();
            q.pop();
            for(int i=0; i<4; ++i){
                int y2 = y + dy[i];
                int x2 = x + dx[i];
                if(0 <= y2 && y2 < h && 0 <= x2 && x2 < w && s[y2][x2] == '.'){
                    s[y2][x2] = '#';
                    q.push(make_pair(y2, x2));
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9488
#include<stdio.h>
int main(void)
{
	int w,a,b,c,d,e,f,g,h;
	scanf("%d",&w);
	while (w!=-1)
	{
		a=1150;
		b=1150+125*(w-10);
		c=1150+1250+140*(w-20);
		d=1150+1250+1400+160*(w-30);
		e=4280-a;
		f=4280-b;
		g=4280-c;
		h=4280-d;
		
		if (w<=10)
		{
			printf("%d\n",e);
		}
		if (10<w && w<=20)
		{
			printf("%d\n",f);
		}
		if (20<w && w<=30)
		{
			printf("%d\n",g);
		}
		if (30<w)
		{
			printf("%d\n",h);
		}
	scanf("%d",&w);
	}
	return 0;
}

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

using namespace std;
void show(vector<int> a);

int main()
{
    int num;//数组数量
   cin>>num;
    vector <int>p[num];
    int opr;cin>>opr;
    while(opr--)
    {
        int oper;
        cin>>oper;
        switch(oper)
        {

            case 0:int number,mag;
            cin>>number>>mag;
            p[number].push_back(mag);
            break;
            case 1:int number1;
            cin>>number1;
            show(p[number1]);
            break;
            case 2:
                int number2;
                cin>>number2;
                if(p[number2].empty()==false)
                p[number2].clear();
                break;
        }

    }
}
void show(vector<int> a)
{
     vector<int>::iterator point;
     if(a.empty()==false)
     {
     for(point=a.begin();point!=a.end();point++)
     {
         vector<int>::iterator point1=point;
         if(++point1==a.end())
            cout<<*point<<endl;
         else
            cout<<*point<<" ";
     }
     }
     else cout<<endl;
}



Measured memory_bytes: 6864
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
typedef long long ll;
#define lowbit(i) (i & (-i))
ll sum[maxn];
int n,m,a[maxn],cnt[maxn];
void update(int x,ll v) {
	for (int i = x; i <= maxn - 10; i += lowbit(i))
		sum[i] += v;
}
ll qry(int x) {
	ll ans = 0;
	for (int i = x; i ; i -= lowbit(i))
		ans += sum[i];
	return ans;
}
int main() {
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) {
		scanf("%d",&a[i]);
		cnt[a[i]]++; 
	} 
	for (int i = 1; i <= n; i++) {
		update(i,1ll * cnt[i] * (cnt[i] - 1) / 2);
	}
	for (int i = 1; i <= n; i++) {
		update(i,-1ll * cnt[a[i]] * (cnt[a[i]] - 1) / 2);
		cnt[a[i]]--;
		update(i,1ll * cnt[a[i]] * (cnt[a[i]] - 1) / 2);
		printf("%lld\n",qry(n));
		update(i,-1ll * cnt[a[i]] * (cnt[a[i]] - 1) / 2);
		cnt[a[i]]++;
		update(i,1ll * cnt[a[i]] * (cnt[a[i]] - 1) / 2);
	}
}

Measured memory_bytes: 13184
#include <stdio.h> 
#include <algorithm> 
#include <iostream> 
using namespace std; 
class Heap{ 
	public: 
	Heap(){ 
		array = new int[2000000]; 
		n = 0; 
		} 
	void insert(int data){ 
		array[n] = data; 
		int tmp = n; 
		while(tmp != 0 && array[tmp] > array[(tmp-1)/2]){ 
			std::swap(array[tmp], array[(tmp-1)/2]); 
			tmp = (tmp-1)/2; 
		} n++; 
	} 
	int extract(){ 
		int ret = array[0]; 
		n--; 
		std::swap(array[0],array[n]); 
		int tmp = 0; 
		while(2*tmp+1 <= n-1){ 
			if(2*tmp+2 <= n-1){ 
				if(array[2*tmp+2] > array[tmp] && array[2*tmp+2] >= array[2*tmp+1]){ 
					std::swap(array[2*tmp+2],array[tmp]); 
					tmp = 2*tmp+2; 
				}else if(array[2*tmp+1] > array[tmp] && array[2*tmp+1] >= array[2*tmp+2]){ 
					std::swap(array[2*tmp+1],array[tmp]); tmp = 2*tmp+1; 
				}else{ break; } 
			}else{ 
				if(array[tmp] < array[2*tmp+1]){ 
					std::swap(array[tmp],array[2*tmp+1]); 
					tmp = 2*tmp+1; 
				}else{ break; } 
			} 
		} return ret; 
	} 
private: 
	int* array; int n; 
}; 
int main(){ 
	int insert_data; 
	char buf[22]; 
	Heap heap; 
	while(true){ 
		fgets(buf,22,stdin); 
		if(buf[2] == 'd') break; 
		if(buf[0] == 'i'){ 
			insert_data = 0; 
			for(int i = 0; buf[i] != '\0';i++)
			{ if(buf[i] >= '0' && buf[i] <= '9')	
				{ 
					insert_data = 10*insert_data + (buf[i] - '0'); 
				} 
			} 
			heap.insert(insert_data); 
		}else{ printf("%d\n",heap.extract()); 
	} 
	}
}


Measured memory_bytes: 7044
//
// Created by 李青坪 on 2018/11/28.
//

#include <cmath>
#include <cstdio>
#include <algorithm>

#define EPSLON 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPSLON)

#define MAXN 10000
#define NIL -1
using namespace std;

// 点
class Point {
public:
    double x;
    double y;

    Point() {}

    Point(double x, double y) : x(x), y(y) {}

    Point operator+(Point a) {
        return Point(x + a.x, y + a.y);
    }

    Point operator-(Point a) {
        return Point(x - a.x, y - a.y);
    }

    Point operator*(double a) {
        return Point(x * a, y * a);
    }

    Point operator/(double a) {
        return Point(x / a, y / a);
    }

    double norm() {
        return x * x + y * y;
    }

    double absVector() {
        return sqrt(norm());
    }

    bool operator==(Point a) const {
        return equals(x, a.x) && equals(y, a.y);
    }
};

typedef Point Vector;

// 线段
class Segment {
public:
    Point a, b;
};

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x * b.y - a.y * b.x;
}

Point projection(Segment s, Point point) {
    Vector base = s.b - s.a;
    double t = dot(point - s.a, base) / base.absVector();
    double r = t / base.absVector();
    Point y = base * r;
    Point x = s.a + y;
    return x;
}

Point reflection(Segment s, Point point){
    return point + (projection(s, point) - point) * 2.0;
}

int n;


int main() {
    Segment s;
    Point p[2];
    scanf("%lf %lf %lf %lf", &p[0].x, &p[0].y, &p[1].x, &p[1].y);
    s.a = p[0];
    s.b = p[1];
    scanf("%d", &n);
    Point point;
    for (int i = 0; i < n; ++i) {
        double x, y;
        scanf("%lf %lf", &x, &y);
        point = Point(x, y);
//        Point re = projection(s, point);
//        printf("%.10f %.10f\n", re.x, re.y);
        Point re = reflection(s, point);
        printf("%.10f %.10f\n", re.x, re.y);
    }
}
/*
0 0 3 4
3
2 5
1 4
0 3

 */


Measured memory_bytes: 2744
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;

int main(){
  int N;
  cin >> N;
  vector<char> S(N);
  rep(i,N) cin >> S[i];
  bool p=false, w=false, g=false, y=false;
  rep(i,N){
    if(S[i]=='P') p=true;
    if(S[i]=='W') w=true;
    if(S[i]=='G') g=true;
    if(S[i]=='Y') y=true;
  }
  if(p+w+g+y==3) cout << "Three" << endl;
  else cout << "Four" << endl;

  return 0;
}


Measured memory_bytes: 256
D1_li = []
D2_li = []


N = int(input())
for i in range(N):
	D1, D2 = map(int, input().split())
	D1_li.append(D1)
	D2_li.append(D2)

for j in range(N-2):
	if D1_li[j] == D2_li[j]:
		if D1_li[j+1] == D2_li[j+1]:
			if D1_li[j+2] == D2_li[j+2]:
				print('Yes')
				break
else:
	print('No')

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s;
	ll n,dsum=0,disum=0,djsum=0,ic=0,jc=0,iic=-1,icount[100001],jcount[100001];
	cin>>n>>s;
	for(ll i=n-1;i!=-1;i--){
		switch(s[i]){
			case 'J':dsum+=disum;break;
			case 'O':disum+=ic;break;
			case 'I':ic++;
		}
		icount[i]=ic;
	}
	for(ll i=0;i<n;i++){
		if(s[i]=='O')djsum+=jc;
		if(s[i]=='J')jc++;
		jcount[i]=jc;
	}
	for(ll i=1;i<n;i++)iic=max(iic,icount[i]*jcount[i-1]);
	cout<<max(iic,max(disum,djsum))+dsum<<endl;
}

Measured memory_bytes: 2892
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main() {
    string s, t;
    cin >> s >> t;
    ll N = s.size();
    map<char, vector<ll>> V;
    REP(i, N){
        V[s[i]].push_back(i);
    }
    ll count = 0;
    ll N1 = t.size();
    ll iter = -1;
    REP(i, N1){
        if(V.count(t[i]) == 0){
            cout << -1 << endl;
            return 0;
        }
        auto hoge = upper_bound(V[t[i]].begin(), V[t[i]].end(), iter);

        if (hoge == V[t[i]].end()){
            iter = V[t[i]][0];
            count++;
        }else iter = *hoge;
        //cout << iter << " " << count << endl;
    }

    cout << (count * N + iter + 1) << endl;
    return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template<typename t1, class t2>
void input(t1 count,t2* array) {
	for(t1 i = 0;i < count;i++) {
		cin >> array[i];
	}
}

template<typename t1, class t2>
void output(t1 count,t2* array) {
	for(t1 i = 0;i < count;i++) {
		cout << array[i];
		if(i != count - 1) cout << " ";
	}
	cout << endl;
}

template <class T>
class queue{
private:
	T d[200000];
	int head = 0,tail = 0;
public:
	void push(T a) {
		d[tail] = a;
		tail++;
	}
	T pop() {
		head++;
		return d[head-1];
	}
	bool empty() {
		return head  == tail;
	}
};

int main(int argc,char** argv) {
	queue<pair<string,int>> w;
	int n,q;
	string name;
	int time;
	cin >> n >> q;
	for(int i = 0;i < n;i++) {
		cin >> name >> time;
		w.push(make_pair(name,time));
	}
	int cur = 0;
	while(!w.empty()) {
		auto t = w.pop();
		cur += q;
		t.second -= q;
		if(t.second > 0) w.push(t);
		else {
			cur += t.second;
			cout << t.first << " " << cur << endl;
		}
	}
}



Measured memory_bytes: 8472
#include <bits/stdc++.h>
using namespace std;
const int IINF = INT_MAX;

int main() {
    int n, t[55], sum = 0, ans = IINF;
    bool dp[900][900]{};
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> t[i];
        sum += t[i];
    }
    dp[0][0] = true;
    for(int i=0; i<n; i++){
        for(int x=800; x>=0; x--){
            for(int y=800; y>=0; y--){
                if(dp[x][y]){
                    dp[x+t[i]][y] = true;
                    dp[x][y+t[i]] = true;
                }
            }
        }
    }
    for(int x=0; x<=850; x++){
        for(int y=0; y<=850; y++){
            if(dp[x][y]) ans = min(ans, max({x, y, sum-x-y}));
        }
    }
    cout << ans << endl;
    return 0;
}



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

int main() {
    int L, R, A, B, C ,D;

    cin >> A >> B >> C >> D;
    R = (C + D);
    L = (A + B);

    if (R == L)
        cout << "Balanced" << endl;
    else if (R > L)
        cout << "Right" << endl;
    else if (L > R)
        cout << "Left" << left;

    return 0;
}

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

int n;

int main() {
	cin >> n;
	for (int i=1; i<=9; i++) {
		if (n % i == 0 && n / i <= 9) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}

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

int main(){
	int N, M, a, b, i;
	scanf("%d%d", &N, &M);
	int *v = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		v[i] = 0;
	}
	for(i = 0; i < M; i++){
		scanf("%d%d", &a, &b);
		v[a]++;
		v[b]++;
	}
	for(i = 0; i < N; i++){
		if(v[i] % 2 == 1){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int maisuu = scanner.nextInt();
        int sougaku = scanner.nextInt();

        if (500 * maisuu >= sougaku){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23508
//#include <fstream>
#include <iostream>
#include <cstring>


using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

const int MAXN = 100000;

char s[1 + MAXN];
bool dp[1 + MAXN];

bool Match(int x, string word) {
    if (x < word.size())
        return false;
    if (!dp[x - word.size()])
        return false;
    for (int i = 0; i < word.size(); i++)
        if (word[i] != s[x - word.size() + i + 1])
            return false;
    return true;
}

int main() {
    int n;
    cin >> s + 1;
    n = strlen(s + 1);
    dp[0] = true;
    for (int i = 1; i <= n; i++)
        if (Match(i, "dream") || Match(i, "dreamer") || Match(i, "erase") || Match(i, "eraser"))
            dp[i] = true;
    if (dp[n])
        cout << "YES\n";
    else
        cout << "NO\n";
    return 0;
}


Measured memory_bytes: 512
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        BigInteger max = new BigInteger("1000000000000000000");
        BigInteger ans = new BigInteger("1");

        long[] A = new long[N];
        for (int i = 0; i < N ; i++) {
            A[i] = sc.nextLong();
        }
        Arrays.sort(A);

        for (long val : A) {
            if(val==0){
                System.out.println(0);
                return;
            }
            ans = ans.multiply(new BigInteger(val+""));
            if(ans.compareTo(max)>0){
                System.out.println(-1);
                return;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 62420
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(){
    string s;
    cin>>s;
    int cnt = 0;
    rep(i,0,2) if(s[i] == 'o') cnt++;
    cout<<700 + cnt * 100<<endl;
    return 0;
}

Measured memory_bytes: 256
//****** @author mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll fast_pow(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}



void solve() {
   ll n;cin>>n;
   ll a[n];
   for(ll i=0;i<n;i++)cin>>a[i];
   ll x=-1;
   int c=1;
   for(ll i=0;i<n;i++){
       if(a[i]==c){
           x=c;
           c++;
       }
   }
   if(x==-1)cout<<-1<<endl;
   else cout<<n-x<<endl;

}
int main()
{
    IOS;
    ll t=1;
   //   cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

using namespace std;

int main(){
    int time_counter = 0;
    int n;
    int limit;
    scanf("%d%d",&n,&limit);

    queue< pair<string, int> >que;
    string proc;
    int time;

    for(int i = 0; i<n; i++){
        cin>>proc>>time;
        que.push(make_pair(proc,time));
    }

    while(!que.empty()){
        pair<string, int>now = que.front();
        que.pop();

        if(now.second <= limit){
            time_counter += now.second;
            cout<<now.first<<" "<<time_counter<<endl;
        }
        else if(now.second > limit){
            time_counter += limit;
            int new_time = now.second - limit;
            que.push(make_pair(now.first, new_time));
        }
    }

 return 0;

}



Measured memory_bytes: 6300
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map { it.toInt() }

    val B = mutableListOf<Int>()
    val C = mutableListOf<Int>()
    B.add(A.first()); C.add(A.last())
    for (i in 1 until N) {
        B.add(gcd(B.last(), A[i]))
        C.add(gcd(C.last(), A[N - 1 - i]))
    }
    val G = mutableListOf<Int>()
    G.add(C[N - 2])
    for (i in 0 until N - 2) {
        G.add(gcd(B[i], C[N - 3 - i]))
    }
    G.add(B[N - 2])
    println(G.max())
}

fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)

Measured memory_bytes: 59644
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAXN 3004
int N;
int A[MAXN];
llong PS[MAXN];
llong sum(int L, int R) {
   return PS[R] - PS[L-1];
}

llong memo[MAXN][MAXN];
llong go(int L, int R) {
   if (L > R) return 0;
   llong& res = memo[L][R];
   if (res < 0) {
      res = sum(L, R)-min(go(L+1, R), go(L, R-1));
   }
   return res;
}

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

   cin >> N;
   FOR(i, 1, N)
      cin >> A[i];

   FOR(i, 1, N)
      PS[i] = PS[i-1] + A[i];

   memset(memo, -1, sizeof(memo));
   llong first = go(1, N);
   llong second = sum(1, N) - first;
   cout << first - second << '\n';

   return 0;
}


Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
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; }
const int INF = 1000100100;

int main() {
    ll H, W;
    cin >> H >> W;

    char a[H][W];
    REP(i, H) REP(j, W) cin >> a[i][j];

    char c = '#';
    for(ll i = 0; i < H + 2; ++i) {
        printf("%c", c);
        for(ll j = 0; j < W; ++j) {
            if(i == 0 || i == H + 1) {
                printf("%c", c);
            } else {
                printf("%c", a[i - 1][j]);
            }
        }
        printf("%c\n", c);
    }

    return 0;
}

Measured memory_bytes: 3636
nm = input('')
n = int(nm.split(' ')[0])
m = int(nm.split(' ')[1])
alist = input('').split(' ')

t = 0
for i in range(n):
  t += int(alist[i])

  s = 0
for i in range(n):
  a = int(alist[i])
  if a*4*m >= t:
    s+=1

if s >= m:
  print('Yes')
else:
  print('No')



Measured memory_bytes: 3060
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

ll llmin(ll a,ll b){
    if(a>=b) return b;
    return a;
}
ll llmax(ll a,ll b){
    if(a<=b) return b;
    return a;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> A;
    cin >> B;
    C = llmax(A+B,A-B);
    cout << llmax(C,A*B) << endl;
       

}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main(){
using ll = long long;
int n;
cin >> n;
vector<ll> v(n);
for(auto& x : v) cin >> x;
sort(begin(v), end(v), greater<ll>());
ll res = 0;
for(int i = 0; i < n; ++i) res += (i%2 ? -1ll : 1ll) * v[i];
cout << res << endl;
return 0;
 
}

Measured memory_bytes: 256
(defun solve (str)
  (let (S N W E)
       (loop for char across str do
             (cond 
               ((eq char #\S) (setf S t))
               ((eq char #\N) (setf N t))
               ((eq char #\W) (setf W t))
               (t (setf E t))))
       (and (eq S N) (eq W E))))

(if (solve (read-line)) 
    (princ "Yes")
    (princ "No"))

Measured memory_bytes: 3688
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int k=sc.nextInt();
        char c[]=sc.nextString().toCharArray();
        char pr=c[0];
//        db(c,k);
        
        for (int i = 1; i < c.length; i++) {
        	if(k==0)break;
			if(pr!=c[i]) {
				while(c[i]!=pr) {
					c[i]=pr;
					i++;
					if(i==c.length) {i--;break;}
				}
				k--;
			}
			pr=c[i];
		}
        int a=0;
        for (int i = 1; i < c.length; i++) {
			if(c[i-1]==c[i])a++;
		}
//        db(c);
        
        out.println(a);
     	out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}


//class P {
//	int x, y;
//	P(int  x, int y) {
//	  this.x=x;
//	  this.y=y;
//	}
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//    	if(a==p.a) return b-p.b;
//        return -p.a+a;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

int main(void) {
    ll X, Y;
    cin >> X >> Y;
    int ans = 0;
    while(X <= Y) {
        X *= 2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 3e3 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, dp[maxn][maxn];
string s;
int add(int a, int b)
{
	if(a + b >= mod) return a + b - mod;
	else if(a + b < 0) return a + b + mod;
	else return a + b;
}
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    cin >> s;
    dp[1][1] = 1;
    for(int i = 2; i <= n; i++)
    {
    	vector<int>pref(i, 0);
    	for(int j = 1; j < i; j++)
    	    pref[j] = add(dp[i - 1][j], pref[j - 1]);
    	for(int cur = 1; cur <= i; cur++)
    	{
    	    if(s[i - 2] == '<')
    	    	dp[i][cur] = pref[cur - 1];
    	    else 
    	    	dp[i][cur] = add(pref[i - 1], -pref[cur - 1]);
    	}
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) 
    	ans = add(ans, dp[n][i]);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 35840
#include <stdio.h>

int main(void)
{
	char str[1000];
	char buf[1000];
	char rep[1000];
	char cmd[10];
	int i, j, q;
	int a, b;

	scanf("%s", str);
	scanf("%d", &q);

	for (i = 0; i < q; i++)
	{
		scanf("%s", cmd);
		if (strcmp(cmd, "print") == 0)
		{
			scanf("%d %d", &a, &b);
			strncpy(buf, str + a, b - a + 1);
			buf[b - a + 1] = '\0';
			printf("%s\n", buf);
		}
		else if (strcmp(cmd, "reverse") == 0)
		{
			scanf("%d %d", &a, &b);
			strcpy(buf, str);
			for (j = a; j < b + 1; j++)
			{
				buf[j] = str[b + a - j];
			}
			strcpy(str, buf);
		}
		else if (strcmp(cmd, "replace") == 0)
		{
			scanf("%d %d %s", &a, &b, rep);
			buf[0] = '\0';
			strncat(buf, str, a);
			strcat(buf, rep);
			strcat(buf, str + b + 1);
			strcpy(str, buf);
		}
	}

	return 0;
}


Measured memory_bytes: 2100
#include <stdio.h>
int main()
{
  int ret;
  int n,x;
  ret=scanf("%d",&n);
  ret=scanf("%d",&x);
  int i;
  int nl=1;
  int d=0;
  for (i=0; i<n; i++){
    int leap;
    ret = scanf("%d",&leap);
    d += leap;
    if ( d <= x ) nl++;
    else break;
  }
  printf("%d",nl);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int a, b;
	cin >> a >> b;
	if(a > b)
		swap(a, b);
	if(a == 2)
		cout << 1;
	else if(b == 2)
		cout << 3;
	else
		cout << 2;
	return 0;
}

Measured memory_bytes: 256
//shara's here
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAD
#include <bits/stdc++.h>
using namespace std;
typedef string s;
typedef long long ll;
typedef long double ld;
#if !defined(ONLINE_JUDGE)
#include "C:\debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define ins insert
#define vl vector<ll>
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
int main(){
    speed;
    ll t,m,sum=0;
    cin>>t>>m;
    while(m--){
        ll x;
        cin>>x;
        sum+=x;
    }
    if(t-sum>=0)cout<<t-sum<<endl;
    else cout << -1 << endl;





















return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int n;
static const int MAX = 100;
static const int INF = (1 << 21);
int M[MAX][MAX];
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;


void dijkstra(){
    int minv;
    int d[MAX], color[MAX];

    for (int i = 0; i < n; i++){
        d[i] = INF;
        color[i] = WHITE;
    }

    d[0] = 0;
    // color[]

    while(1){
        minv = INF;
        int u = -1;

        for (int i = 0; i < n; i++){
            if (minv > d[i] && color[i] != BLACK){
                minv= d[i];
                u = i;
            }
        }

        if (u == -1){ //全部探索済み
            break;
        }

        color[u] = BLACK;
        for (int i = 0; i < n; i++){
            if (color[i] != BLACK && d[i] > M[u][i] != INF){
                if (d[i] > d[u] + M[u][i]){
                    color[i] = GRAY;
                    d[i] = d[u] + M[u][i];
                }
            }
        }
    }
    for (int i = 0; i < n; i++){
            cout << i << " ";
            if (d[i] == INF){
                cout << -1 << endl;
            }else{
                cout << d[i] << endl;
            }
            
        }
}

int main(void){
    int tmp;

    cin >> n;

    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            M[i][j] = INF;
        }
    }

    int u, k;
    int v, c;
    for (int i = 0; i < n; i++){
        cin >> u >> k;
        for (int j = 0; j < k; j++){
            cin >> v >> c;
            M[u][v] = c;
        }
    }
    dijkstra();

    return 0;
}



Measured memory_bytes: 3136
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	ll a,b;
    double c;
    
    cin >> a;
    cin >> c;
    
    b = (c*100+.5);
    
    ll res = (a*b);
    res/=100;
    
    cout << res; 
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3752