akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <functional>

template <typename T, typename U>
struct LazySegTree {
  std::function<T (T, T)> op;
  T id;
  std::function<U (U, U)> lazy_op;
  U lazy_id;
  std::function<T (T, U, int)> update;

  int n;

  std::vector<T> node;
  std::vector<T> lazy_node;

  LazySegTree(std::function<T (T, T)> _op, T _id, std::function<U (U, U)> _lazy_op, U _lazy_id, std::function<T (T, U, int)> _update, std::vector<T> valvec) {
    op = _op;
    id = _id;
    lazy_op = _lazy_op;
    lazy_id = _lazy_id;
    update = _update;

    for (n = 1; n < valvec.size(); n *= 2);

    node.resize(2*n-1);
    for (int i = 0; i < valvec.size(); i++) node[n-1+i] = valvec[i];
    for (int i = valvec.size(); i < n; i++) node[n-1+i] = id;
    for (int i = n-2; i >= 0; i--) node[i] = op(node[2*i+1], node[2*i+2]);

    lazy_node.resize(2*n-1);
    for (int i = 0; i < 2*n-1; i++) lazy_node[i] = lazy_id;
  }

  void eval(int k, int l, int r) {
    node[k] = update(node[k], lazy_node[k], r-l);
    if (k < n-1) {
      lazy_node[2*k+1] = lazy_op(lazy_node[2*k+1], lazy_node[k]);
      lazy_node[2*k+2] = lazy_op(lazy_node[2*k+2], lazy_node[k]);
    }
    lazy_node[k] = lazy_id;
  }

  T op_range(int a, int b) { return op_range(a, b, 0, 0, n); }
  T op_range(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return id;
    eval(k, l, r);
    if (a <= l && r <= b) return node[k];
    return op(op_range(a, b, 2*k+1, l, (l+r)/2), op_range(a, b, 2*k+2, (l+r)/2, r));
  }

  void update_range(int a, int b, T val) { return update_range(a, b, val, 0, 0, n); }
  void update_range(int a, int b, T val, int k, int l, int r) {
    if (r <= a || b <= l) return;
    if (a <= l && r <= b) {
      lazy_node[k] = lazy_op(lazy_node[k], val);
      return;
    }
    eval(k, l, r);
    update_range(a, b, val, 2*k+1, l, (l+r)/2);
    update_range(a, b, val, 2*k+2, (l+r)/2, r);
  }
};

int main() {
  int N, Q;
  std::cin >> N >> Q;

  std::vector<int> width_valvec(N, N-2);
  std::vector<int> height_valvec(N, N-2);
  LazySegTree<int,int> width(
      [](int a, int b) { return std::min<int>(a, b); },
      1000000000,
      [](int a, int b) { return std::min<int>(a, b); },
      1000000000,
      [](int a, int b, int nc) { return std::min<int>(a, b); },
      width_valvec);
  LazySegTree<int,int> height(
      [](int a, int b) { return std::min<int>(a, b); },
      1000000000,
      [](int a, int b) { return std::min<int>(a, b); },
      1000000000,
      [](int a, int b, int nc) { return std::min<int>(a, b); },
      width_valvec);

  long long int ngot = 0;
  for (int i = 0; i < Q; i++) {
    int type, x;
    std::cin >> type >> x;
    x--;
    if (type == 1) {
      int heightx = height.op_range(x,x+1);
      //std::cout << heightx << std::endl;
      ngot += heightx;
      width.update_range(1,heightx+1,x-1);
    } else {
      int widthx = width.op_range(x,x+1);
      //std::cout << widthx << std::endl;
      ngot += widthx;
      height.update_range(1,widthx+1,x-1);
    }
  }
  std::cout << ((long long int)N-2)*((long long int)N-2)-ngot << std::endl;
  return 0;
}


Measured memory_bytes: 13428
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String s = scan.next();

		int i;
		int length = s.length();
		int[] sum = new int[10000];
		for(i = 0; i < length; i++) {
			sum[s.codePointAt(i)]++;
		}
		for(i = 0; i < length; i++) {
			if(sum[s.codePointAt(i)] != 2) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

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

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

  deque<int> Vec;
  for (int i = 0; i < N; i++) {
    int cmd1, cmd2, ele;
    cin >> cmd1;
    if (cmd1 == 0) {
      cin >> cmd2 >> ele;
      if (cmd2 == 0)
        Vec.push_front(ele);
      else if (cmd2 == 1)
        Vec.push_back(ele);
    } else if (cmd1 == 1) {
      cin >> ele;
      cout << Vec.at(ele) << endl;
    } else if (cmd1 == 2) {
      cin >> cmd2;
      if(cmd2 == 0)Vec.pop_front();
      else if(cmd2 == 1)Vec.pop_back();
    }
  }
}


Measured memory_bytes: 4628
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdlib>
#include <list>
#include <algorithm>

using namespace std;

