akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] a = new int[n + 1];
		for (int i = 0; i <= n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		long max = a[1] - a[0];
		for (int i = 1; i < n; i++) {
			max = gcd(a[i + 1] - a[i], max);
		}
		System.out.println(max);
	}

	private static long gcd(long m, long n) {
		if (m < n)
			return gcd(n, m);
		if (n == 0)
			return m;
		return gcd(n, m % n);
	}
}


Measured memory_bytes: 50816
#from collections import deque
from pprint import pprint

N,W = map(int,input().split())

wv = [list(map(int,input().split())) for _ in range(N)]

dp = [[float("inf")] * (1000*N+1) for _ in range(N+1)]

dp[0][0] = 0

for i in range(1,N+1):
    for sum_v in range(0,1000*N+1):
        #print(i,sum_v)
        if sum_v >= wv[i-1][1]:
            dp[i][sum_v] = min(dp[i-1][sum_v],dp[i-1][sum_v-wv[i-1][1]] + wv[i-1][0])
        else:
            dp[i][sum_v] = min(dp[i-1][sum_v],dp[i][sum_v])

for j in range(1000*N,-1,-1):
    if dp[N][j] <= W:
        print(j)
        exit()
    


Measured memory_bytes: 311704
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  int t;
  //sd(t);
  //rep(tt,t){
    //cout<<"Case #"<<tt+1<<": ";
    int a[101]={0};
    int n,k,d,l;
    cin>>n>>k;
    rep(i,k){
        cin>>d;
        rep(j,d){
            cin>>l;
            a[l]++;
        }
    }
    int c=0;
    reps(i,1,n+1)
        if(a[i]==0)
            c++;
    cout<<c;
    nline;
  //}
  return 0;
}


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

int main(){
int a=0;
int b=INT_MAX;
int c;
for(int d=0;d<3;d++){
	scanf("%d",&c);
	b=min(b,c);
}
a+=b;
b=INT_MAX;
for(int d=0;d<2;d++){
	scanf("%d",&c);
	b=min(b,c);
}
printf("%d\n",a+b-50);
}

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

