akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint

sys.setrecursionlimit(1000000)
# MOD = 10 ** 9 + 7
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]

N = int(input())
A = [int(x) for x in input().split()]

ans = float('inf')
for y in range(-100, 101):
    ans = min(ans, sum([(x - y) ** 2 for x in A]))

print(ans)


Measured memory_bytes: 3772
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] input = In.ReadToEnd().Split(new[] { " ", "\n", "\r" },
        StringSplitOptions.RemoveEmptyEntries);

    T Get<T>(Func<string, T> parser) => parser(input[idx++]);

    public string S => Get(s => s);
    public char C => Get(char.Parse);
    public int I => Get(int.Parse);
    public long L => Get(long.Parse);
    public double F => Get(double.Parse);
    public decimal D => Get(decimal.Parse);
    public BigInteger B => Get(BigInteger.Parse);

    T[] Gets<T>(int n, Func<string, T> parser)
        => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray();

    public string[] Ss(int n) => Gets(n, s => s);
    public char[] Cs(int n) => Gets(n, char.Parse);
    public int[] Is(int n) => Gets(n, int.Parse);
    public long[] Ls(int n) => Gets(n, long.Parse);
    public double[] Fs(int n) => Gets(n, double.Parse);
    public decimal[] Ds(int n) => Gets(n, decimal.Parse);
    public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse);

    public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs));
    public void Write(params object[] xs) => WriteLine(string.Join(" ", xs));
}

#region Library

static class Extentions
{
}

#endregion

static class Program
{
    public static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { NewLine = "\n" };
#if DEBUG
        sw.AutoFlush = true;
#else
        sw.AutoFlush = false;
#endif
        SetOut(sw);
        Solve(new IO());
        Out.Flush();
    }

    static void Solve(IO io)
    {
        var a = io.Is(3).OrderBy(x => x);

        io.Write(a.SequenceEqual(new[] { 5, 5, 7 }) ? "YES" : "NO");
    }
}

Measured memory_bytes: 11488
#include <iostream>
#include <vector>
#include <queue>

#define  FOR(i, c) for(__typeof((c).begin())i = (c).begin(); i != (c).end(); ++i)

using namespace std;

typedef int Weight;
const Weight INF = 1e9;

struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight) :
        src(src), dst(dst), weight(weight) { }
};

bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void shortestPath(const Graph &g, int s,
                  vector<Weight> &dist, vector<int> &prev) {
    int n = g.size();
    dist.assign(n, INF); dist[s] = 0;
    prev.assign(n, -1);
    priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
    for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
        Edge e = Q.top(); Q.pop();
        if (prev[e.dst] != -1) continue;
        prev[e.dst] = e.src;
        FOR(f,g[e.dst]) {
            if (dist[f->dst] > e.weight+f->weight) {
                dist[f->dst] = e.weight+f->weight;
                Q.push(Edge(f->src, f->dst, e.weight+f->weight));
            }
        }
    }
}