int main() {
    //cin.tie(0); 
    //ios::sync_with_stdio(false);
   
    int n;
    int x;
    char cc[20];
    list<int> L;

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
	scanf("%s", cc);
	if (cc[0] == 'i') {
	    scanf("%d", &x);
	    L.emplace_front(x);
	}
	else if (cc[6] == 'L') {
	    L.pop_back();
	}
	else if(cc[6] == 'F') {
	    L.pop_front();
	}
	else {
	    scanf("%d", &x);
	    for (auto iter = L.begin(); iter != L.end(); iter++) {
		if (*iter == x) {
		    L.erase(iter);
		    break;
		}
	    }
	}
    }

    int i = 0;
    for (auto iter = L.begin(); iter != L.end(); iter++) {
	if (i++) {
	    printf(" ");
	}
	printf("%d", *iter);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 34348
#include <bits/stdc++.h>
#define MAXN 1007

using namespace std;

int main(void)
{
    vector<int> applePos,peachPos;
    char msg[MAXN];
    int i=0;
    while((msg[i]=getchar())!='\n')
    {
        i++;
    }
    msg[i]=0;
    for(i=0;msg[i];i++)
    {
        if(strncmp(msg+i,"apple",5)==0)
        {
            applePos.push_back(i);
        }
        if(strncmp(msg+i,"peach",5)==0)
        {
            peachPos.push_back(i);
        }
    }
    for(i=0;i<applePos.size();i++)
    {
        strncpy(msg+applePos[i],"peach",5);
    }
    for(i=0;i<peachPos.size();i++)
    {
        strncpy(msg+peachPos[i],"apple",5);
    }
    printf("%s\n",msg);
    return 0;
}



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

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
vector<int>E[100000];
int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;
bool b[200000], ok[100000];
queue<int>que;

void bfs(int u, int t) {
	que.push(u);
	while (!que.empty()) {
		int p = que.front(); que.pop(); for (int v : E[p]) {
			if (t) {
				if (d[v] > d[p] && !ok[v]) {
					ok[v] = 1; cnt++; que.push(v);
				}
			}
			else if (!~d[v]) {
				d[v] = d[p] + 1; que.push(v);
			}
		}
	}
}
int main() {
	int n, m, q; reader(&n); reader(&m); reader(&q);
	rep(i, m) {
		reader(&u[i]); reader(&v[i]);
		u[i]--; v[i]--;
		E[u[i]].push_back(v[i]); E[v[i]].push_back(u[i]);
	}
	queue<int>que;
	memset(d, -1, sizeof(d));
	d[0] = 0; bfs(0, 0);
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		reader(&r[i]); r[i]--;
		b[r[i]] = true;
	}
	ok[0] = true;
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] - d[u[i]] == 1) {
				E[u[i]].emplace_back(v[i]);
			}
		}
	}
	bfs(0, 1);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] - d[u[r[i]]] == 1 && !ok[v[r[i]]]) {
			E[u[r[i]]].emplace_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = true;
				bfs(v[r[i]], 1);
			}
		}
	}
	rep(i, q)printf("%d\n", ans[i]);
}

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(a) begin(a), end(a)
#define SZ(a) ((int)(a).size())