int main(){
    int A, B, C;
    cin >> A >> B >> C;

    int D = A * 100 + B * 10 + C;

    if(D % 4 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

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

int main() {
  ll n,ans=0,count=0;
  cin>>n;
  string t;
  vector<string> s;
  for(ll i=0; i<n; i++) {
    cin>>t;
    sort(t.begin(),t.end());
    s.push_back(t);
  }
  sort(s.begin(),s.end());
  for(ll i=1; i<n; i++){
    if(s[i-1] == s[i]) {
      count++;
      ans += count;
    }
    else count = 0;
  }
  cout << ans;
}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {

  int n, m;
  cin >> n >> m;
  vec1 a(m);
  vec1 b(m);
  for(int i = 0; i < m; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  vec1 ans(n);
  for(int i = 0; i < m; i++) {
    ans.at(a.at(i)-1)++;
    ans.at(b.at(i)-1)++;
  }
  for(int i = 0; i < n; i++) {
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long[] arr = new long[n];
    long sum = 0;
    for(int i=0;i<n;i++){
      arr[i] = scan.nextLong();
    }
    
    for(int i=1;i<n;i++){
      if(arr[i-1] > arr[i]){
        long d = arr[i-1] - arr[i];
        arr[i] = arr[i] + d;
        sum = sum + d;
      }
    }
    System.out.println(sum);
        
    
  }
  
}

Measured memory_bytes: 62600
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 300001
#define PI 3.14159265358979323846264338327950
 
#define ll   long long int
#define mod  1000000007


int main()
{
	FAST;
	ll n;
	cin >> n;
	map<string, int> mp;
	for(ll i = 0; i < n; i ++){
		string s;
		cin >> s;
		mp[s] ++;
	}
	cout <<  "AC x " << mp["AC"] << endl;
	cout <<  "WA x " << mp["WA"] << endl;
	cout <<  "TLE x " << mp["TLE"] << endl;
	cout <<  "RE x " << mp["RE"] << endl;
	return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    int total = 0;
    for(int i = 0; i < M; ++i)
    {
        cin >> A.at(i);
        total += A.at(i);
    }
    if(N - total >= 0) cout << N - total << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

int get_int3(int *a1, int *a2, int *a3) {
  scanf("%d %d %d", a1, a2, a3);
  return 0;
}

int get_int4(int *a1, int *a2, int *a3, int *a4) {
  scanf("%d %d %d %d", a1, a2, a3, a4);
  return 0;
}

int get_int5(int *a1, int *a2, int *a3, int *a4, int *a5) {
  scanf("%d %d %d %d %d", a1, a2, a3, a4, a5);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define DIGITS_MAX 10
#define NUM_MAX 1000000

void calc_digit(int num, int *map) {
    while(num) {
        map[num%10] = 1;
        num /= 10;
    }
    return;
}

int main(void) {
    int num, k;
    get_int2(&num, &k);
    int arr[DIGITS_MAX];
    fget_array(arr, k);
    static int xs[10];
    int i, j;
    for(i = 0; i < k; i++) xs[arr[i]] = 1;
    int ans = 0;
    for(i = num; i <= NUM_MAX; i++) {
        int map[10] = {0};
        calc_digit(i, map);
        int flag = 1;
        for(j = 0; j < 10; j++) {
            if(xs[j] == 1 && map[j] == 1) flag = 0;
        }
        if(flag) {
            ans = i;
            break;
        }
    }

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

Measured memory_bytes: 128
import std.stdio, std.string, std.conv;

long solve(long n) {
    import std.algorithm;
    long result = long.max;
    for (long i = 1; i * i <= n; ++i) {
        if (n % i == 0) result = min(result, i+n/i-2);
    }
    return result;
}

void main() {
    long n = readln.chomp.to!long;
    solve(n).writeln;
}

Measured memory_bytes: 380
#include<stdio.h>

int main(void)
{
	int a, b;
	scanf("%d%d", &a, &b);
	if ((a + b) > (a - b)) {
		if ((a + b) > (a*b))
			printf("%d", a + b);
		else
			printf("%d", a*b);
	}
	else {
		if ((a - b) > (a*b))
			printf("%d", a - b);
		else
			printf("%d", a*b);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<bool> vb;
long long int max(long long int a,long long int b){
  if(a>b)
    return a;
  else
    return b;
}
long long int min(long long int a,long long int b){
  if(a<b)
    return a;
  else
    return b;
}
long long int binpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
    }
  return res;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
 
//############################ENDOFTEMPLATE############################




void solve(){
  lli n;
  cin>>n;

  lli ans = 0;
  for(int i = 1;i<=n;i++){
    lli m = n/i;
    ans = ans+ (m*(m+1)*i)/2;
  }

  cout<<ans;
}
 
 
 
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  //freopen("moobuzz.in","r",stdin);
  //freopen("moobuzz.out","w",stdout);
  int t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;

int kyu(int x) {
  if (x < 600) return 8;
  if (x < 800) return 7;
  if (x < 1000) return 6;
  if (x < 1200) return 5;
  if (x < 1400) return 4;
  if (x < 1600) return 3;
  if (x < 1800) return 2;
  return 1;
}


int main() {
  int x; cin >> x;
  cout << kyu(x);
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))

vector<vector<int>> g;

bool get_path(int cur, int pre, int goal, vector<int> &path){
    static map<pair<int,int>, int> path_id;
    if (cur == goal) return true;
    for(int to : g[cur]){
        if(to == pre) continue;
        pair<int,int> p = {min(cur, to), max(cur, to)};
        int id = path_id.count(p) ? path_id[p] : path_id.size();
        path_id[p] = id;
        path.push_back(id);
        if (get_path(to, cur, goal, path)) {
            return true;
        } else {
            path.pop_back();
        }
    }
    return false;
}

int main(void){
    int n;
    cin >> n;
    g.resize(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int m;
    cin >> m;
    vector<vector<int>> paths(m);
    rep(i,m){
        int u, v;
        cin >> u >> v;
        u--, v--;
        get_path(u, -1, v, paths[i]);
    }
    long long res = 0;
    rep(mask, 1<<m){
        vector<bool> on(n);
        rep(i,m){
            if (bit(i) & mask) {
                for(int e : paths[i]) {
                    on[e] = true;
                }
            }
        }
        res += (((int)__builtin_popcount(mask) & 1) ? -1 : +1) * (1LL<<((n-1)-count(all(on), true)));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(array##_itr, array) { cin >> *(array##_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	cin >>n;
	Vi b(n);
	input(b);
	Vi ans;
	bool can  = true;
	int legth = b.size();
	rep(I, legth) {
		can = false;
		for (int i = b.size() - 1; i >= 0 and b.size() != 0 and can==false; i--) {
			if (i + 1 == b[i]) {
				can = true;
				ans.pb(b[i]);
			//	clog << b[i] << endl;
				b.erase(b.begin() + i);
			}
		}
		if (can == false) {
			cout << -1 << endl;
			return 0;
		}
	}
	reverse(all(ans));
	repi(itr, ans) { cout << *itr << endl; }
}

Measured memory_bytes: 3636
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	s := nextString()
	t := nextString()
	ss := []byte(s)
	tt := []byte(t)
	for i := 0; i < n; i++ {
		fmt.Print(string(ss[i]))
		fmt.Print(string(tt[i]))
	}
	fmt.Println()
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


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

constexpr size_t get_cost(size_t height_a, size_t height_b) {
  return height_a < height_b ? height_b - height_a : height_a - height_b;
}

size_t cheapest_route_cost(const std::vector<size_t> &heights) {
  if (heights.size() <= 1u) {
    return 0u;
  }

  size_t cost_a{0};
  size_t cost_b = get_cost(heights[0], heights[1]);
  for (size_t i = 2u; i < heights.size(); ++i) {
    const size_t height = heights[i];
    const size_t cost_from_a = cost_a + get_cost(height, heights[i - 2]);
    const size_t cost_from_b = cost_b + get_cost(height, heights[i - 1]);
    const size_t cost = std::min(cost_from_a, cost_from_b);

    cost_a = cost_b;
    cost_b = cost;
  }

  return cost_b;
}

int main() {
  size_t count{0};
  std::cin >> count;

  std::vector<size_t> heights;
  heights.reserve(count);

  for (size_t i = 0; i < count; ++i) {
    size_t cost{0};
    std::cin >> cost;
    heights.push_back(cost);
  }

  std::cout << cheapest_route_cost(heights) << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;

//typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll MAX = 1e9 + 5;

int main() {
	string s;
	cin >> s;
	int k;
	cin >> k;
	int n = s.length();
	for (int i = 0; i < n; i++) {
		int num = ('z' - s[i] + 1) % 26;
		if (num <= k) {
			s[i] = 'a';
			k -= num;
		}
	}

	if (k == 0) {
		cout << s << endl;
		return 0;

	}
	//cout << (s[n - 1] - 'a') + k << endl;
	s[n - 1] = 'a' + ((s[n-1]-'a') +k) % 26;
	cout << s << endl;
}

Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

int a[2003];
bitset<4000003> seg;

int main() {
	int n; cin >> n;
	int sum = 0;
	for (int i = 0; i < n; ++i) cin >> a[i], sum += a[i];
	seg[0] = true;
	for (int i = 0; i < n; ++i) {
		seg |= (seg << a[i]);
	}
	for (int i = (sum + 1)/2; i <= sum; ++i) {
		if (seg[i]) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 1e2 + 5;

int a[MAXN];

int main(void)
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; ++i) scanf("%d",&a[i]);
	
	int ans = 1e9;
	for(int k=1; k<=100; ++k)
	{
		int tmp=0;
		for(int i=1; i<=n; ++i)
			tmp += (a[i]-k)*(a[i]-k);
		if(ans>tmp) ans=tmp;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, H;
    cin >> N >> H;
    vector<pair<int, int>> A(N);
    rep(i, N) cin >> A[i].first >> A[i].second;
    sort(all(A));
    int con = A.back().first;
    vector<int> B(N);
    rep(i, N) B[i] = A[i].second;
    sort(all(B));
    reverse(all(B));
    int ind = 0;
    int ans = 0;
    if(B.size()){
        while(con < B[ind] && H > 0 && ind < N){
            H -= B[ind];
            ind++;
            ans++;
        }
    }
    

    
    if(H > 0){
        ans += (H + con - 1) / con;
    }
    
    output(ans);
    
    return 0;
}


Measured memory_bytes: 1408
n=int(input())
a=list(map(int,input().split()))
d={}
ans=0
for key in a:
    try:
        d[key]+=1
    except:
        d[key]=1
    ans+=key

q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    try:
        x=d[b]
        try:
            y=d[c]
            ans+=(c-b)*x
            d[b]=0
            d[c]+=x
            print(ans)
        except:
            d[c]=x
            ans+=(c-b)*x
            d[b]=0
            print(ans)
    except:
        print(ans)


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

const long long MOD=1000000007;

map<long long, int> fac_all;

void prime_factor(long long n){
    for(long long i=2; i*i<=n; i++){
        while(n%i==0){
            fac_all[i]++;
            n /= i;
        }
    }
    if(n!=1) fac_all[n]++;
}

int main(){
    //input
    long long N;
    cin >> N;

    //calc
    int i;
    for(i=2; i<=N; i++){
        prime_factor(i);
    }
    long long ans=1;
    for(auto p : fac_all){
        ans*=(long long)(p.second+1);
        ans%=MOD;
    }
    
    //output
    cout << ans << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3712
import itertools


N, K = map(int, input().split())
a = list(map(int, input().split()))
ans = float('inf') 

for pattern in itertools.combinations(range(1,N),K-1):
    temp_cost = 0
    temp_pattern = [0] + list(pattern)
    max_high = a[0]

    for i in range(1,N):
        if i in temp_pattern:
            diff = a[i]- max_high
            if diff ==  0:
                temp_cost += 1
                max_high = max_high + 1
            elif diff < 0 :
                temp_cost += ( max_high - a[i] ) + 1
                max_high = max_high +1
            else:
                temp_cost += 0
                max_high = a[i]
        else:
            max_high = max (a[i] ,max_high)

    ans = min(ans, temp_cost)

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int x, y;
	cin >> x >> y;
	if (x%y == 0)print(-1);
	else print(x);




	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll n, m, d;
	cin >> n >> m >> d;
	long double ans = (n - d) * 2;
	if (d == 0)ans = n;
	ans = ans * (m - 1) / n / n;
	cout << fixed << setprecision(20) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

static const int N = 1000;

static int lcs(string& s1, string& s2) {
	int table[N + 1][N + 1];
	int m = s1.size();
	int n = s2.size();
	int max_len = 0;
	s1 = ' ' + s1;
	s2 = ' ' + s2;

	for (int i = 0; i <= m; i++) table[i][0] = 0;
	for (int j = 0; j <= m; j++) table[0][j] = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if (s1[i] == s2[j]) {
				table[i][j] = table[i - 1][j - 1] + 1;
			}
			else {
				table[i][j] = max(table[i - 1][j], table[i][j - 1]);
			}

			max_len = max(table[i][j], max_len);
		}
	}

	return max_len;
}

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

	for (int i = 0; i < n; i++) {
		string s1, s2;
		cin >> s1 >> s2;
		cout << lcs(s1, s2) << endl;
	}

	return 0;
}

Measured memory_bytes: 7056
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
const int M = 39;
int main() {
    int N;
    cin >> N;
    i64 S = (1ll << M) - 1;
    i64 mod = -1;
    vector<string> ans;
    for(int i = 0; i < N; i++) {
        i64 X, Y;
        cin >> X >> Y;
        if(!i) {
            mod = (X + Y + 1) & 1;
        } else {
            if(mod != ((X + Y + 1) & 1)) {
                cout << -1 << endl;
                return 0;
            }
        }
        string w = "";
        if (mod) {
            w = "L";
            X++;
        }
        i64 V = X + Y + S;
        i64 W = X - Y + S;
        for(int i = 0; i < M; i++) {
            int a = (V >> (i + 1)) & 1, b = (W >> (i + 1)) & 1;
            char c;
            if(a && b) { // Right
                c = 'R';
            } else if(a && !b) { // Up
                c = 'U';
            } else if(b && !a) { // Down
                c = 'D';
            } else { // Left
                c = 'L';
            }
            w.push_back(c);
        }
        ans.push_back(w);
    }
    cout << M + mod << endl;
    if(mod) cout << "1";
    for (int i = mod; i < M + mod; i++) {
        cout << (i ? " " : "") << (1ll << (i - mod));
    }
    cout << endl;
    for(auto a : ans) {
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
  int input;
  int k = 1;
  int trgdeg = 360;
  
  scanf("%d",&input);
  
  while(((input * k) % trgdeg) != 0) {
    k++;
  }
  
  printf("%d", k);
  
  return 0;
}


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

int main(){




int n;
cin>>n;

int ac = 0,wa = 0,tle = 0,re = 0;

while(n-- != 0){

string s;
cin>>s;



if(s[0] == 'A'){
	ac++;
}
else if(s[0] == 'W'){
	wa++;
}
else if(s[0] == 'T'){
	tle++;
}
else {
	re++;
}

}


cout<<"AC"<<" x "<<ac<<"\n";
cout<<"WA"<<" x "<<wa<<"\n";
cout<<"TLE"<<" x "<<tle<<"\n";
cout<<"RE"<<" x "<<re<<"\n";




}

Measured memory_bytes: 3196
#include<stdio.h>
int gcd(long int x, long int y)
{
    long int r;
    if(y>x)
    {
        r=x;
        x=y;
        y=r;
    }
    while(y%x!=0)
    {
        r=y%x;
        y=x;
        x=r;
    }
    return x;
}
main()
{
    long int n, i, a[12], j, p=1, c=0, f;
    scanf("%ld", &n);
    for(i=0; i<n; i++)
    {
        scanf("%ld", &a[i]);
        c=gcd(a[i], p);
        p*=a[i];
        p=p/c;
    }
    printf("%ld\n", p);
    return 0;
}


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

if n == 1:
    print('a')
    exit()

def dfs(s, cmax):
    if len(s) == n:
        print(s)
    else:
        for i in range(ord(cmax)-ord('a')+2):
            c = chr(i+ord('a'))
            if ord(c) < ord(cmax):
                dfs(s+c, cmax)
            else:
                dfs(s+c, c)

dfs('a', 'a')

Measured memory_bytes: 56152
//Love and Freedom.
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#define inf 20021225
#define ll long long
#define N 200010
using namespace std;
int read()
{
	int f=1,s=0; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9')	s=s*10+ch-'0',ch=getchar();
	return f*s;
}
int a[N],n,t[N],f[N];
bool check(int x,int y,int z){return (x<y&&y<z)||(y<z&&z<x)||(z<x&&x<y);}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)	a[read()]=i;
	for(int i=n-1;i;i--)
	{
		if(!t[i+1])
		{
			if(a[i]>a[i+1])	t[i]=1,f[i]=a[i+1];
		}
		else
		{
			if(check(f[i+1],a[i],a[i+1]))
				t[i]=t[i+1],f[i]=f[i+1];
			else
				t[i]=t[i+1]+1,f[i]=a[i+1];
		}
	}
	printf("%d\n",t[1]);
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>

int m,n,ans;
int ice[92][92];

void saiki(int w,int h,int l){
	ice[w+1][h+1]=0;
	
	if(ice[w+2][h+1]==1)saiki(w+1,h,l+1);
	if(ice[w+1][h+2]==1)saiki(w,h+1,l+1);
	if(ice[w][h+1]==1)saiki(w-1,h,l+1);
	if(ice[w+1][h]==1)saiki(w,h-1,l+1);
	
	ans=ans>l?ans:l;
	
	ice[w+1][h+1]=1;
	return;
	
}

int main(void){

	for(;;){
		scanf("%d %d",&m,&n);
		if(!m||!n)break;
		
		for(int i=0;i<92;i++){
			for(int j=0;j<92;j++){
				ice[i][j]=0;
			}
		}
		ans=0;
		
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				scanf("%d",&ice[i+1][j+1]);
			}
		}
		
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				if(ice[i+1][j+1])saiki(i,j,1);
			}
		}
/*		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				printf("%d ",ice[i+1][j+1]);
			}puts("");
		}*/
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mod 1e9+7
int main() {
	ios_base::sync_with_stdio(false);
	cout.tie(0); cin.tie(0);
 int n;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int c=0;
  for(int i=0;i<n;i++)
  {for(int j=i+1;j<n;j++)
  {for(int k=j+1;k<n;k++)
  {
  if((a[i]+a[j]>a[k])&&(a[i]+a[k]>a[j])&&(a[k]+a[j]>a[i])&&(a[i]!=a[j])&&(a[i]!=a[k])&&(a[j]!=a[k]))
    { c++; }}}}
  cout<<c;
    
}

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

using namespace std;

template <typename T,typename E>
struct SegmentTree{
private:
    typedef std::function<T(T,T)> F;
    typedef std::function<T(T,E)> G;
    int n;
    std::vector<T> init;
    F f;//function for caliculate
    G g;//function for update
    std::vector<T> node;

public:
    explicit SegmentTree(
            int sz,
            F cal,
            G upd
    ){
        n=1;
        f=cal;
        g=upd;
        while(n<sz)n=n*2;
        node.assign(static_cast<unsigned int>(2 * n - 1), bitset<26>(0));
        for (int i = 0; i <sz ; ++i) node[i+n-1]=bitset<26>(0);
        for (int i = n-2; i >= 0 ; --i) node[i]=f(node[2*i+1],node[2*i+2]);
    }

    void update(int x, E val){//x:0-indexed
        x+=n-1;
        node[x]=g(node[x],val);
        while(x>0){
            x=(x-1)/2;
            node[x]=f(node[2*x+1],node[2*x+2]);
        }
    }

    T query(int p,int q,int k=0,int l=0,int r=-1){//[p,q):0-indexed
        if(r<0)r=n;
        if(r<=p||l>=q)return bitset<26>(0);//out of range
        if(p<=l&&r<=q)return node[k];

        return f(query(p,q,2*k+1,l,(l+r)/2),query(p,q,2*k+2,(l+r)/2,r));
    }
};

void solve(){
    int n,q;
    string s;
    std::cin>>n>>s>>q;
    SegmentTree<bitset<26>,int> st(n,
                            [](bitset<26> a,bitset<26> b){return a|b;},//example for RMQ
                            [](bitset<26> a,int b){bitset<26> ret(0); return ret.set(b);}
    );
    for (int i = 0; i < n; ++i) {
        st.update(i,s[i]-'a');
    }
    for (int i = 0; i < q; ++i) {
        int x,y;
        cin>>x>>y;
        --y;
        if(x==1){
            char z;
            cin>>z;
            st.update(y,(int)(z-'a'));
        }
        else{
            int z;
            cin>>z;

            auto v=st.query(y,z);
            int ans=0;

            cout<<v.count()<<endl;
        }
    }
}

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

Measured memory_bytes: 9220
import itertools
n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]

v = list(itertools.combinations_with_replacement(range(1, m+1), n))
ans = 0
for i in v:
    s = 0
    for a, b, c, d in abcd:
        if i[b-1] - i[a-1] == c:
            s += d
    ans = max(ans, s)
print(ans)

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

int numberDivideByTwo(int n)
{
    int num = 0;

    while(n > 0)
    {
        if (n % 2 == 0)
        {
            n /= 2;
            num++;
        }
        else
        {
            break;
        }
    }
    return num;
}


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

    int max_num = 0;
    int res = 1;
    for (int i = 1; i < N+1; i++)
    {
        int div_num = numberDivideByTwo(i);
        if (div_num > max_num)
        {
            max_num = div_num;
            res = i;
        }
    }

    cout << res << endl;

    return 0;
}

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

int main() {
    char s1[1000001];
    char s2[10001];
    int i, j, k;

    scanf("%s", s1);
    scanf("%s", s2);
    
    int s1len = strlen(s1);
    int s2len = strlen(s2);

    for (i = 0; i < s1len; i++) {
        if(strncmp(s2, &s1[i], s2len)==0) printf("%d\n", i);
    }

    return 0;
}

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


int main(){


    int n, i, t;

    int s = 0;

    vector<int> w; 

    vector<int> s1; 

    vector<int> s2;

    vector<int> a;


    cin >> n;


    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> t;

         w.push_back(t);

         s += t;

         }


    t = 0;


    for( i = 0 ; i < n ; i = i + 1 ){

         t += w.at(i);

         s1.push_back(t);

         s2.push_back(s - t);

         }


    for( i = 0 ; i < n ; i = i + 1 ){

         a.push_back( abs( s2.at(i) - s1.at(i) ) );         

         }


    sort( a.begin(), a.end() );	


    cout << a.at(0) << endl;


    return 0;

    }


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==b){printf("Draw\n");return 0;}
    if(a==1||a>b&&b!=1){printf("Alice\n");return 0;}
    if(b==1||a<b&&a!=1){printf("Bob\n");return 0;}
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iomanip>
#include<iostream>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;

int main()
{
    double v,t,a,x;
    a=9.8;
    while(cin>>v)
    {
        t= v/a;
        x=(a* pow(t,2))*.5;


        int result=0;
        result=(int)x/5;
        int y=x;
        if(y<x)
        result++;

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

Measured memory_bytes: 1224
import math
def main(a, b, c):
    for i in range(b):
        if (a * i) % b == c:
            print('YES')
            return

    print('NO')

if __name__ == "__main__":
    a, b, c = [int(x) for x in input().split()]
    main(a, b, c)

def test1(capsys):
    inputs = [7, 5, 1]
    out = 'YES'
    main(*inputs)
    captured = capsys.readouterr()    
    assert captured.out == str(out) + '\n'

def test3(capsys):
    inputs = [2, 2, 1]
    out = 'NO'
    main(*inputs)
    captured = capsys.readouterr()    
    assert captured.out == str(out) + '\n'

def test4(capsys):
    inputs = [1, 100, 97]
    out = 'YES'
    main(*inputs)
    captured = capsys.readouterr()    
    assert captured.out == str(out) + '\n'

def test5(capsys):
    inputs = [40, 98, 58]
    out = 'YES'
    main(*inputs)
    captured = capsys.readouterr()    
    assert captured.out == str(out) + '\n'

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define   ll          long long int
#define   sz          200010
#define   sc(a)       scanf("%lld",&a)
#define   sc2(a,b)    scanf("%lld %lld",&a,&b)
#define   py          printf("Yes\n")
#define   pn          printf("No\n")
using namespace std;

vector<ll>vt[sz];
vector<ll>cl[sz];
queue<ll>q;
map<pair<ll,ll>,ll>mp;
ll vis[sz];
queue<pair<ll,ll> >qq;

ll tani(ll v,ll k)
{
    ll i,j,n;

    for(i=1; i<=k; i++)vis[i]=0;

    for(i=0; i<cl[v].size(); i++)
    {
        vis[cl[v][i]]=1;
    }

    for(i=1; i<=k; i++)
    {
        if(vis[i]==0)return i;
    }


}
ll vs[sz];

int main()
{

    ll a,b,x,y,n,m,p,d,k=0,i,j,u,v;

    sc(n);

    for(i=1; i<n; i++)
    {
        sc2(a,b);
        vt[a].push_back(b);
        vt[b].push_back(a);
        qq.push({a,b});
    }

    for(i=1; i<=n; i++)
    {
        p=vt[i].size();
        k=max(k,p);
    }

    q.push(1);
    vs[1]=1;

    while(!q.empty())
    {
        u=q.front();
        q.pop();

        for(i=0; i<vt[u].size(); i++)
        {

            v=vt[u][i];
            if(vs[v]==0)
            {
                p=tani(u,k);
              // cout<<v<<" "<<p<<endl;
                mp[{u,v}]=p;
                cl[v].push_back(p);
                cl[u].push_back(p);
                q.push(v);
                vs[v]=1;
            }
        }
    }

    printf("%lld\n",k);

    while(!qq.empty())
    {
        a=qq.front().first;
        b=qq.front().second;

        p=mp[{a,b}];
        printf("%lld\n",p);

        qq.pop();
    }
    return 0;
}



Measured memory_bytes: 27008
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,cnt,cnt1,h,h1;
    cin>>n;
    cnt=n/500;
    h=cnt*1000;
    n=n%500;
    cnt1=n/5;
    h1=cnt1*5;
    cout<<h+h1;
}


Measured memory_bytes: 256
from sys import stdin

input = stdin.readline


def read():
    return tuple(map(int, input().split()))


def main():
    input()
    A = read()
    B = read()
    pre = A[0]
    ans = 0
    for a, b in zip(A[1:], B):
        tmp1 = pre if pre < b else b
        b -= tmp1
        tmp2 = a if a < b else b
        ans += tmp1 + tmp2
        pre = a - tmp2
    print(ans)
    return


main()


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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    int N, K, Q, A;
    cin >> N >> K >> Q;
    vector<int> P(N, 0);
    rep(i, Q) {
        cin >> A;
        A--;
        P[A]++;
    }
    rep(i, N) {
        if (K - Q + P[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }    
}

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

using namespace std;

int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}

int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	int maxn=a,minn=b;
	if(a<b){
		swap(maxn,minn);
	}
	int res=gcd(maxn,minn);
	printf("%d\n",res);
	return 0;
}



Measured memory_bytes: 3192
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int x, y, z; cin >> x >> y >> z;
	int amari = x % (y + z);

	if (amari < z) cout << x / (y + z) - 1 << endl;
	else cout << x / (y + z) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string S;
	scan(S);
	int ans[100001]={};
	int N=S.size();
	int Rnum=0;
	rep(i,N){
		if(S[i]=='R'){
			Rnum++;
		}
		else{
			ans[i]+=Rnum/2;
			ans[i-1]+=Rnum-Rnum/2;
			Rnum=0;
		}
	}
	int Lnum=0;
	for(int i=N-1;i>=0;i--){
		if(S[i]=='L'){
			Lnum++;
		}
		else{
			ans[i]+=Lnum/2;
			ans[i+1]+=Lnum-Lnum/2;
			Lnum=0;
		}
	}
	rep(i,N){
		printf("%d ",ans[i]);
	}
	kaigyo;
	return 0;
}


Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


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

	VI v(n);
	int a[100001] = {};
	int tmp;
	REP(i, n) {
		cin >> tmp;
		a[tmp]++;
	}

	int M = 0;
	FOR(i, 1, 100000 - 1) {
		M = max(M, a[i - 1] + a[i] + a[i + 1]);
	}

	ANS(M);

	return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include<iostream>
using namespace std;
int n,s,t,u,a;
int count[4][3][10];
int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s >> t >> u;
        cin >> a;
        count[s-1][t-1][u-1] += a;
    }
    for(int i=0;i<4;i++){
        for(int x=0;x<3;x++){
            for(int y=0;y<10;y++){
                cout << " " << count[i][x][y];
            }
            printf("\n");
        }
        if(i<3)    cout << "####################" << endl;
    }
}


