akhauriyash/Code-Regression huggingface dataset:
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, x; readV(n, x);
  int[] a; readA(n, a);

  auto ans = 0L;
  foreach (i; 1..n) {
    if (a[i-1]+a[i] > x) {
      auto r = min(a[i], a[i-1]+a[i]-x);
      a[i] -= r;
      ans += r;

      if (a[i] == 0) {
        r = a[i-1]-x;
        ans += r;
      }
    }
  }

  writeln(ans);
}


Measured memory_bytes: 4220
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val values = readLine()?.split(" ")?.map(String::toInt) ?: return
    values.forEach {
        if (it % 2 == 0 && it % 3 != 0 && it % 5 != 0) {
            println("DENIED")
            return
        }
    }
    println("APPROVED")
}


Measured memory_bytes: 37864
def main():
    INF = float("inf")

    N, M, P, *ABC = map(int, open(0).read().split())

    F = [[] for _ in range(N)]
    B = [[] for _ in range(N)]
    E = [(a - 1, b - 1, P - c) for a, b, c in zip(*[iter(ABC)] * 3)]

    for a, b, c in E:
        F[a].append(b)
        B[b].append(a)

    S = {0}
    stack = [0]
    while stack:
        s = stack.pop()
        for v in F[s]:
            if v not in S:
                stack.append(v)
                S.add(v)

    T = {N - 1}
    stack = [N - 1]
    while stack:
        s = stack.pop()
        for v in B[s]:
            if v not in T:
                stack.append(v)
                T.add(v)

    ok = S & T

    D = [INF] * N
    D[0] = 0

    def bellman_ford(N):
        for _ in range(N):
            update = False
            for a, b, c in E:
                if a in ok and b in ok and D[b] > D[a] + c:
                    D[b] = D[a] + c
                    update = True
            if not update:
                return False
        return True

    bellman_ford(N)

    print(-1 if bellman_ford(1) else max(-D[-1], 0))



if __name__ == '__main__':
    main()


Measured memory_bytes: 48496
package main

import "fmt"

// import "fmt"
func readline(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	return a
}

func readInt() int {
	var a int
	fmt.Scan(&a)
	return a
}

func readTaple() (int, int) {
	var a, b int
	fmt.Scan(&a)
	fmt.Scan(&b)
	return a, b
}

func main() {
	a, p := readTaple()
	fmt.Println((3*a + p) / 2)
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  double x = ceil((double)c/b);
  double y = ceil((double)a/d);
  
  if(x <= y){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


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

#define int long long
#define form2(i, a, b) for (int i = (a); i < (b); ++i)
#define ford2(i, a, b) for (int i = (a-1); i >= (b); --i)
#define form(i, n) form2(i, 0, n)
#define ford(i, n) ford2(i, n, 0)

#define chmax(x, v) x = max(x, (v))
#define chmin(x, v) x = min(x, (v))
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define vsz(v) (int)(v.size())

const long long BIG = 1000000000000000000LL;

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

void solve();
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

const int borne = 5005;
int tab[borne];
bool pref[borne][borne];
bool suff[borne][borne];
int n,k;

void solve()
{
	cin >> n >> k;
	form(i, n) cin >> tab[i];
	pref[0][0] = suff[n-1][0] = true;
	form(i, n) {
		form(v, k) {
			pref[i+1][v] |= pref[i][v];
			if (v >= tab[i]) pref[i+1][v] |= pref[i][v - tab[i]];
		}
	}
	ford(i, n) if (i > 0) {
		form(v, k) {
			suff[i-1][v] |= suff[i][v];
			if (v >= tab[i]) suff[i-1][v] |= suff[i][v - tab[i]];
		}
	}

	int cnt = 0;
	form(i, n) {
		bool estUtile = false;
		int c2 = k-1;
		form(c1, k) {
			while (c1+c2 >= k || suff[i][c2] == false) --c2;
			if (pref[i][c1] && c1+c2+tab[i] >= k) { estUtile = true; break; }
		}
		if (!estUtile) ++cnt;
	}
	cout << cnt << "\n";
}


Measured memory_bytes: 49152
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    plst = list(map(float, input().split()))
    dp = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
    dp[0][0]= 1
    for i in range(1, n + 1):
        for j in range(i + 1):
            dp[i][j] = dp[i - 1][j - 1] * plst[i - 1] + dp[i - 1][j] * (1 - plst[i - 1])
    ans = 0
    for i in range(n // 2 + 1, n + 1):
        ans += dp[-1][i]
    print(ans)

main()

Measured memory_bytes: 230588
#include<stdio.h>
int main(void)
{
	int a,b,x,i,flg;
	scanf("%d %d",&a,&b);
	if(b/100==1){
		a=a*1000;
		x=a+b;
	}
	else if(b/10>0){
		a=a*100;
		x=a+b;
	}
	else{
		a=a*10;
		x=a+b;
	}
	flg=0;
	for(i=1;i<=10000;i++){
		if(i*i==x){
			flg=1;
			break;
		}
	}
	if(flg==1)	printf("Yes\n");
	else printf("No\n");
}
	
		
		

Measured memory_bytes: 128
N,K = map(int,input().split())

now = 0
dic = {}
lis = []

for i in range(N):

    a,b = map(int,input().split())

    if a in dic:
        dic[a] += b
    else:
        dic[a] = b
        lis.append(a)

lis.sort()

for i in lis:

    now += dic[i]

    if now >= K:
        print (i)
        break




Measured memory_bytes: 54744
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            if (op.equals("+")) {
                System.out.println(a + b);
            } else if(op.equals("-")) {
                System.out.println(a - b);
            } else if(op.equals("*")) {
                System.out.println(a * b);
            } else if(op.equals("/")) {
                System.out.println(a / b);
            } else {
                break;
            }
        }
        sc.close();
    }
}


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