#ifdef __DEBUG
#define debug if (true)
#else
#define debug if (false)
#endif

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<string> grid(n * 2);
  for (int i = 0; i < n; i++) {
    cin >> grid[i];
    grid[i] += grid[i];
    grid[i + n] = grid[i];
  }
  vector<vi> maxMatch(2 * n, vi(2 * n));
  for (int i = 0; i < n + n; i++) {
    for (int j = 0; j < n + n; j++) {
      int len = 0;
      while (i + len < 2 * n && j + len < 2 * n && grid[i + len][j] == grid[i][j + len]) {
        len++;
      }
      maxMatch[i][j] = len;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      bool can = true;
      for (int k = 0; k < n && can; k++) {
        can = can && maxMatch[i + k][j + k] >= n - k;
      }
      ans += can;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2048
use std::io::*;
use std::str::FromStr;
use std::io::{self,Write};

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:i32=read();
  let mut a=Vec::new();
  for _i in 0..n {
    let t:i32=read();
    a.push(t);
  }
  a.sort();
  a.reverse();
  let mut alice=0i32;
  let mut bob=0i32;
  let mut c=0i32;
  for i in a {
    if c%2==0 { alice+=i; }
    else { bob+=i; }
    c+=1;
  }
  println!("{}",alice-bob);

}


Measured memory_bytes: 4352
S = int(input())

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

total = sum(list)

standard = total//2

counter = 0

for i, k in enumerate(list):
  if standard > 0:
    standard -= k
    counter = i

s11 = total //2 - standard
s21 = total - s11

s12 = s11 - list[counter]
s22 = total - s12

Answer = min(abs(s11-s21), abs(s12-s22))

print(Answer)

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

int segment[1 << 19];
int a;
int saiki(int b) {
	if (segment[b] != -1)return segment[b];
	int x = saiki(b * 2 + 1), y = saiki(b * 2 + 2);
	if (abs(x - y))return abs(x - y);
	return x;
}
signed main() {
	memset(segment, -1, sizeof(segment));
    cin >> a;
	for (int b = 0; b < (1 << a); b++) {
		scanf("%d", &segment[(1 << a) - 1 + b]);
	}
	cout << saiki(0) << endl;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e3 + 5);
const int MAX_SIZE = (int)(MAX_N * MAX_N);

/////////////////////////////////////////////////////////////
// node in { 0, ... }
class TopologicalSort {
  using ts_graph = vector<vector<int>>;

 public:
  int n;
  ts_graph graph;
  vector<int> topological_sorted;
  vector<int> flg;  // 0: not-visited, 1: done, -1, temporary

  bool no_loop;

  TopologicalSort(ts_graph graph, int n) {
    this->flg = vector<int>(n, 0);
    this->graph = graph;
    this->n = n;
    init();
  }

  void init() {
    topological_sort();
  }

  bool visit(int i) {
    if (flg[i] == -1) {
      return false;
    }

    if (flg[i] == 0) {
      flg[i] = -1;

      for (auto &e : graph[i]) {
        if (!visit(e)) {
          return false;
        }
      }

      flg[i] = 1;

      topological_sorted.push_back(i);

      return true;
    }

    return true;
  }

  void topological_sort() {
    for (int i = 0; i < n; ++i) {
      flg[i] = 0;
    }

    for (int i = 0; i < n; ++i) {
      if (flg[i] == 0) {
        if (!visit(i)) {
          no_loop = false;
          return;
        }
      }
    }

    reverse(topological_sorted.begin(), topological_sorted.end());

    no_loop = true;
    return;
  }

  bool contains_loop() {
    return !no_loop;
  }

  vector<int> &get_sorted() {
    return topological_sorted;
  }
};
/////////////////////////////////////////////////////////////

int n;

int tmp[MAX_N];
vector<vector<int>> graph(MAX_SIZE);
unordered_map<int, int> memo;

int make_key(int a, int b) {
  return min(a, b) * n + max(a, b);
}

int depth(int cur) {
  if (memo.find(cur) != memo.end()) return memo[cur];

  if (graph[cur].size() == 0) {
    return memo[cur] = 1;
  }

  int ret = -1;

  for (auto &e : graph[cur]) {
    ret = max(ret, depth(e));
  }

  ret += 1;

  return memo[cur] = ret;
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= n - 1; ++j) {
      scanf("%d", &(tmp[j]));
      tmp[j] -= 1;
    }

    int last = make_key(i, tmp[1]);

    for (int j = 2; j <= n - 1; ++j) {
      int cur = make_key(i, tmp[j]);
      graph[last].push_back(cur);
      last = cur;
    }
  }

  TopologicalSort ts(graph, MAX_SIZE);

  if (ts.contains_loop()) {
    printf("-1\n");
    return 0;
  }

  int ans = -1;

  for (int i = 0; i < MAX_SIZE; ++i) {
    ans = max(ans, depth(i));
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 127860
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <set>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main(void){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> t(n);
    int sum = 0;
    rep(i,n){
        cin >> t[i];
        sum += t[i];
    }
    int m;
    cin >> m;
    vector<int> p(m), x(m);
    rep(i, m) cin >> p[i] >> x[i];
    rep(i, m) cout << sum - t[p[i] - 1] + x[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
     
typedef long long ll;
typedef vector <int> vi;
typedef pair <int,int> pi;
typedef tuple <int,int,int> ti;

#define forn(i,a,n) for(int i = a; i < n ; i++)
#define mem(str,a) memset(str, a, sizeof(str));
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(nullptr)
const int MOD = 1e9+7, N = 1e7 + 10, E = 1e-9;
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
//vector <int> show;
//for (auto x : show)
//   cout << x << " ";
getline(cin,s);


*/

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
    return 0;
}


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

int main(int argc, char* argv[]){
    int n, ans = 0;
    cin >> n;

    vector<int> d(n);

    loop(i, n){
        cin >> d[i];
    }
    sort(d.begin(), d.end(), greater<int>());
    for(int i = 1; i < n; i++){
        if(d[i] < d[i-1]){
            ans++;
        }
    }
    cout << ans + 1<< endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    int n, HP;
    cin >> n >> HP;
 
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
 
    sort(b.begin(), b.end(), greater<>());
    int aMax = *max_element(a.begin(), a.end());
    
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (HP <= 0 || b[i] < aMax) break;
        HP -= b[i];
        ans++;
    }
 
    if (HP > 0) ans += (HP + aMax - 1) / aMax;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        vector<int> post(30,-1),pre(30);
        string s;
        cin >> s;
        if(s.size() < 3){
            cout << s << endl;
        }else{
            for(int j = 3; j < s.size(); j += 3){
                int now = s[j] - 'a';
                int bef = s[j-3] - 'a';
                if(s[j-2] == '<')swap(now,bef);
                post[bef] = now;
                pre[now]++;
            }
            for(int j = 0; j < 30; j++){
                if(pre[j] == 0 && post[j] != -1){
                    int now = j;
                    cout << char('a' + now);
                    while(post[now] != -1){
                        now = post[now];
                        cout << char('a' + now);
                    }
                    cout << endl;
                }
            }
        }
    }
}



Measured memory_bytes: 3168
import java.util.*;
import java.lang.*;
import java.io.*;
 
class Main {
    public static void main (String[] args) throws java.lang.Exception{
        Scanner scan = new Scanner(System.in);
        List<String> printList = new ArrayList<String>();
 
        String str = scan.next();
        int n = scan.nextInt();
     
        for (int i = 0; i < n; i ++) {
            String op = scan.next();
            int start = scan.nextInt();
            int end = scan.nextInt() + 1;
         
       		if ("replace".equals(op)) {
            	String replaceStr = scan.next();
            	str = str.substring(0, start) + replaceStr + str.substring(end, str.length());
        	} else if ("reverse".equals(op)) {
          		str = str.substring(0, start) + new StringBuffer(str.substring(start, end)).reverse().toString() + str.substring(end, str.length());
        	} else if ("print".equals(op)) {
           		printList.add(str.substring(start, end));
        	}
    	}
 
    	for (String s : printList) {
        	System.out.println(s);
    	}
 
	}
}

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

int main(){
  int A,B;
  int V,W;
  int T;
  
  scanf("%d %d\n",&A,&V);
  scanf("%d %d\n",&B,&W);
  scanf("%d",&T);
  
  int c=0;
  if(V>W){
    A-=B;
    if(A<0) A=-A;
    V-=W;
    for(int i=0;i<T;i++){
      A-=V;
      if(A<=0){
        c=1;
        break;
      }
    }
  }
  
  if(c==1) printf("YES\n");
  else printf("NO\n");
  return 0;
}


Measured memory_bytes: 1660
INPUT_SENTENCES = 2
ss = [input() for i in range(INPUT_SENTENCES)]
n = int(ss[0])
p = list(map(lambda x: int(x), ss[1].split()))
result = []
for i in range(1, n-1):
    if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]:
        result.append(1)