Measured memory_bytes: 3092
N = int(input())
M=0
A=0
R=0
C=0
H=0
namelist=[]
for _ in range(N):
    namelist.append(str(input()))
for i in range(N):
    if namelist[i][0] == "M":
      M += 1
    elif namelist[i][0] == "A":
      A += 1
    elif namelist[i][0] == "R":
      R += 1
    elif namelist[i][0] == "C":
      C += 1
    elif namelist[i][0] == "H":
      H += 1
    else:
       pass
num= M*A*R + M*A*C + M*A*H + M*R*C + M*R*H + M*C*H + A*R*C + A*R*H + A*C*H + R*C*H
print(num)

Measured memory_bytes: 9772
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n").map(Number);
while(true){
   var n=arr.shift();
   if(n==0)break;
   var max=0;
   for(var i=0;i<=54;i++){
      for(var j=0;j<=96;j++){
         var sum=i*i*i+(j*(j+1)*(j+2))/6;
         if(n>=sum)max=Math.max(max,sum);
      }
   }
   console.log(max);
}

Measured memory_bytes: 18012
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,f,g,h,j,i;
	while(1){
		scanf("%d",&a);
		if(a==-1) break;
		if(a<10) s=1150;
		else if(a<20) s=1150+(a%10)*125;
		else if(a<30) s=1150+1250+(a%10)*140;
		else s=1150+1250+1400+(a-30)*160;
		printf("%d\n",4280-s);
	}
	return 0;
}

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