int main()
{
    int n, m;
    char ch;
    
    cin >> n >> m;
    Graph g(n);
    for (int i = 0; i < m; i++) {
        int a, b, c, d;

        cin >> a >> ch >> b >> ch >> c >> ch >> d;
        a--, b--;
        g[a].push_back(Edge(a, b, c));
        g[b].push_back(Edge(b, a, d));
    }
    
    int x1, x2, y1, y2;
    int w1, w2;
    vector<Weight> dist;
    vector<int> prev;
    cin >> x1 >> ch >> x2 >> ch >> y1 >> ch >> y2;
    x1--, x2--;
    
    shortestPath(g, x1, dist, prev);
    w1 = dist[x2];
    shortestPath(g, x2, dist, prev);
    w2 = dist[x1];
    cout << y1 - (y2 + w1 + w2) << endl;

    return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(int i=init;i<=(int)(n);i++)
#define repd(i,n,init) for(int i=(int)(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)

int main()
{
    int A,B,K;
    cin >> A >> B >> K;
    int cnt = 0;
    vector<int> cd;
    repi(i,min(A,B),1){
        if(A%i == 0 && B%i == 0){
            cd.push_back(i);
        }
    }
    cout << cd.at(cd.size() - K) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define repi(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
using namespace std;
typedef long long ll;

int main() {
  int a,b; cin >> a >> b;
  cout << (b >= a ? a : a - 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
typedef long long LL;
const LL mod = 1e9+7;
int a[N]; 
int main(){    
	int n;    
	cin>>n;
		for(int i=2;i<=n;i++){            
			int x=i;            
			for(int j=2;j<=x;j++)            
			{                
				while(x%j==0)                
				{                    
					a[j]++;                    
					x/=j;                
				}           
			}
			if(x!=1) a[x]++;        
	}        
	LL ans=1;        
	for(int i=1;i<=n;i++)        
	{            
		if(a[i]!=0) 
			ans=(ans*(a[i]+1))%mod;        
	}        
		printf("%lld\n",ans);    
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

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

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

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

template <typename T>
T gcd(T a, T b) {
  if(b == 0) return a;
  else return gcd(b,a%b);
}



int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

// struct UnionFind {
//   vector<int> par;

//   UnionFind(int n) {
//     par.resize(n,-1); 
//   }

//   int root(int x) {
//     if(par[x] < 0) return x;
//     else return par[x] = root(par[x]);
//   }

//   bool issame(int x, int y) {
//     return root(x) == root(y);
//   }

//   bool merge(int x, int y) {
//     x = root(x); y = root(y);
//     if(x == y) return false;
//     if(par[x] > par[y]) swap(x,y);
//     par[x] += par[y];
//     par[y] = x;
//     return true;
//   }
  
//   int size(int x) {
//     return -par[root(x)];
//   }
// };

int c[20];
int a[20][20];

int main() {
  int N,M,X;
  cin >> N >> M >> X;
  rep(i,N) {
    cin >> c[i];
    rep(j,M) {
      cin >> a[i][j];
    }
  }
  int ans = 1e+9;
  for(int bit=0; bit <(1<<N); bit++) {
    int ret = 0;
    vector<int> comp(M);
    rep(i,N) {
      if(bit & (1<<i)) {
	rep(j,M) comp[j] += a[i][j];
	ret += c[i];
      }
    }
    bool f = true;
    rep(i,M) if(comp[i] < X) f = false;
    if(f) ans = min(ans,ret);
  }
  if(ans == 1e+9) cout << -1 << endl;
  else cout << ans << endl;
    
}














Measured memory_bytes: 3176
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

tuple<int64_t, int64_t, int64_t> xgcd(int64_t a, int64_t b) {
  if (b == 0) {
    return make_tuple(1, 0, a);
  }
  int64_t z, w, d;
  tie(z, w, d) = xgcd(b, a % b);
  return make_tuple(w, z - a / b * w, d);
}

tuple<int64_t, int64_t> chinese_rem(int64_t a1, int64_t a2, int64_t m1,
                                    int64_t m2) {
  int64_t x, y, d;
  tie(x, y, d) = xgcd(m1, m2);

  const int64_t c = a2 - a1;
  if (c % d != 0) {
    return make_tuple(0, 0);
  }
  const int64_t tmp = c / d * x % (m2 / d);
  const int64_t sln = a1 + tmp * m1;
  const int64_t M = m1 / d * m2;

  return make_tuple((sln % M + M) % M, M);
}

tuple<int64_t, int64_t> chinese_rem(const vector<int64_t>& a,
                                    const vector<int64_t>& MOD) {
  if (a.size() != MOD.size()) {
    stringstream msg;
    msg << "a.size() is " << a.size() << ", but MOD.size()" << MOD.size()
        << "\n";
    throw msg.str();
  }
  int64_t sln = 0, M = 1;
  for (size_t i = 0; i < a.size(); i++) {
    if (a[i] == -1) {
      continue;
    }
    tie(sln, M) = chinese_rem(sln, a[i], M, MOD[i]);
    if (M == 0) {
      return make_tuple(0, 0);
    }
  }

  return make_tuple(sln, M);
}

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

  vector<int64_t> a(M);
  rep(i, M) { cin >> a[i]; }

  rep(i, D) {
    vector<int64_t> r(M);
    rep(i, M) { cin >> r[i]; }

    int64_t rem, m;
    tie(rem, m) = chinese_rem(r, a);
    if (m == 0 || N < rem) {
      N = -1;
      break;
    }

    N = rem + (N - rem) / m * m;
  }

  cout << N << endl;
  return 0;
}


Measured memory_bytes: 3116
using System;
using System.Collections.Generic;

namespace D___Preparing_Boxes
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var read = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var ai = new int[N + 1];
            for (int i = 1; i < N + 1; i++) ai[i] = read[i - 1];
            var bi = new int[N + 1];
            var M = 0;
            var output = new List<int>();
            for (int i = N; i > 0; i--)
            {
                bi[i] = ai[i];
                for (int j = 2; j * i <= N; j++)
                {
                    bi[i] ^= bi[j * i];
                }
                if (bi[i] == 1)
                {
                    M += 1;
                    output.Add(i);
                }
            }
            Console.WriteLine(M);
            Console.WriteLine(string.Join(" ", output));
        }
    }
}


Measured memory_bytes: 35160
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>

using namespace std;
int main() {
	int count=0;
	string str;

	cin >> str;
	for   (int i =0; i< str.size(); i++)
	{
		count++;
	}

	cout << str[0] << count - 2 << str.back() << endl;

	return 0;

}


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

using namespace std;
using ll = long long int;
using Pii = pair<int, int>;
using Psi = pair<string, int>;

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

int main(){

    int n, q;
    cin >> n >> q;

    queue<Psi> que;
    vector<Psi> ans;

    loop(i, n){
        string str;
        int a;
        cin >> str >> a;
        que.push(Psi(str, a));
    }

    int sum = 0;
    while(que.size()){
        Psi p;
        p = que.front(); que.pop();
        if(p.second > q){
            p.second -= q;
            sum += q;
            que.push(p);
        }else{
            sum += p.second;
            ans.push_back(Psi(p.first, sum));
        }
    }

    loop(i, ans.size()){
        cout << ans[i].first << " " << ans[i].second << endl;
    }

    return 0;
}




Measured memory_bytes: 6952
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;

signed main() {
    ll N, A,B,C,D,E;
    cin >>N>>A>>B>>C>>D>>E;
    ll bottol_neck = min({A,B,C,D,E}); 
    ll delay = 5;

    cout << ((N+bottol_neck-1)/bottol_neck - 1) + delay << endl;
}


Measured memory_bytes: 256
n = gets.to_i
t_point = 0
h_point = 0

ARGF.each_line do |line|
  t_card, h_card = line.split

  case t_card <=> h_card
  when 1
    t_point += 3
  when 0
    t_point += 1
    h_point += 1
  when -1
    h_point += 3
  end
end

puts "#{t_point} #{h_point}"

Measured memory_bytes: 6096
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

pair<int,int> dxy(char d) {
  if(d=='R') {
    return make_pair(1,0);
  }
  if(d=='L') {
    return make_pair(-1,0);
  }
  if(d=='U') {
    return make_pair(0,1);
  }
  return make_pair(0,-1);
}
  
int main() {
  int N;
  cin >> N;
  vi xs(N),ys(N);
  string dir(N,' ');
  rep(i,N) {
    cin >> xs[i] >> ys[i] >> dir[i];
  }
  auto calc = [&](double t) -> double {
    double xmin=INF,xmax=-INF,ymin=INF,ymax=-INF;
    rep(i,N) {
      double px=xs[i]+t*dxy(dir[i]).first;
      double py=ys[i]+t*dxy(dir[i]).second;
      chmin(xmin,px);
      chmax(xmax,px);
      chmin(ymin,py);
      chmax(ymax,py);
    }
    return (xmax-xmin)*(ymax-ymin);
  };
  double lt=0,rt=INF;
  rep(tryi,100) {
    double lm = (lt*2+rt)/3;
    double rm = (lt+rt*2)/3;
    double a = calc(lm);
    double b = calc(rm);
    if(a<b) {
      rt=rm;
    } else {
      lt=lm;
    }
  }
  cout << setprecision(16) << calc(lt) << endl;
  return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;

ll n, m;
vector<ll> ve[100005];
bool v[100005];
vector<ll> ans1, ans2;

int main()
{
    scanf("%lld%lld", &n, &m);
    for(ll i = 0; i < m; i++)
    {
        ll t1, t2;
        scanf("%lld%lld", &t1, &t2);
        ve[t1].push_back(t2);
        ve[t2].push_back(t1);
    }
    ll now = 1;
    while(1)
    {
        bool vv = false;
        v[now] = true;
        ans1.push_back(now);
        for(ll i = 0; i < ve[now].size(); i++)
        {
            if(v[ve[now][i]]) continue;
            vv = true;
            now = ve[now][i];
            break;
        }
        if(!vv) break;
    }
    now = 1;
    while(1)
    {
        bool vv = false;
        v[now] = true;
        ans2.push_back(now);
        for(ll i = 0; i < ve[now].size(); i++)
        {
            if(v[ve[now][i]]) continue;
            vv = true;
            now = ve[now][i];
            break;
        }
        if(!vv) break;
    }
    printf("%lld\n", (ll)ans1.size() + (ll)ans2.size() - 1);
    for(ll i = ans1.size() - 1; i > 0; i--)
    {
        printf("%lld ", ans1[i]);
    }
    for(ll i = 0; i < ans2.size(); i++)
    {
        printf("%lld ", ans2[i]);
    }
    return 0;
}


Measured memory_bytes: 7284
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 998244353
using namespace std;
typedef long long ll;
int main() {
  ll n, a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<vector<ll> > dp(c + 10);
  for (int i = 0; i < c + 10; i++) {
    dp[i].resize(d + 10);
  }
  dp[a][b] = 1;
  for (ll i = a; i < c; i++) {
    dp[i + 1][b] = dp[i][b] * b;
    dp[i + 1][b] %= MOD;
  }
  for (ll i = b; i < d; i++) {
    dp[a][i + 1] = dp[a][i] * a;
    dp[a][i + 1] %= MOD;
  }
  for (ll i = a + 1; i <= c; i++) {
    for (ll j = b + 1; j <= d; j++) {
      dp[i][j] = dp[i - 1][j] * j + dp[i][j - 1] * i -
                 dp[i - 1][j - 1] * (i - 1) * (j - 1) + MOD * (ll)10000000;
      dp[i][j] %= MOD;
    }
  }
  cout << dp[c][d] << endl;
}

Measured memory_bytes: 74504
n=int(input())
t=list(map(int,input().split()))
a=list(map(int,input().split()))
if t[0]>a[0] or t[-1]<a[-1]:print(0);exit()
x=[1]*n
x[0]=x[-1]=0
for i in range(1,n):
  if t[i-1]!=t[i]:
    x[i]=0
    if t[i]>a[i]:print(0);exit()
for i in range(n-2,-1,-1):
  if a[i+1]!=a[i]:
    x[i]=0
    if t[i]<a[i]:print(0);exit()
ans=1
for i in range(n):
  if x[i]:
    ans*=min(t[i],a[i])
    ans%=10**9+7
print(ans)

Measured memory_bytes: 19012
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

int N;
cin>>N;
int k;
cin>>k;

int d[k];
rep(i,k)cin>>d[i];

for(int l=N;l<10*N;l++){
    
    bool ans=true;
    int n=l;
        while(n>0){
        bool in=true;
        int p=n%10;
        
            rep(i,k){
                if(d[i]==p){
                in=false;
                break;
                }
            }

            if(!in){
            ans=false;
            break;
            }
        n/=10;
        }
    if(!ans)continue;
    else{
        cout<<l<<endl;
        break;
    }
}

return 0;

}
/*
1000 8
1 3 4 5 6 7 8 9

2000

9999 1
0

9999
*/


Measured memory_bytes: 256
import copy


N, M = list(map(int,input().split()))
graph = [dict() for i in range(N)]
for i in range(N):
	graph[i]["edge"] = []
for i in range(M):
	a, b = list(map(int, input().split()))
	graph[a - 1]["edge"].append(b - 1)
	graph[b - 1]["edge"].append(a - 1)

def pow(N):
	ans = 1
	for i in range(N):
		ans *= i + 1
	return  ans

total = 0
for i in range(pow(N - 1)):
	node = [a+1 for a in range(N - 1)]
	num = i
	zyun = [0]
	for j in range(N - 1, 0 , -1):
		mod = num % j
		num -= num % j
		num = num//j
		zyun.append(copy.deepcopy(node[mod]))
		del node[mod]
	judge = 1
	for loc in range(N - 1):
		if not zyun[loc + 1] in graph[zyun[loc]]["edge"]:
			judge = 0
	total += judge

print(total)

Measured memory_bytes: 46552
# n=int(input())
# a,b=map(int, input().split())
# c=list(map(int, input().split()))
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a=100
# b=0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋めのときの出力
# 000100-0.987654

import numpy as np
import math
import copy

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

n = 0

if a > b:
    n += a
    a = a - 1
else:
    n += b
    b = b - 1

if a > b:
    n += a
    a = a - 1
else:
    n += b
    b = b - 1

print(n)

Measured memory_bytes: 12420
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Rmq
{
    int n;
    vector<long long> data;
    long long query(int a, int b, int k, int l, int r){
        if(r < a || b < l)
            return LLONG_MAX;
        if(a <= l && r <= b)
            return data[k];
        long long x = query(a, b, k*2+1, l, (l+r)/2);
        long long y = query(a, b, k*2+2, (l+r+1)/2, r);
        return min(x, y);
    }
public:
    Rmq(int n0){ // コンストラクタ（要素数を指定）
        n = 1;
        while(n < n0)
            n *= 2;
        data.assign(2*n-1, LLONG_MAX);
    }
    void update(int k, long long x){ // k番目の要素をxに変更する
        k += n - 1;
        data[k] = x;
        while(k > 0){
            k = (k - 1) / 2;
            data[k] = min(data[k*2+1], data[k*2+2]);
        }
    }
    long long query(int a, int b){ // 区間[a,b]の最小値を返す
        return query(a, b, 0, 0, n-1);
    }
};

int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i=0; i<n; ++i)
        cin >> x[i];

    Rmq rmq(n+1);
    rmq.update(0, 0);
    for(int i=0; i<n; ++i)
        rmq.update(x[i], rmq.query(0, x[i]-1) - x[i]);

    long long ret = (n * (n + 1LL)) / 2;
    ret += rmq.query(0, n);
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 3380
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

int isUnder(int T,int A){ // AがT以下で1,それ以外0
    if(A<=T) return 1;
    else return 0;
}

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Ciniii(r,D,x0);
    rep(i,10){
        x0 = r*x0 -D;
        cout << x0 << nn;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include "atcoder/all"
using namespace std;
using namespace atcoder;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
const long long int sMod = 998244353;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll k;
    cin >> k;
    rp(i,k){
        cout << "ACL";
    }
    cout << endl;
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	int count=0;
	cin >> s;
	if (s[0] == '1') {
		count++;
	}
	if (s[1]== '1') {
		count++;
	}
	if (s[2] == '1') {
		count++;
	}
	cout << count << endl;
}

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

int main(void){

  char S[10];
  scanf("%s",S);

  char mozi;
  bool judge = true;
  int length = strlen(S);
  int place = 0;
  int C_count = 0;


  //頭文字の大文字A判定
  mozi = S[0];
  if(mozi != 'A')  judge = false;

  
  //頭三文字目から後ろ二文字目までにCが一つか?
  for(int i = 2; i <= length - 2; i++){
    if(S[i] == 'C'){
      C_count++;
      place = i;                  //Cの場所記憶
    }
  }
  if(C_count != 1)    judge = false;

  
  //その他の文字が小文字か
  for(int i = 1; i < length ; i++){
    	if(i != place){
    
   	    mozi = S[i];
        if(mozi < 'a' || 'z' < mozi)      judge = false;
    
    }
  }

  
  //最終出力
  if(judge) puts("AC");
  else      puts("WA");
      
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n,m;
  cin >> n >> m;
  priority_queue<ll> pq;
  rep(i,n){
    ll x;
    cin >> x;
    pq.push(-x);
  }
  vector<pair<ll,ll>> qurey(m);
  rep(i,m){
    ll x,y;
    cin >> x >> y;
    qurey[i] ={-y,-x};
  }
  sort(qurey.begin(),qurey.end());
  //rep(i,m){
    //cout << "{" << qurey[i].first << qurey[i].second << "}" << endl;
  //}
  rep(i,m){
    rep(j,(-qurey[i].second)){
      ll tmp = -(pq.top());
      pq.pop();
      if (tmp < (-qurey[i].first)){
        pq.push(qurey[i].first);
      }else{
        pq.push(-tmp);
        break;
      }
    }
  }
  ll ans = 0;
  while(!pq.empty()){
    ll tmp = pq.top();
    pq.pop();
    //cout << -tmp << endl;
    ans += (-tmp);
  }
  cout << ans << endl;


    
  return 0;
}


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

int main(){
  double W,H,x,y,ans1;
  cin >> W >> H >> x >> y;
  
  ans1=(W*H)/2;
  cout << ans1 << " ";
  
  if(x==W/2&&y==H/2){
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
N, A, B, C, D = map(int, input().split())
S = input()


def move_snuke():
    global A, B
    if B == D:
        return False
    if S[B + 1] == '.' and A != B + 1:
        B += 1
        return True
    if S[B + 2] == '.' and A != B + 2:
        B += 2
        return True
    return False


def move_fnuke():
    global A, B
    if A == C:
        return False
    if S[A + 1] == '.' and B != A + 1:
        A += 1
        return True
    if S[A + 2] == '.' and B != A + 2:
        A += 2
        return True
    return False


S = '#' + S
while True:
    if C < D:
        if not move_snuke():
            if not move_fnuke():
                print('No')
                break
    else:
        if not move_fnuke():
            if not move_snuke():
                print('No')
                break
    if A == C and B == D:
        print('Yes')
        break


Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
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 << endl; }
 
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(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
const ll mod = 998244353;
 
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define S second
#define F first
#define M_PI 3.14159265358979323846

ll sqr(ll n) {
	return n*n;
}

ll gcd(ll a, ll b) {
	while(b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

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

bool prime(int n) {
	int i = 2;
	while (i*i <= n) {
		if (n % i == 0) return false;
		i++;
	}
	return true;
}
ll binpow(ll a, ll n) {
	if (n == 0)
		return 1;
	if (n % 2 != 0) return binpow(a, n-1)*a; else {
		ll b = binpow(a, n/2);
		return b*b;
	}
}

void solve() {
	int n, m;
	cin >> n >> m;

	ll sum = 0;
	for (int i = 0; i < m; i++) {
		ll x;
		cin >> x;
		sum += x;
	}
	if (n-sum < 0) {
		cout << -1 << endl;
	} else cout << n-sum << endl;
}
 
int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}

	return 0;
}

Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Main
{
    class Program
    {
        static void Main(string[] arg)
        {
            int answer = 0;
            int n = int.Parse(Console.ReadLine());
            //int[] ta = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            if (n == 2)
            {
                int a = int.Parse(Console.ReadLine());
                int b = int.Parse(Console.ReadLine());
                answer = a + b;
                Console.WriteLine(answer);

            }
            else
            {
                Console.WriteLine("Hello World");
            }
            Console.ReadLine();

        }
    }
}

Measured memory_bytes: 11092
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt()-i+1;
		}
		Arrays.sort(A);
		int t = A[N/2];
		long ans = 0;
		for (int i = 0; i < N; i++) {
			ans += (Math.abs(A[i]-t));
		}
		System.out.println(ans);
	}



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

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

using namespace std;

struct cake {
  int width, depth;
  cake(int w, int d){
    width = w;
    depth = d;
  }
  bool operator < (const cake &right) const {
    return width*depth < right.width*right.depth;
  }
};

int main()
{
  int n, w, d;
  while(cin >> n >> w >> d, n || w || d){
    vector<cake> cs;
    cs.push_back(cake(w, d));
    while(n--){
      int p, s; cin >> p >> s;
      p--;
      int w0, d0, w1, w2, d1, d2;
      w0 = w1 = w2 = cs[p].width;
      d0 = d1 = d2 = cs[p].depth;
      s %= (w0 + d0 + w0 + d0);
      cs.erase(cs.begin() + p);
      if(s > w0 + d0 + w0){
	d1 = s - w0 - d0 - w0;
	d2 = d0 - d1;
      } else if(s > w0 + d0){
	w1 = s - w0 - d0;
	w2 = w0 - w1;
      } else if(s > w0){
	d1 = s - w0;
	d2 = d0 - d1;
      } else {
	w1 = s;
	w2 = w0 - w1;
      }
      if(w1*d1 <= w2*d2){
	cs.push_back(cake(w1, d1));
	cs.push_back(cake(w2, d2));
      } else {
	cs.push_back(cake(w2, d2));
	cs.push_back(cake(w1, d1));
      }
    }
    sort(cs.begin(), cs.end());
    for(int i = 0; i < cs.size(); i++){
      cout << (i == 0 ? "":" ") << cs[i].width*cs[i].depth;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N; cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    sort(all(a), greater<ll>());
    ll ans = 0;
    
    for(int i = 1; i < N; i++){
        if(i == 1) ans += a[0];
        else{
            ans += a[(i + 2) / 2 - 1];
        }
    }
    cout << ans << endl;

}



Measured memory_bytes: 4840
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        for(int i = 1; ; i++){
            if(stdIn.nextInt() == 0){
                System.out.println(i);
                break;
            }
        }
        
        //String s = stdIn.next();
        //boolean flag;
        

        
    }
}


Measured memory_bytes: 35756
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        
        if(S.length() == 2){
            System.out.println(S);
        }else {
            for(int i=2; i>=0; i--){
                System.out.print(S.charAt(i));
            }  
        }
    }
}