print(len(result))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<iomanip>
#include<queue>
#include<cmath>
#include<stack>
#include <map>
#define ll long long int
#define skip cin>>ws;
#define vll vector<ll> 
#define vb vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define vs vector<string>
#define vvpll vector<vector<pair<ll, ll>>>
#define pb push_back
#define pob pop_back()
#define MOD (ll)(1e9 + 7)
#define test ll t; cin>>t; while(t--)

using namespace std;

void enter(vll &ar)
{
    ll n = ar.size();

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

void show(vll &a)
{
    ll n = a.size();

    for(ll i=0;i<n;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<"\n";
}

void SieveOfErat1sthenes(int n, vll &pri) 
{ 
    vb prime(n+1, true); 
   
    for (int p=2; p*p<=n; p++) 
    { 
        
        if (prime[p] == true) 
        { 
            pri.pb(p);
            
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}

ll mo(ll a)
{
    return a%MOD;
}

bool compare(pll a, pll b)
{
    return a.first>b.first;
}


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

    ll n;
    cin>>n;

    vll h(n);
    enter(h);

    vll ans(n);
    ans[0] = 0;
    ans[1] = abs(h[1]-h[0]);

    for(ll i=2;i<n;i++)
    {
        ans[i] = min(ans[i-1]+abs(h[i]-h[i-1]), ans[i-2] + abs(h[i]-h[i-2]));
    }

    cout<<ans[n-1]<<"\n";

    return 0;
}


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

const int MAXN = 2.1e5;
const int K = 10;
int dp[MAXN][K];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s; cin >> s;
	int N = int(s.size());
	dp[0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int a = 0; a <= i && a < K; a++) {
			for (int b = 1; i+b <= N && b < K; b++) {
				if (s.substr(i-a, a) != s.substr(i, b)) {
					dp[i+b][b] = max(dp[i+b][b], dp[i][a] + 1);
				}
			}
		}
	}
	int ans = 0;
	for (int a = 0; a < K; a++) {
		ans = max(ans, dp[N][a]);
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 8724
#include<iostream>

int main(){
    int N;
    std::cin >> N;

    // 即座に0になるものを例外処理
    if(N < 105){
        std::cout << 0 << std::endl;
        return 0;
    }

    // 全探索
    int num = 0;
    for(int i = 105; i <= N; i += 2){
        int yakusu = 0;
        for(int j = 1; j <= i; j += 2){
            if(i % j == 0) yakusu++;
        }
        if(yakusu == 8) num++; 
    }

    std::cout << num << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,a,i,min,max;
    long long sum;
    sum = 0;
    min = 1000000;
    max = -1000000;
    scanf("%d",&n);
    for ( i = 0; i < n; i++)
    {
        scanf("%d",&a);
        sum = sum+ a;
        if ( min > a )
        min = a;
        if ( max < a )
        max = a;
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int p[n+1], q[n+1];
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    int a=0, b=0;
    do{
        a++;
    }while(next_permutation(p, p+n));
    do{
        b++;
    }while(next_permutation(q, q+n));

    cout << max(a-b, b-a) << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1LL<<31;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
    }
    ll ans=0;
    for(ll i=0;i<=30;i++){
        vector<ll> A(n),B(n);
        ll T=1LL<<i;
        rep(j,n){
            A[j]=a[j]%(2*T);
            B[j]=b[j]%(2*T);
        }
        sort(B.begin(),B.end());
        ll sum=0;
        rep(j,n){
            auto it1=lower_bound(B.begin(),B.end(),T-A[j])-B.begin();
            auto it2=lower_bound(B.begin(),B.end(),2*T-A[j])-B.begin();
            auto it3=lower_bound(B.begin(),B.end(),3*T-A[j])-B.begin();
            sum+=it2-it1;
            sum+=n-it3;
        }
        if(sum%2) ans+=1LL<<i;
    }
    cout << ans << endl;
} 


Measured memory_bytes: 9584
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    int S[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin>>K;
    cout<<S[K-1];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const ll INF = 1e17;
ll N, M, L, Q;
ll fuel[305][305];
ll dist[305][305];
ll s[105000], t[105000];
ll A[100000], B[100000], C[100000];

void input() {
    cin >> N >> M >> L;
    for(int i = 1; i <= M; i++) {
        cin >> A[i] >> B[i] >> C[i];
    }
    cin >> Q;
    for (int i = 1; i <= Q; i++) {
        cin >> s[i] >> t[i];
    }
}

void solve() {
    input();
    for(int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            fuel[i][j] = INF;
            dist[i][j] = INF;
        }
        fuel[i][i] = 0;
        dist[i][i] = 0;
    }
    for(int i = 1; i <= M; i++) {
        chmin(fuel[A[i]][B[i]], C[i]);
        chmin(fuel[B[i]][A[i]], C[i]);
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                chmin(fuel[j][k], fuel[j][i] + fuel[i][k]);
            }
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            if(i == j) continue;
            if(fuel[i][j] <= L) chmin(dist[i][j], 1LL);
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                chmin(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
    for(int i = 1; i <= Q; i++) {
        if(dist[t[i]][s[i]] < INF) cout << dist[t[i]][s[i]] -1 << endl;
        else cout << -1 << endl;
    }
    return ;
}


int main() {
    solve();
    return 0;
}


Measured memory_bytes: 4864
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    print("#"*W)
    for i in range(H-2):
        print("#",end="")
        print("."*(W-2),end="")
        print("#")
    print("#"*W)
    print()


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

int main(){
    string S;int K;cin>>S>>K;
    vector<char> a(K);
    for(int i=0;i<K;i++)cin>>a.at(i);
    int flag;
    while(true){
        flag=0;
        int N=S.size();
        for(int i=0;i<N;i++){
            for(int j=0;j<K;j++){
                if(S.at(i)==a.at(j)){
                    i==N;
                    flag++;
                    break;
                }
            }
        }
        if(flag==0)break;
        int num = stoi(S);
        num++;
        S=to_string(num);
    }
    cout<<S<<endl;
    return 0;
}

Measured memory_bytes: 256
/* https://atcoder.jp/contests/abc089/tasks/abc089_c */

#include <iostream>
#include <map>
#include <vector>

int N;
std::vector<int> initials = {
  'M',
  'A',
  'R',
  'C',
  'H'
};
std::map<char, int> names = {
  {initials.at(0), 0},
  {initials.at(1), 0},
  {initials.at(2), 0},
  {initials.at(3), 0},
  {initials.at(4), 0}
};

void solve()
{
  long long ptn = 0;
  for (int i = 0; i < 3; ++i) {
    long long n_1 = names.at(initials.at(i));
    for (int j = i+1; j < 4; ++j) {
      long long n_2 = names.at(initials.at(j));
      for (int k = j+1; k < 5; ++k) {
        long long n_3 = names.at(initials.at(k));
          ptn += n_1*n_2*n_3;
      }
    }
  }

  std::cout << ptn << std::endl;

  return;
}

int main(int argc, char *argv[])
{
  // Input
  std::cin >> N;

  for (int i = 0; i < N; ++i) {
    std::string s;
    std::cin >> s;
    char s_initials = s.at(0);

    if (names.find(s_initials) != names.end()) {
      names.at(s_initials)++;
    }
  }

  // Output
  solve();

  return 0;
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll X, Y, Z, K;
	cin >> X >> Y >> Z >> K;

	vector <ll> A(X);
	for (int ii = 0; ii < X; ++ii){
		cin >> A[ii];
	}
	vector <ll> B(Y);
	for (int ii = 0; ii < Y; ++ii){
		cin >> B[ii];
	}
	vector <ll> C(Z);
	for (int ii = 0; ii < Z; ++ii){
		cin >> C[ii];
	}
	sort(A.rbegin(), A.rend());
	sort(B.rbegin(), B.rend());
	sort(C.rbegin(), C.rend());

	vector < pair<ll, ll> > v;
	ll cA = 1000000;
	ll cB = 1000;
	ll cC = 1;
	ll pval = A[0] + B[0] + C[0];
	ll pidx = cA*0 + cB*0 + cC*0;
	v.push_back(make_pair(pval, pidx));

	map<ll, ll> m;
	map<ll, ll> mm;
	mm[pidx] = 1;

	for (int cnt = 0; cnt < K; ++cnt){
		pair<ll, ll> tmp = v.back();
		v.pop_back();

		ll val = tmp.first;
		ll idx = tmp.second;
		if (m[idx] == 0){
			cout << val << "\n";
		}
		m[idx] = 1;

		ll aidx = idx / cA;
		ll bidx = (idx - cA*aidx) / cB;
		ll cidx = idx - cA*aidx - cB*bidx;

		if (aidx + 1 < X){
			ll taidx = aidx + 1;
			//下位互換でないかチェック
			bool ok = true;
			for (int ii = 0; ii < v.size(); ++ii){
				ll vidx = v[ii].second;
				ll vaidx = vidx / cA;
				ll vbidx = (vidx - cA*vaidx) / cB;
				ll vcidx = vidx - cA*vaidx - cB*vbidx;
				// if ( (taidx<=vaidx) && (bidx<=vbidx) && (cidx<=vcidx)){
				// 	ok = false;
				// 	break;
				// }
			}
			if (ok){
				ll val = A[taidx] + B[bidx] + C[cidx];
				ll idx = cA*taidx + cB*bidx + cC*cidx;
				if (mm[idx] == 0){
					v.push_back(make_pair(val, idx));
					mm[idx] = 1;
				}
				// printf("valA %i, idx %i %i %i\n", val, taidx, bidx, cidx);
			}
		}

		if (bidx + 1 < Y){
			ll tbidx = bidx + 1;
			//下位互換でないかチェック
			bool ok = true;
			for (int ii = 0; ii < v.size(); ++ii){
				ll vidx = v[ii].second;
				ll vaidx = vidx / cA;
				ll vbidx = (vidx - cA*vaidx) / cB;
				ll vcidx = vidx - cA*vaidx - cB*vbidx;
				// if ( (aidx<=vaidx) && (tbidx<=vbidx) && (cidx<=vcidx)){
				// 	ok = false;
				// 	break;
				// }
			}
			if (ok){
				ll val = A[aidx] + B[tbidx] + C[cidx];
				ll idx = cA*aidx + cB*tbidx + cC*cidx;
				if (mm[idx] == 0){
					v.push_back(make_pair(val, idx));
					mm[idx] = 1;
				}
			}
		}

		if (cidx + 1 < Z){
			ll tcidx = cidx + 1;
			//下位互換でないかチェック
			bool ok = true;
			for (int ii = 0; ii < v.size(); ++ii){
				ll vidx = v[ii].second;
				ll vaidx = vidx / cA;
				ll vbidx = (vidx - cA*vaidx) / cB;
				ll vcidx = vidx - cA*vaidx - cB*vbidx;
				// if ( (aidx<=vaidx) && (bidx<=vbidx) && (tcidx<=vcidx)){
				// 	ok = false;
				// 	break;
				// }
			}
			if (ok){
				ll val = A[aidx] + B[bidx] + C[tcidx];
				ll idx = cA*aidx + cB*bidx + cC*tcidx;
				if (mm[idx] == 0){
					v.push_back(make_pair(val, idx));
					mm[idx] = 1;
				}
			}
		}

		sort(v.begin(), v.end());
	}

	return 0;
}


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

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            ok = mid
        else:
            ng = mid
    return ok

def check(x):
    x = str(x)
    N = len(x)
    dp0 = list2d(N+1, 10, 0)
    dp1 = list2d(N+1, 10, 0)
    a = int(x[0])
    dp0[1][a] = 1
    for j in range(1, a):
        dp1[1][j] = 1
    for i in range(2, N+1):
        for j in range(1, 10):
            dp1[i][j] = 1
    for i, a in enumerate(x):
        a = int(a)
        for j in range(10):
            for k in range(10):
                if abs(j - k) >= 2:
                    continue
                if k > a:
                    dp1[i+1][k] += dp1[i][j]
                elif k == a:
                    dp0[i+1][k] += dp0[i][j]
                    dp1[i+1][k] += dp1[i][j]
                else:
                    dp1[i+1][k] += dp0[i][j]
                    dp1[i+1][k] += dp1[i][j]
    ans = sum(dp0[N]) + sum(dp1[N])
    return ans >= K

K = INT()

res = bisearch_min(0, 10**10, check)
print(res)


Measured memory_bytes: 3316
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int M[]=new int[N];
    int x=0;
    for(int i=0;i<N;i++){
      M[i]=sc.nextInt();
       if(((M[i]%2==0)&&(!(M[i]%3==0)))&&(!(M[i]%5==0))){
         System.out.println("DENIED");break;}
      x=x+1;}
    if(x==N){System.out.println("APPROVED");}
  }
}

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

int main(){
  int n,m,i,kotae=1;
  cin>>n;
  if(n%2==1){
    cout<<"No";
    return 0;
  }
  char a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  m=n/2;
  for(i=0;i<m;i++){
    if(a[i]!=a[i+m]){
      kotae*=0;
    }
  }
  if(kotae){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n;//入力用
    int a,b,c,d;
    int cnt;
    
    while(scanf("%d",&n)!=EOF){
        cnt=0;
        for(a=0;a<=9;a++){
            for(b=0;b<=9;b++){
                for(c=0;c<=9;c++){
                    for(d=0;d<=9;d++){
                        if(a+b+c+d == n){
                            cnt++;
                        }
                    }
                }
            }
        }
        printf("%d\n",cnt);
    }
    
    return 0;
}

Measured memory_bytes: 596
from collections import deque

def dfs():
  queue = deque()
  queue.append([0,[0]])
  queue.append([0,[1]])
  queue.append([0,[2]])
  queue.append([0,[3]])
  
  grps = []
  while len(queue) != 0:
    idx, Llist = queue.pop()
    if idx == N-1:
      grps.append(Llist)
    else:
      queue.append([idx+1,Llist+[0]])
      queue.append([idx+1,Llist+[1]])
      queue.append([idx+1,Llist+[2]])
      queue.append([idx+1,Llist+[3]])
  return grps

N,A,B,C = map(int,input().split())
L = [int(input()) for _ in range(N)]
grps = dfs()

ans = float('inf')
for grp in grps:
  A_mem = []
  B_mem = []
  C_mem = []
  for idx, val in enumerate(grp):
    if val == 0:A_mem.append(L[idx])
    elif val == 1:B_mem.append(L[idx])
    elif val == 2:C_mem.append(L[idx])
    
  len_A_mem, len_B_mem, len_C_mem = len(A_mem), len(B_mem), len(C_mem)  
  if 0 in [len_A_mem, len_B_mem, len_C_mem]: continue
  else:
    pt = (sum([len_A_mem,len_B_mem, len_C_mem]) -3)*10
    pt += abs(sum(A_mem)-A) + abs(sum(B_mem)-B) + abs(sum(C_mem)-C)
    ans = min(ans, pt)
print(ans)

Measured memory_bytes: 13036
n = int(input())
arr = list(map(int, input().split()))

max_arr = max(arr)
dp = [0] * (max_arr + 1)

for i in arr:
    for j in range(i, max_arr + 1, i):
        dp[j] += 1

print([dp[i] for i in arr].count(1))


Measured memory_bytes: 32196
#include<stdio.h>
 
int main(void){
  int a,b,c,d,turn=0;
  
  scanf("%d %d %d %d",&a,&b,&c,&d);
  
  while(a>0 && c>0){
    if(turn%2==0){
      c -= b;
    }
    else{
      a -= d;
    }
    turn++;
  }
  
  if(a>0)
    printf("Yes");
  else
    printf("No");
  
  return 0;
}

Measured memory_bytes: 1704
n,m = map(int,input().split())
X = list(map(int,input().split()))
if n>=m:
    print(0)
    exit()
X.sort()
D = []
prev = X[0]
for i in range(1,m):
    x = X[i]
    D.append(abs(x-prev))
    prev = x
D.sort()
print(sum(D[0:m-n]))


Measured memory_bytes: 13960
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, m;
		n = sc.nextInt();
		m = sc.nextInt();
		char[][] a = new char[n][n];
		char[][] b = new char[m][m];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.next().toCharArray();
		}
		for (int i = 0; i < m; i++) {
			b[i] = sc.next().toCharArray();
		}

		boolean match = true;
		for (int y = 0; y < n; y++) {
			for (int x = 0; x < n; x++) {
				if(y + m - 1 >= n || x + m - 1 >= n) continue;

				match = true;
				for (int y2 = 0; y2 < m; y2++) {
					for (int x2 = 0; x2 < m; x2++) {
						if(a[y + y2][x + x2] != b[y2][x2]) match = false;
					}
				}
				if(match) {
					System.out.println("Yes");
					return;
				}
			}
		}

		if(!match) {
			System.out.print("No");
		}
	}
}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
#define INF (1e9)
using namespace std;