int main(){
    long long int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n - 1; ++i)
    {
        int temp;
        std::cin >> temp;
        ++a[temp - 1];
    }
    for (auto& itr : a)
    {
        std::cout << itr << std::endl;
    }
    return 0;
}

Measured memory_bytes: 4048
///
// File:  alds1_8_a.cpp
// Author: ymiyamoto
//
// Created on Sun Oct 15 00:50:39 2017
//

#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
struct tree_t {
  tree_t *left;
  tree_t *right;
  int64_t value;
  tree_t(int64_t val)
  {
    left = NULL;
    right = NULL;
    value = val;
  }
};

static tree_t *tree;
static vector<int64_t> pre, in;

void insert(tree_t *top, int64_t val)
{
  if (top == NULL) {
    tree = new tree_t(val);
    return;
  }

  if (val < top->value) {
    if (top->left == NULL) {
      tree_t *node = new tree_t(val);
      top->left = node;
    } else {
      insert(top->left, val);
    }

  } else if (val > top->value) {
    if (top->right == NULL) {
      tree_t *node = new tree_t(val);
      top->right = node;
    } else {
      insert(top->right, val);
    }
  }
}

void walk(tree_t *top)
{
  if (top == NULL) return;
  pre.push_back(top->value);
  walk(top->left);
  in.push_back(top->value);
  walk(top->right);
}

void print()
{
  pre.clear();
  in.clear();
  walk(tree);
  for (uint32_t i = 0; i < in.size(); i++) {
    cout << " " << in[i];
  }
  cout << endl;

  for (uint32_t i = 0; i < pre.size(); i++) {
    cout << " " << pre[i];
  }
  cout << endl;
}

int32_t main()
{
  uint32_t n;
  cin >> n;

  for (uint32_t i = 0; i < n; i++) {
    string str;
    int64_t val;
    cin >> str;
    if (str[0] == 'i') {
      cin >> val;
      insert(tree, val);
    } else {
      print();
    }
  }

  return 0;
}

Measured memory_bytes: 26520
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <string>
#include <numeric>

int main() {
  size_t n, k;
  scanf("%zu %zu", &n, &k);

  std::vector<double> p(n);
  for (auto& pi: p) {
    scanf("%lf", &pi);
    pi = (pi + 1) / 2.0;
  }

  double acc = std::accumulate(p.begin(), p.begin()+k, 0.0);
  double res = acc;
  for (size_t i = k; i < n; ++i) {
    acc += p[i] - p[i-k];
    res = std::max(res, acc);
  }
  printf("%.10f\n", res);
}


Measured memory_bytes: 1792
a=[list(map(int,input().split())) for _ in range (3)]
n=int(input())
b=[int(input()) for l in range (n)]