Measured memory_bytes: 35384
#include <cstdint>
#include <iostream>

using namespace std;
#define GRAPH_SIZE 8
static bool graph[GRAPH_SIZE][GRAPH_SIZE];
static bool visited[GRAPH_SIZE];

static void init_graph()
{
  for (uint32_t i = 0; i < GRAPH_SIZE; i++) {
    for (uint32_t j = 0; j < GRAPH_SIZE; j++) {
      graph[i][j] = false;
    }
    visited[i] = false;
  }
}

static bool is_visited_all(uint32_t N)
{
  bool ret = true;

  for (uint32_t i = 0; i < N; i++) {
    ret &= visited[i];
  }

  return ret;
}

static size_t dfs(uint32_t N, uint32_t node)
{
  if (is_visited_all(N)) {
    return 1;
  }

  uint32_t count = 0;
  for (uint32_t i = 0; i < N; i++) {
    if ((!visited[i]) && graph[node][i]) {
      visited[i] = true;
      count += dfs(N, i);
      visited[i] = false;
    }
  }

  return count;
}

int32_t main()
{
  init_graph();

  uint32_t N, M;
  cin >> N >> M;

  for (uint32_t i = 0; i < M; i++) {
    uint32_t from, to;
    cin >> from >> to;
    graph[from - 1][to - 1] = true;
    graph[to - 1][from - 1] = true;
  }

  visited[0] = true;
  cout << dfs(N, 0) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int ans=0;
    int n,gusu=0,sim=1;
    int a[100];

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]%2==0)gusu++;
    }
    ans=1;
    for(int i=0;i<n;i++){
        ans*=3;
    }
    for(int i=0;i<gusu;i++){
        sim*=2;
    }
    printf("%d\n",ans-sim);
    return 0;
}