string s;
int p,flg;
int bnf();
bool check(char ch){return ch&&ch!='+'&&ch!='-'&&ch!='*'&&ch!=')';}

bool check2(){
  if(s[p]!='(')return 1;
  int i=p+1;
  while(isdigit(s[i]))i++;
  if(s[i]==')')return 0;
  
  i=p+2;
  int c=s[p+1]=='(';
  while(i<s.size()&&c) c+=(s[i]=='(')-(s[i++]==')');
  return c==0&&s[i]!=')';
}


int Num(){
  int res=0;
  flg&=check2();
  if(s[p]=='('){
    p++;
    res=bnf(),flg&=s[p++]==')';
    return res;
  }

  while(isdigit(s[p]))res=res*2+s[p++]-'0';
  if(res>1024)flg=0;
  return res;
}

int calc(){
  int res;
  p++;
  flg&=check2()&check(s[p]);
  if(s[p]=='(')res=bnf();
  else {
    res=Num();
    if(s[p]=='*') res*=calc();
  }
  if(res<0||res>=1024) flg=0;
  return res;
}

int bnf(){
  flg&=check(s[p]);
  int res=Num();
  while(p<s.size()&&flg){
    if(s[p]=='(') flg=0;
    if(s[p]==')')break;
    flg&=check(s[p+1]);
    if(s[p]=='+')res+=calc();
    else if(s[p]=='-')res-=calc();
    else if(s[p]=='*')res*=calc();
    else break;
    if(res<0||res>=1024) flg=0;
  }
  if(res<0||res>=1024) flg=0;
  if(!flg)res=-INF;
  return res;
}