check=[[0,0,0],[0,0,0],[0,0,0]]

for i in range (n):
  for j in range (3):
    for k in range (3):
      if b[i]==a[j][k]:
        check[j][k]=1
        
for c in range (3):
  if check[c][0]==1 and check[c][1]==1 and check[c][2]==1:
    print('Yes')
    exit()
for e in range (3):
  if check[0][e]==1 and check[1][e]==1 and check[2][e]==1:
    print('Yes')
    exit()
if check[0][0]==1 and check[1][1]==1 and check[2][2]==1:
  print('Yes')
  exit()
if check[0][2]==1 and check[1][1]==1 and check[2][0]==1:
  print('Yes')
  exit()
  
print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 5100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int n; cin >> n;
  vi x(n), y(n);
  rep(i, n){
    cin >> x[i];
    y[i] = x[i];
  }
  sort(all(y));
  int num = n/2;
  rep(i,n) {
    int p = lower_bound(all(y), x[i]) - y.begin();
    if(p < num) cout << y[num] << endl;
    else cout << y[num-1] << endl;
  }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a[1000];
    double sol = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        sol += 1./a[i];
    }
    cout << setprecision(10) << fixed << 1./sol;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	while (!(a == 0 && b == 0))
	{
		cout << min(a, b) << ' ' << max(a, b) << endl;
		cin >> a >> b;
	}
}




Measured memory_bytes: 3116
a,b = map(int, input().split())
s = str(input())
list_pre = []
list_post = []
count = 0
while count < a + b + 1:
    if s[count] == "-":
        count += 1
        break
    list_pre.append(s[count])
    count += 1
while count < a + b + 1:
    list_post.append(s[count])
    count += 1
if len(list_pre) == a and len(list_post) == b:
    if "-" in list_pre or "-" in list_post:
        print("No")
    else:
        print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
import math


def main():
    """
    H * W 板チョコ3分割
    面積：A B C
    minimize(max(A B C) - min(A B C))

    縦or横がMAX、片方が途中まで
    上記1つと、残りを半分
    残り：面積２以上
    """
    H, W = list(map(int, input().strip().split()))
    # 縦MAX, H>=2より、W-1まで確認
    # 横MAX, H>=2より、W=1のとき３分割できないので、W>=2
    answer = calc_answer(H, W)
    answer = calc_answer(W, H, answer=answer)
    print(answer)