Measured memory_bytes: 128
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >> replicateM 3 getLine >>= print . sum . map ( subtract 1 . length . group . sort ) . transpose

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

int main(){
	int a,b;
	cin >> a >> b;
	if(a + b >= 10){
		cout << "error"<<endl;
	}
	else{
		cout << a+b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << (x) << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

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

    OUT(x < 1200 ? "ABC" : "ARC");

    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,x;
    cin >> n >> x;
    int a[n];
    long long int sum = 0;
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    if(sum == x)
    {
        cout << n << "\n";
    }
    else
    {
        sort(a,a + n);
        sum = 0;
        int i = 0;
        while(i < n && sum < x)
        {
            if(sum + a[i] > x)
            {
                break;
            }
            sum += a[i];
            i++;
        }
        if(i == n)
        {
            i--;
        }
        cout << i << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
//#include<bits/stdc++.h>
int main()
{
	char a[110]={};
	int c,cnt=0,i,j;
	while(~scanf("%s",a)){
		cnt=0;		
		c=strlen(a);
		if(c%2){//奇数 
			for(i=0,j=c-1;i<c/2;i++,j--)
				if(a[i]!=a[j])
					cnt++;
//			printf("%d\n",cnt);
		}else{//偶数 
			for(i=0,j=c-1;i<c/2;i++,j--)
				if(a[i]!=a[j])
					cnt++;
//			printf("%d\n",cnt); 
		}
		printf("%d\n",cnt);
//		memset(a,0,sizeof(a));
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define endl "\n"
#define int long long

int32_t main()
{
      ios::sync_with_stdio(false);
      cin.tie(0); 
      int n,w;
      cin>>n>>w;
      vector<vector<int> > dp(n+1, vector<int> (w+1)), v(n+1, vector<int> (2)); 
      for(int i = 0; i < n; i++) {
            cin>>v[i+1][0]>>v[i+1][1];
      }
      // dp[i][j] --> gives value while choosing ith item, and weigth formed is j.

      for(int i = 1; i <= n; i++) {
            for(int j = 0; j <= w; j++) {
                  if(j-v[i][0]<0){
                        dp[i][j] = dp[i-1][j];
                        continue;
                  }
                  dp[i][j] = max(dp[i-1][j-v[i][0]]+ v[i][1], dp[i-1][j]);
            }
      }
      int ans = 0;
      for(int i = 1; i < n+1; i++) {
            ans = max(ans,dp[i][w]);
      }
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 80256
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String string = scanner.next();
        Pattern[] p = new Pattern[8];
        p[0] = Pattern.compile("^.*keyence$");
        p[1] = Pattern.compile("^k.*eyence$");
        p[2] = Pattern.compile("^ke.*yence$");
        p[3] = Pattern.compile("^key.*ence$");
        p[4] = Pattern.compile("^keye.*nce$");
        p[5] = Pattern.compile("^keyen.*ce$");
        p[6] = Pattern.compile("^keyenc.*e$");
        p[7] = Pattern.compile("^keyence.*$");
        for (int i = 0; i < 8; i++) {
            Matcher m = p[i].matcher(string);
            if (m.find()) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }

}


Measured memory_bytes: 23252
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int A, B;
    cin >> A >> B;
    if (A + B >= 10) {
        cout << "error" << endl;
    }
    else {
        cout << A + B << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

import math as mt
angle=max(30*h+0.5*m, 6*m)-min(30*h+0.5*m, 6*m)

if angle>180:
  angle=360-angle
  
d=a**2+b**2-2*a*b*mt.cos(mt.radians(angle))
c=mt.sqrt(d)
print(c)

Measured memory_bytes: 9568
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vishal Burman
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DCaracalVsMonster solver = new DCaracalVsMonster();
        solver.solve(1, in, out);
        out.close();
    }

    static class DCaracalVsMonster {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long h = in.nextLong();
            long sum = 0;
            for (int i = 0; ; i++) {
                if (h < 1)
                    break;
                sum += (long) Math.pow(2, i);
                h = (long) Math.floor(h / 2.0);
            }
            out.println(sum);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22868