int dfs(int idx){
  char ch[]={'0','1','+','-','*','(',')'};
  while(idx<s.size()&&s[idx]!='.')idx++;
  if(idx==s.size()){p=0,flg=1;return max(-1.0,bnf()-(p!=s.size())*INF);}

  int res=-1;
  for(int i=0;i<7;i++)s[idx]=ch[i],res=max(res,dfs(idx+1));
  s[idx]='.';
  return res;
}

int main(){
  cin>>s;
  cout<<dfs(0)<<endl;
  return 0;
}

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

using namespace std;


int main(){
	int n; int W; scanf("%d%d",&n,&W);
	vector<int> w(n), v(n);

	for(int i = 0; i < n; i++){
		scanf("%d%d",&w[i],&v[i]);
	}

	vector<vector<long long> > dp(n, vector<long long>(W+1,0));
	for(int x = 0; x <= W; x++){
		if(w[0] <= x) dp[0][x] = v[0];
	}
	for(int i = 1; i < n; i++){
		for(int j = 1; j <= W; j++){
			if(j >= w[i]){
				dp[i][j] = max(dp[i-1][j], v[i] + dp[i-1][j-w[i]]);
			}
			else dp[i][j] = dp[i-1][j];
		}
	}

	cout << dp[n-1][W] << endl;
}