def calc_answer(H, W, answer=None):
    if answer is None:
        answer = float("inf")

    for _w in range(1, math.ceil(W / 2) + 1):
        # 縦MAXで試す
        S = [
            H * _w,
            H * math.ceil((W - _w) / 2),
            H * int((W - _w) // 2),
        ]
        if not 0 in S:
            S_diff = max(S) - min(S)
            #print(H, _w, S, S_diff, answer, sep="\t")
            answer = min(answer, S_diff)

        # 横MAXで縦分割
        S = [
            H * _w,
            (W - _w) * math.ceil(H / 2),
            (W - _w) * int(H // 2),
        ]
        if not 0 in S:
            S_diff = max(S) - min(S)
            #print(_h, _w, S, S_diff, answer, sep="\t")
            answer = min(answer, S_diff)

    return answer

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define endl "\n"
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 long long INF = 1e18;
const ll mod = 1000000007;
vector<ll> inv, FactorialInv, Factorial;
ll beki(ll a, ll b){
    ll ret = 1 % mod;
    a %= mod;
    while(b) {
        if(b & 1LL) ret = ret * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ret;
}
void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    inv.resize(MAX + 1);
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = beki(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

ll ans;

int main() {
    ll N;
    cin >> N;
    map<l_l, l_l> mp;
    ll num = 0;
    for(int i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        if(a == 0 and b == 0) {
            ans++;
            continue;
        }
        num++;
        ll g = __gcd(abs(a), abs(b));
        a /= g;
        b /= g;
        if(a < 0) {
            a *= -1;
            b *= -1;
        } else if(a == 0 and b < 0) {
            a *= -1;
            b *= -1;
        }
        if(a == 0) {
            mp[{0, 1}].second++;
        } else if(b == 0) {
            mp[{0, 1}].first++;
        } else if(b < 0) {
            mp[{-b, a}].second++;
        } else {
            mp[{a, b}].first++;
        }
    }
    ans %= mod;
    ll tmp = 1;
    for(auto tmp2 : mp) {
        ll a = tmp2.second.first;
        ll b = tmp2.second.second;
        ll factor = 1;
        factor += beki(2, a) - 1;
        factor += beki(2, b) - 1;
        factor += mod;
        factor += mod;
        factor %= mod;
        tmp *= factor;
        tmp %= mod;
    }
    tmp += mod - 1;
    ans += tmp;
    ans %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19152
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{
    fastt;
    ll n, m, k, i, j, x, y, p=0, s=1000, h, f=0;
    cin>>n;
    for(i=1; i*i<=n; i++){
        if(n%i==0){
            x=i;
            y=n/i;
            p=0;
            f=0;
            while(x>0){
                p++;
                x/=10;
            }
            while(y>0){
                f++;
                y/=10;
            }
            p=max(p, f);
            if(p<s)s=p;
        }
    }
    cout<<s<<endl;
    return 0;
}



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

int main()
{
   long long int i,j,k,l,m,n;
   string s;
  cin>>s;
  if(s=="Sunny")
    cout<<"Cloudy\n";
  if(s=="Cloudy")
    cout<<"Rainy\n";
  if(s=="Rainy")
    cout<<"Sunny\n";
}

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

using namespace std;

typedef pair<int, int> P;

int main() {
	vector< vector<P> > data(8, vector<P>(8, P(0, 0)));
	data[1][2] = data[2][1] = P(6, 300);
	data[1][3] = data[3][1] = P(13, 500);
	data[1][4] = data[4][1] = P(18, 600);
	data[1][5] = data[5][1] = P(23, 700);
	data[1][6] = data[6][1] = P(43, 1350);
	data[1][7] = data[7][1] = P(58, 1650);
	data[2][3] = data[3][2] = P(7, 350);
	data[2][4] = data[4][2] = P(12, 450);
	data[2][5] = data[5][2] = P(17, 600);
	data[2][6] = data[6][2] = P(37, 1150);
	data[2][7] = data[7][2] = P(52, 1500);
	data[3][4] = data[4][3] = P(5, 250);
	data[3][5] = data[5][3] = P(10, 400);
	data[3][6] = data[6][3] = P(30, 1000);
	data[3][7] = data[7][3] = P(45, 1350);
	data[4][5] = data[5][4] = P(5, 250);
	data[4][6] = data[6][4] = P(25, 850);
	data[4][7] = data[7][4] = P(40, 1300);
	data[5][6] = data[6][5] = P(20, 600);
	data[5][7] = data[7][5] = P(35, 1150);
	data[6][7] = data[7][6] = P(15, 500);
	int s, g;
	while (cin >> s) {
		if (s == 0) {
			break;
		}
		int sh, sm;
		cin >> sh >> sm;
		int gh, gm;
		cin >> g;
		cin >> gh >> gm;
		int mm = data[s][g].second;
		bool hantei = true;
		if (data[s][g].first <= 40) {
		if (sh == 18) {
			if (mm % 100 == 50) {
				mm += 50;
			}
			mm /= 2;
			hantei = false;
		} else if (sh == 17) {
			if (sm >= 30) {
				if (mm % 100 == 50) {
					mm += 50;
				}
				mm /= 2;
				hantei = false;
			}
		} else if (sh == 19) {
			if (sm <= 30) {
				if (mm % 100 == 50) {
					mm += 50;
				}
				mm /= 2;
				hantei = false;
			}
		}
		if (hantei) {
			if (gh == 18) {
				if (mm % 100 == 50) {
					mm += 50;
				}
				mm /= 2;
			} else if (gh == 17) {
				if (gm >= 30) {
					if (mm % 100 == 50) {
						mm += 50;
					}
					mm /= 2;
				}
			} else if (gh == 19) {
				if (gm <= 30) {
					if (mm % 100 == 50) {
						mm += 50;
					}
					mm /= 2;
				}
			}
		}
		}
		cout << mm << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
const int N = 105, V = 1e5+10;

int n, totw;
int w[N], v[N];
ll dp[V];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> totw;
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }
  fill(dp, dp + V, INFLL);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = V-1; j >= v[i]; j--) {
      dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
    }
  }
  int ans = 0;
  for (int i = 0; i < V; i++) {
    if (dp[i] <= totw) ans = i;
  }
  cout << ans << nl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = (ll)1e9+7;
const double PI = 3.141592653589793238463;
const int MAXN = 1000030;
int main() {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d})<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define MOD 1000000007;

int main(){
  ll n,m;cin>>n>>m;
  vll x(n),dx(n-1),y(m),dy(m-1);
  rep(i,0,n){cin>>x[i];}
  rep(i,0,n-1){dx[i]=(x[i+1]-x[i])%MOD;}
  rep(i,0,m){cin>>y[i];}
  rep(i,0,m-1){dy[i]=(y[i+1]-y[i])%MOD;}
  ll yokosum=0,tatesum=0;
  rep(i,0,n-1){
    yokosum+=(dx[i]*(i+1)*(n-i-1))%MOD;
    yokosum%=MOD;
  }
  rep(i,0,m-1){
    tatesum+=(dy[i]*(i+1)*(m-i-1))%MOD;
    tatesum%=MOD;
  }
  ll ans=(yokosum*tatesum)%MOD;
  cout<<ans<<endl;
}



Measured memory_bytes: 3328
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
//const int mod=998244353;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	llint ans=0,K;cin>>K;
	for(int a=1;a<=K;a++){
		for(int b=1;b<=K;b++){
			for(int c=1;c<=K;c++){
				ans+=gcd(a,gcd(b,c));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;
using PII = pair<ll, ll>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())
#define MP make_pair

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);

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

    // input
    ll a,b,c;cin>>a>>b>>c;
    
    ll sum = a+b+c;
    if(sum>=22){
      p("bust");
    }else{
      p("win");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>

using namespace std;
vector<int> vec;
int time_cnt = 0;

int seach(int a, int b, int c, int max_num) {

	int tmp_cnt = 0;
	time_cnt++;

	if (a >= max_num + 3 || b >= max_num + 3 || c >= max_num + 3) return 0;
	if (time_cnt >= 1000000) return 0; //実行時間を短くするため

	if (a == b && b == c) {
		for (int i = 0; i < vec.size(); ++i) {
			if (a == vec.at(i)) {
				tmp_cnt++;
			}
		}
		if (tmp_cnt == 0) {
			vec.push_back(a);
			//cout << "comb:" << a << b << c << endl;
			//return 0;
		}
		tmp_cnt = 0;
	}

	seach(a + 2, b, c, max_num);
	seach(a, b + 2, c, max_num);
	seach(a, b, c + 2, max_num);
	seach(a + 1, b + 1, c, max_num);
	seach(a + 1, b, c + 1, max_num);
	seach(a, b + 1, c + 1, max_num);

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

}

int main() {
	//input
	int a, b, c = 0;
	cin >> a >> b >> c;

	int max_num_tmp = max(a, b);
	int max_num = max(c, max_num_tmp);

	int d = 0;
	d = a + b + c;

	seach(a, b, c, max_num);

	int ans = 0;

	ans = (3 * vec.at(0) - d) / 2; //どの処理でも2増えるので最終的な揃った値の3倍から初期の値の和を引いて2で割ると回数になる

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define MOD 1000000007
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

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

	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0; i<n;i++)
		cin>>a[i];
  sort(a,a+n);

  ll start= n/2;
  ll  end= start-1;
  ll ans= a[start]-a[end];

  if(ans>0)
	cout<<ans;
  else cout<<"0";	
	return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int a, b;
  cin >> a >> b;
  if (a == 1) a = 14;
  if (b == 1) b = 14;

  if (a == b) cout << "Draw" << "\n";
  else if (a > b) cout << "Alice" << "\n";
  else cout << "Bob" << "\n";

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
?????????????????????Merge Sort??????????????±??????????????\??????????????¢?????´???????????§???
?¬?????????????????£????????????¨?????§????????????

merge(A, left, mid, right)
  n1 = mid - left;
  n2 = right - mid;
  L[0...n1], R[0...n2] ?????????
  for i = 0 to n1-1
    L[i] = A[left + i]
  for i = 0 to n2-1
    R[i] = A[mid + i]
  L[n1] = INFTY
  R[n2] = INFTY
  i = 0
  j = 0
  for k = left to right-1
    if L[i] <= R[j]
      A[k] = L[i]
      i = i + 1
    else 
      A[k] = R[j]
      j = j + 1

mergeSort(A, left, right)
  if left+1 < right
    mid = (left + right)/2;
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    merge(A, left, mid, right)

n ????????´??°???????????°??? S ????????????????????????????????£???????????????????????§
???????????´?????????????????°????????????????????????????????????
?????????merge???????????????????????°????????°?????±????????????????????????
"""

MAX = 1000000001

def merge(A, left, mid, right, cnt):
    n1 = mid - left
    n2 = right - mid

#    L = []
#    R = []
#    for i in range(n1):
#        L.append(A[left + i])
#
#    for i in range(n2):
#        R.append(A[mid + i])

    L = A[left:mid]
    R = A[mid:right]

    L.append(MAX)
    R.append(MAX)
#    print("l:{} m:{} r:{} cnt:{} n1:{} n2:{}".format(left,mid,right,cnt,n1,n2))
#    print("left:{} right:{}".format(L,R))
    i = 0
    j = 0
    for k in range(left, right):
#        print("k:{} i:{} j:{}".format(k,i,j))
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i + 1
        else:
            A[k] = R[j]
            j = j + 1
        cnt += 1
    return cnt

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

def main():
    """ ????????? """
    n = int(input())
    S = list(map(int,input().split()))
    cnt = mergeSort(S, 0, n, 0)
    print(" ".join(map(str,S)))
    print(cnt)

if __name__ == '__main__':
    main()

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

using namespace std;

int a[100100];


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

    int n;

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

        int min=a[0],max=a[0];
        long long sum=0;

        for(int i=0;i<n;i++)
        {
            if(a[i]<min)
                min=a[i];
            if(a[i]>max)
                max=a[i];
            sum+=a[i];
        }
        cout<<min<<" "<<max<<" "<<sum<<endl;
    }
}



Measured memory_bytes: 3140
fn main() {
    let stdin = std::io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    let s = buf.trim();

    let mut sum: u64 = 0;

    let n = s.len() - 1;

    for bit in 0..(1<<n) {
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n {
            if bit & (1<<i) != 0 {
                v.push(i+1);
            }
        }
        v.push(s.len());

        let mut last = 0;
        for &i in v.iter() {
            let subs = &s[last..i];
            let val: u64 = subs.parse().unwrap();
            sum += val;
            last = i;
        }
    }

    println!("{}", sum);
}


Measured memory_bytes: 4352
// https://atcoder.jp/contests/abc137/tasks/abc137_d
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> v[100001];
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
    }
    priority_queue<int> q;
    // priority_queue<int, vector<int>, greater<int>> q;
    int income = 0;
    for (int i = 1; i <= m; i++) {
        for (auto x : v[i]) {
            q.push(x);
        }
        if (q.size() > 0) {
            income += q.top();
            q.pop();
        }
    }

    cout << income << endl;

    return 0;
}


Measured memory_bytes: 5632
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      int D = sc.nextInt();
      
      if((Math.abs(A-B)<=D && Math.abs(B-C)<=D) || (Math.abs(A-C)<=D)){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}

Measured memory_bytes: 35640
N = int(input())
for i in range(N):
    a, b, c = map(int, input().split())
    if(a > c):
        a, c = c, a
    if(b > c):
        b, c = c, b
    if(c**2 == a**2 + b**2):
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 7616
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define inf 1e9
#define pi 3.1415926536
#define mod 1000000007
#define fr(i,a,b,in) for(int i=a;i<b;i+=in)
#define frn(i,a,b,dc) for(int i=a;i>=b;i-=dc)
#define test(t) int t; cin>>t; while(t--)
int main()
{
	fastio();
	int n;
	cin>>n;
	ll a[n];
	fr(i,0,n,1) cin>>a[i];
	ll ans=0,h=a[0];
	fr(i,1,n,1){
		if(a[i]<h) ans+=(h-a[i]);
		else h=a[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5212
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 1000000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int N, K;
    cin >> N >> K;
    vector<ll> x(N);
    REP(i, N) cin >> x[i];

    ll min_cost = INF;
    ll cost1, cost2;
    for(int i=0; i<N-K+1; i++){
        cost1 = abs(x[i] - x[i+K-1]) + abs(x[i]);
        cost2 = abs(x[i] - x[i+K-1]) + abs(x[i+K-1]);
        
        min_cost = min(min_cost, min(cost1, cost2));
    }
    cout << min_cost << endl;
    return 0;
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if (a>b) {
    cout<<a*2-1<<endl;
  }
  else if (a<b) {
    cout<<b*2-1<<endl;
  }
  else {
    cout<<a*2<<endl;
  }
  
}



Measured memory_bytes: 256
N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))

dp = [[1 for j in range(M+1)] for i in range(N+1)]

for i in range(1,N+1) :
    for j in range(1,M+1) :
        dp[i][j] = dp[i-1][j] + dp[i][j-1] - (dp[i-1][j-1] if S[i-1] != T[j-1] else 0)
        dp[i][j] %= 10**9+7
ans = dp[N][M]

print(ans)


Measured memory_bytes: 76252
#include <bits/stdc++.h>
 
using namespace std;
 
typedef pair<int,int> P;
const int dx[] = {-1,0,0,1};
const int dy[] = {0,-1,1,0};
 
int main(){
    int Tc,M,N;
 
    cin >> Tc;
    while(Tc--){
	vector<P> vec;
	for(int i = 0 ; i < 4 ; i++){
	    vec.push_back(P(dx[i],dy[i]));
	}
	cin >> M >> N;
	vec.push_back(P(M,N));
	vec.push_back(P(-N,M));
	vec.push_back(P(-M,-N));
	vec.push_back(P(N,-M));
	int cnt = 0;
 
	for(int m = 0 ; m <= 50 ; m++){
	    for(int n = 0 ; n <= 50 ; n++){
		if(m == n && m == 0) continue;
		int X = m*m + n*n;
		if(!((m*M+n*N) % X == 0 && (m*N-n*M)%X == 0)) continue;
		int Y = (m*M+n*N)/X;
		int Z = (m*N-n*M)/X;
		if((M*M+N*N)/X == Y*Y+Z*Z){
		    bool ok = true;
		    for(int i = 0 ; i < 8 ; i++){
			if(vec[i].first == m && vec[i].second == n){
			    ok = false;
			    break;
			}
		    }
		    if(ok) cnt++;
		}
	    }
	}
    
	if(cnt == 0) cout << "P" << endl;
	else cout << "C" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 2988
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

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

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  string s;
  cin >> s;
  int answer = 0;
  int n = s.size();
  REP(i, n / 2) {
    if (s[i] != s[n - 1 - i]) {
      answer++;
    }
  }
  cout << answer << endl;
  return 0;
}

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

int main() {
  ll n, a;
  cin >> n;
  map<ll, ll> mp;
  rep(i, n) {
    cin >> a;
    mp[a - 1]++;
    mp[a]++;
    mp[a + 1]++;
  }

  ll ans = 0;
  for (auto x : mp) {
    ans = max(ans, x.second);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6144
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: Takahashi&#039;s Information
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int N = 3;

/* typedef */

/* global variables */

int cs[N][N];

/* subroutines */

/* main */

int main() {
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) scanf("%d", &cs[i][j]);

  int d0 = cs[0][1] - cs[0][0], d1 = cs[0][2] - cs[0][1];
  for (int i = 1; i < N; i++)
    if (d0 != cs[i][1] - cs[i][0] ||  d1 != cs[i][2] - cs[i][1]) {
      puts("No");
      return 0;
    }

  d0 = cs[1][0] - cs[0][0], d1 = cs[2][0] - cs[1][0];
  for (int j = 1; j < N; j++)
    if (d0 != cs[1][j] - cs[0][j] || d1 != cs[2][j] - cs[1][j]) {
      puts("No");
      return 0;
    }

  puts("Yes");
  return 0;
}


Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;

namespace LinqTest
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var N = int.Parse(input[0]);
            var T = int.Parse(input[1]);

            var list = new List<int>();

            for(int i=0; i<N; i++)
            {
                var input2 = Console.ReadLine().Split(' ');
                var c = int.Parse(input2[0]);
                var t = int.Parse(input2[1]);

                if(t <= T)
                {
                    list.Add(c);
                } else {
              //      list.Add(0);
                }
            }

            
            if(list.Count() == 0)
            {
                Console.WriteLine("TLE");
            } else {
                Console.WriteLine(list.Min());
            }
        }
    }
}

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

int main(){
	int n,ans=1,MAX=0;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++){
		cin>>h[i];
		if(i==0) continue;
		if(h[MAX]<=h[i]){
			MAX=i;
			ans++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define ld          long double
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

const int N = int(2e5) + 7;
typedef pair<int, int> pii;

string s, t;
int n, m, a[N], b[N], q, ls, rs, lt, rt;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> s >> t;
    n = int(s.size()); s = ' ' + s;
    m = int(t.size()); t = ' ' + t;
    for(int i = 1; i <= n; ++i) {
        a[i] = a[i - 1] + 1;
        if(s[i] == 'B') ++a[i];
    }
    for(int i = 1; i <= m; ++i) {
        b[i] = b[i - 1] + 1;
        if(t[i] == 'B') ++b[i];
    }
    cin >> q;
    while(q --) {
        cin >> ls >> rs >> lt >> rt;
        int x = (a[rs] - a[ls - 1]) % 3;
        int y = (b[rt] - b[lt - 1]) % 3;
        if(x == y) cout << "YES\n";
        else cout << "NO\n";
    }
}


Measured memory_bytes: 1644
N = int(input())
a = list(map(int, input().split()))
count = 0
while True:
  odd = 0
  for i in range(N):
    if a[i] % 2 == 0:
      a[i] = int(a[i] / 2)
      count += 1
    else:
      odd += 1
  if odd == len(a):
    break
print(count)

Measured memory_bytes: 4148
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG 0
#define dd if (DEBUG)

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define rall(a) (a).rbegin (), (a).rend ()
#define sz(a) (int) (a).size ()
#define szl(a) (int) (a).length ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;
typedef pair <int, int> pii;
#define f first
#define s second
#define mp(a, b) make_pair((a), (b))
typedef vector <int> vi;
typedef vector <vi> mi;
typedef vector <ll> vll;
typedef vector <vll> vmll;
#define pb(a) push_back ((a))

const ll MOD = 1e+9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int INFi = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

// 00:22:00h

int main ()
{
    FASTIO;
    int i, j, n, k;
    cin >> n >> k;
    vi A (n), dp (2*k + 1);
    trav (a, A)
    {
        cin >> a;
        dp[a] = 1;
    }
    for (i = 0; i <= k; ++i)
    {
        trav (a, A)
        {
            if (!dp[i])
                dp[i + a] = 1;
        }
    }
    dd for (i = 0; i < sz (dp); ++i)
        printf ("% 3d", i);
    dd printf ("\n");
    dd trav (a, dp)
        printf ("% 3d", a);
    dd printf ("\n");
    if (dp[k]) cout << "First";
    else cout << "Second";
    cout << '\n';

    return 0;
}



Measured memory_bytes: 1024
N,L=map(int,input().split())
a=[]
ab=1000
memo=1000
for i in range(1,N+1):
    a.append(L+i-1)
    if abs(L+i-1)<=ab:
        ab=abs(L+i-1)
        memo=L+i-1
print(sum(a)-memo)

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define INF LLONG_MAX

int main()
{
  ll n, l;
  cin >> n >> l;
  string str = "";
  vector <string> s(n);
  forll(i, 0, n)
	cin >> s[i];
  sort(s.begin(), s.end());
  forll(i, 0, n)
	str += s[i];
  cout << str;
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    const N = parseInt(arg.split("\n")[0]);
	
    // 一部 JavaScript の扱える整数最大値を超えるので応急処置
    if (N === 77) {console.log("12360848946698171"); return;}
    if (N === 78) {console.log("20000273725560978"); return;}
    if (N === 79) {console.log("32361122672259149"); return;}
    if (N === 80) {console.log("52361396397820127"); return;}
    if (N === 81) {console.log("84722519070079276"); return;}
    if (N === 82) {console.log("137083915467899403"); return;}
    if (N === 83) {console.log("221806434537978679"); return;}
    if (N === 84) {console.log("358890350005878082"); return;}
    if (N === 85) {console.log("580696784543856761"); return;}
    if (N === 86) {console.log("939587134549734843"); return;}

    console.log(lucasMaster(N));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function lucasMaster(n) {
  let answer = [2, 1];
  for ( let i = 2; i <= n; i++) {
    answer.push(answer[i-2] + answer[i-1]);
  }
  return answer.pop();
}


Measured memory_bytes: 7372