typedef long long      ll;
typedef vector<int>    vi;
typedef vector<string> vs;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n)    FOR(i, 0, n)
#define pb           push_back
#define all(a)       (a).begin(), (a).end()
#define UNIQUE(v)    v.erase(unique(all(v)), v.end());
#define fill(a, x)   memset(a, x, sizeof(a))
#define zero(a)      fill(a, 0)
#define minus(a)     fill(a, -1)
#define dbg(x)       cout << #x "=" << x << endl

vi resq;

struct Command {
  string op;
  int    num;
};

struct Node {
  int   key;
  Node *prev, *next;
};

// 番兵
Node *sentinel;

void init() {
  sentinel = (Node *)malloc(sizeof(Node));
  sentinel->next = sentinel;
  sentinel->prev = sentinel;
}

// LinkedListの先頭に一つ要素を一つ挿入する関数
void insert(int key) {
  Node *new_node = (Node *)malloc(sizeof(Node));
  new_node->key = key;
  new_node->next = sentinel->next;
  // 元々sentinelの次の要素のprevはsentinelを指していたのをnew_nodeを指すように変えた
  sentinel->next->prev = new_node;
  sentinel->next = new_node;
  new_node->prev = sentinel;
}

Node *listSearch(int key) {
  Node *cur = sentinel->next;
  // 一番最後の要素はsentinelをnextとして持っている?
  while (cur != sentinel && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void deleteNode(Node *t) {
  if (t == sentinel) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(sentinel->next);
}

void deleteLast() {
  deleteNode(sentinel->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void printList() {
  Node *cur = sentinel->next;
  while (cur != sentinel) {
    printf("%d%c", cur->key, cur->next == sentinel ? '\n' : ' ');
    cur = cur->next;
  }
}

int main() {
  ios::sync_with_stdio(false);
  int             n;
  int             c = 0;
  vector<Command> q;
  cin >> n;

  init();

  while (c < n) {
    string op;
    cin >> op;
    int num;

    if (op == "deleteFirst" || op == "deleteLast") {
      num = 0;
    } else {
      cin >> num;
    }

    if (op == "insert") {
      insert(num);
    }
    if (op == "delete") {
      deleteKey(num);
    }
    if (op == "deleteFirst") {
      deleteFirst();
    }
    if (op == "deleteLast") {
      deleteLast();
    }
    c++;
  }

  printList();
  return 0;
}



Measured memory_bytes: 34400
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
    ll H,W;
    cin >> H >> W;
    ll ans = 0;
    if(H==1 || W==1){
        ans = 1;
    } else {
        ans += ((W+1)/2) * ((H+1)/2);
        ans += (W/2)*(H/2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
use itertools::Itertools as _;
use maplit::hashset;
use proconio::{fastout, input, marker::Usize1};
use std::cmp;

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        ijs: [(Usize1, Usize1)],
    }

    let mut by_ij = hashset!();
    let mut by_i = vec![0u64; h];
    let mut by_j = vec![0u64; w];

    for &(i, j) in &ijs {
        by_ij.insert((i, j));
        by_i[i] += 1;
        by_j[j] += 1;
    }

    let mut ans = 0;

    for (i, j) in ijs {
        ans = cmp::max(ans, (by_i[i] + by_j[j]).saturating_sub(1));
    }

    let mut by_i = by_i
        .into_iter()
        .enumerate()
        .sorted_by_key(|&(_, n)| n)
        .collect::<Vec<_>>();

    let mut by_j = by_j
        .into_iter()
        .enumerate()
        .sorted_by_key(|&(_, n)| n)
        .collect::<Vec<_>>();

    while let (Some((i, n)), Some((j, m))) = (by_i.pop(), by_j.pop()) {
        if !by_ij.contains(&(i, j)) {
            let ans = cmp::max(ans, n + m);
            println!("{}", ans);
            return;
        }
        if n < m {
            by_j.push((j, m));
        } else {
            by_i.push((i, n));
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 28504
import java.util.Scanner;
public class Main {
	 public static void main(String args[]){
	Scanner scanner = new Scanner(System.in);
	// "abc"という文字列
	String a=scanner.next();

	 String str3 = String.valueOf(a.charAt(2));
	    String str4 = String.valueOf(a.charAt(3));
	    String str5 = String.valueOf(a.charAt(4));
	    String str6 = String.valueOf(a.charAt(5));
	    if(str3.equals(str4) && str5.equals(str6)){
	    		System.out.println("Yes");
	    }
	    else {
	    	System.out.println("No");
	    }

	}
}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char a = sc.next().charAt(0);
		char b = sc.next().charAt(0);
		if(a > b)System.out.println(">");
		else if(a < b)System.out.println("<");
		else System.out.println("=");
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

bool finder(vector<string>& w, string tmp){
	for(int i=0; i<w.size(); i++){
		if (w[i]==tmp){
			return false;
		}
	}
	return true;
}
	

int main(){
	bool flg = true;
	int n;
	string tmp;
	vector<string> w;
	cin >> n;
	cin >> tmp;
	w.push_back(tmp);
	for (int i=0; i < n-1; i++){
		cin >> tmp;
		string last_w = w.back();
		if (tmp[0] != last_w[last_w.size()-1]){
			flg = false;
		}else if(finder(w, tmp)==false){
			flg = false;
		}else{
			w.push_back(tmp);
		}
	}
	if (flg){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	map<ll,int> mp;
	int n;
	cin>>n;
	for(int i=0;i<n;++i){
		int x;
		cin>>x;
		mp[x]++;
	}
	auto it=mp.end();
	ll f=-1,s=-1;
	ll res=0;
	do{
		it--;
		if(it->second>=2){
			if(it->second>=4){
				ll side=it->first;
				res=max(res,side*side);
			}
			if(f==-1) f=it->first;
			else if(s==-1) s=it->first;
		}
		if(~f&&~s)
			res=max(res,f*s);
	} while(it!=mp.begin());
	cout<<res<<'\n';
}



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

using namespace std;

int main()
{
    long n, m;
    cin>>n>>m;

    vector<long> a(n);
    vector<pair<long, long> > bc(m);

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

    long b, c;
    for(int i=0; i<m; i++)
    {
        cin>>b>>c;
        bc.push_back(make_pair(c, -b));
    }

    sort(a.begin(), a.end());
    sort(bc.begin(), bc.end());

    /*for(int i=0; i<n; i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;*/

    long temp, counter;
    bool ind=false;
    for(int i=0; i<n; i++)
    {
        ind=false;
        temp=bc.back().first;
        counter=(-1) * bc.back().second;
        for(int j=0; j<counter; j++)
        {
            if(a[i]<temp)
            {
                a[i]=temp;
                i++;
                ind=true;
            }
            else    break;
        }
        if(ind) i--;
        bc.pop_back();
    }

    /*a.resize(n);
    for(int i=0; i<n; i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
    */

    long long ans = 0;
    //ans=accumulate(a.begin(), a.end(), 0);
    for(int i=0; i<n; i++)
    {
        ans+=a[i];
    }
    cout<<ans;

    /*long long ans=1000000000*10+1;
    cout<<ans;
    cout<<endl<<1000000000*10+1;*/
    return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string a[10001];
int main()
{
	int n;
	cin >> n;
	int dap = 0;
	int cnt = 0, cnt1 = 0, cnt2 = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		int t = a[i].size();
		for (int y = 0; y < t - 1; y++) {
			if (a[i][y] == 'A'&&a[i][y + 1] == 'B')
				dap++;
		}
		int update = 0;
		if (a[i][t - 1] == 'A'&&a[i][0] == 'B')
			cnt2++;
		else if (a[i][t - 1] == 'A')
			cnt++;
		else if (a[i][0] == 'B') 
			cnt1++;
	}
	if (cnt2) {
		dap += (cnt2 - 1);
		if (cnt) {
			dap++; cnt--;
		}
		if (cnt1) {
			dap++; cnt1--;
		}
	}
	int gap = min(cnt, cnt1);
	dap += gap;
	printf("%d\n", dap);
}


Measured memory_bytes: 768