Measured memory_bytes: 79360
N = int(input())
a_list = [int(i) for i in input().split()]

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

def lcm(a,b):
    return (a*b) // gcd(a,b)

s = a_list[0]
for i in range(1,N):
    s = lcm(s, a_list[i])

def f(m):
    c = 0
    for a in a_list:
        c += m % a
    return c
print(f(s-1))

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

using namespace std;

int main(){
  int n;
  cin>>n;
  string alter;
  cin>>alter;
  int r = n-1, l = 0, count = 0;
  while(r!=l && r>l){
    while(r>=0 && alter[r] != 'R')
      	r--;
  	while(l<n && alter[l] != 'W')
    	l++;
    if(r>l){
    alter[r] = 'W';
      alter[l] = 'R';
      count++;
    }
    
}
  cout<<count<<endl;
}

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

dic = {}
for i in range(n):
    dic[i] = input().split()

x = input()

start = 0

for i, (k, v) in enumerate(dic.items()):
    if v[0] not in [x]:
        pass
    else:
        start = i+1
        break

if start==0:
    print(0)

else:
    ans = 0
    for i, (k, v) in enumerate(dic.items()):
        if i < start:
            pass
        else:
            ans += int(v[1])
    print(ans)

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

vector<int> enumerateDivisors(int M) {
    vector<int> res;
    for (int n = 1; n * n <= M; n++) {
        if (M % n == 0) {
            res.push_back(n);
            res.push_back(M / n);
        }
        if (n * n == M) {
            res.pop_back();
        }
    }
    return res;
}

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

    int ans = 1;
    for (auto d : enumerateDivisors(M)) {
        if ((int64_t)N * d <= M) {
            ans = max(ans, d);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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 = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    multiset<int> se;
    rep(i,n) {
        auto it = se.lower_bound(a[i]);
        if(it != se.begin()) {
            it--;
            se.erase(it);
        }
        se.insert(a[i]);
    }
    cout << se.size() << endl;
}


Measured memory_bytes: 5376
import java.io.*;

public class Main{
public static void main(String[] args) {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
String line = reader.readLine();
int x = Integer.parseInt(line);
System.out.println(x*x*x);
} catch (IOException e) {
System.out.println(e);
} catch (NumberFormatException e) {
System.out.println("Please Input Integer.");
}
}
}


Measured memory_bytes: 24236
q, h, s, d = map(int, input().strip().split())
n = int(input())

sorted_list = sorted([(q, 4), (h, 2), (s, 1), (d, 0.5)],
                     key=lambda t: t[0] * t[1])

cheapest = sorted_list[0]
if cheapest[1] == 0.5:
    # 2リットルが最安の場合
    second = sorted_list[1]
    cost = cheapest[0] * (n // 2) + second[0] * (n % 2) * second[1]
else:
    cost = cheapest[0] * cheapest[1] * n

print(cost)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

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

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

    cout << n - k + 1 << endl;


    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.Exception
import java.util.*

fun gcd(a:Int, b:Int):Int {
    val c = a % b
    if (c == 0) return b
    return gcd(b, c)
}

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val lst = mutableListOf<Int>()
    var i = 1
    var sum = 0
    while (lst.count() < n - 1) {
        if (i % 2 == 0 || i % 3 == 0 || i % 5 == 0) {
            lst.add(i)
            sum += i
        }
        i++
        if (lst.count() == n - 1 && sum % 2 != 0 && sum % 3 != 0 && sum % 5 != 0) {
            sum -= lst[n - 2]
            lst.removeAt(n - 2)
        }
    }
    while (i <= 30000) {
        val m = sum + i
        if (m % 30 == 0 && (i % 2 == 0 || i % 3 == 0 || i % 5 == 0)) {
            lst.add(i)
            break
        }
        i++
    }
    println(lst.joinToString(" "))
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 39868
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"h,w,d=map(int,input().split())\n"
"l=[[0,0]]+[[]for _ in range(h*w)]\n"
"for i in range(h):\n"
"    for j,a in enumerate(map(int,input().split())):\n"
"        l[a]=[i,j]\n"
"for a in l[:d]:\n"
"    a.append(0)\n"
"for i,j in zip(l[d:],l):\n"
"    a,b=i\n"
"    x,y,v=j\n"
"    i.append(abs(x-a)+abs(y-b)+v)\n"
"l=[c for a,b,c in l]\n"
"for _ in range(int(input())):\n"
"    a,b=map(int,input().split())\n"
"    print(l[b]-l[a])\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 21744
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;
 
LL N;
LL D[50];
 
LL ans = 0;
 
void solve(){
    vector<int> time_num(13,0);//時刻iの人数をtime_num[i]とする
    time_num[0]++;//高橋くんの都市の分
    for(int i=0;i<N;i++) time_num[D[i]]++;
    //時差0と12は一人までしか許容不可
    if(time_num[0]>=2 || time_num[12]>=2) return;
    //2人までなら時刻i、時刻24-iの二箇所に配置できるが、
    //3人以上いると必ず、最低誰か2人は時刻が被って時差の最小値が0になってしまう
    for(int i=1;i<=11;i++){
        if(time_num[i]>=3) return;
    }

    //被りがないことが保証されたなら次の工程へ
    //被りがないことが保証=各時刻に対し、該当者が必ず2人以下
    vector<int> time_alone,time_twin;//それぞれ、1人しかいない時間帯、2人いる時間帯を格納
    for(int i=1;i<=11;i++){
        if(time_num[i]==1) time_alone.push_back(i);
        if(time_num[i]==2) time_twin.push_back(i);
    }

    //時間iに人がいるかどうかをtime_arrayのibit目が1かどうかで表す
    int time_array = 1;//高橋くんの分
    for(int time : time_twin){
        //時間timeの2人をtime[bit]目と24-time[bit]目にそれぞれ配置
        time_array |= (1<<time);
        time_array |= (1<<(24-time));
    }
    if(time_num[12]==1) time_array |= (1<<12);

    auto search = [&](int bits){
        int min_diff = INF_INT;
        for(int i=0;i<24;i++){
            if(!((bits>>i)&1)) continue;
            for(int j=i+1;j<24;j++){
                if(!((bits>>j)&1)) continue;
                min_diff = min(min_diff,j-i);
                min_diff = min(min_diff,24-(j-i));
            }
        }
        return min_diff;
    };

    if(time_alone.size()==0){
        ans = search(time_array);
        return;
    }

     // auto show_bit = [&](int x){
     //    for(int i=0;i<24;i++) cout << ((x>>i)&1);
     //        cout << endl;
     // };

    //一人しかいない時間帯iについて、
    //その一人をiに配置するのか、24-iに配置するのかで全探索
    int numof_alone = time_alone.size();
    for(int bit=0;bit<(1<<numof_alone);bit++){
        //bitのi[bit]目が立っていれば、
        //時刻time_alone[i]に一人配置、
        //立っていないなら24-time_alone[i]に一人配置する
        int array = time_array;
        //bitのi[bit]目を見る
        for(int i=0;i<numof_alone;i++){
            if((bit>>i)&1) array |= (1<<time_alone[i]);
            else array |= (1<<(24-time_alone[i]));
        }
        //show_bit(array);

        //arrayのibit目が立っていれば時刻iに一人いる
        //arrayのjbit目が立っていれば時刻jに一人いる
        ans = max(ans,(LL)search(array));
    }
}
 
int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> D[i];
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL Mod = 1e9 + 7;
LL n, a, b, ans;

LL qwe(LL a, LL n) { //快速幂
	LL res = 1LL;
	while(n) {
		if(n & 1) res = res * a % Mod;
		a = a * a % Mod;
		n >>= 1LL;
	}
	return res % Mod;
}

LL C(LL n, LL m) { //组合数
	if(m < n - m) m = n - m;
	LL x = 1LL;
	for(LL i = m + 1; i <= n; i++) x = x * i % Mod;
	LL y = 1LL;
	for(LL i = 1; i <= n - m; i++) y = y * i % Mod;
	return x * qwe(y, Mod - 2) % Mod;
	//除法取模只需将除法变乘法即可, 也就是用被除数去乘以除数的乘法逆元
	//求乘法逆元用费马小定理: 当模Mod为素数, x的逆元为qwe(x, Mod - 2)
}

int main() {
	cin >> n >> a >> b;
	ans = ((qwe(2LL, n) - C(n, a) - C(n, b) - 1) % Mod + Mod) % Mod;
	cout << ans << endl;
    return 0;
}

/*
c(n, 1) + ... + c(n, n)
c(n, 0) + ... + c(n, n) = 2 ^ n
=> ans = (2 ^ n) - C(n, a) - C(n, b) - 1
减去一束也不选的情况
*/

Measured memory_bytes: 256