akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 1e5 + 5;

int sum,n,k,a[N],b[N];

bool f(int x) {
  int cnt = 0;
  for (int i = 1 ; i <= n ; i++)
    b[i] = x - (a[i] % x);
  sort(b + 1 , b + n + 1);
  int l = 1 , r = n;
  while(l < r) {
    bool flag = 0;
    if (b[l] % x == 0) {
      l++;
      flag = 1;
    }
    if (b[r] % x == 0) {
      r--;
      flag = 1;
    }
    if (flag == 0) {
      int h = min(b[l] % x, x - (b[r] % x));
      b[l] -= h;
      b[r] += h;
      cnt += h;
    }
  }
  return cnt <= k;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n >> k;
  for (int i = 1 ; i <= n ; i++) {
    cin >> a[i];
    sum += a[i];
  }
  for (int i = sum ; i >= 1 ; i--) 
    if (sum % i == 0 && f(i)) {
      cout << i << "\n";
      return 0;
    }
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

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

	if (d == 25)cout << "Christmas" << endl;
	if (d == 24)cout << "Christmas Eve" << endl;
	if (d == 23)cout << "Christmas Eve Eve" << endl;
	if (d == 22)cout << "Christmas Eve Eve Eve" << endl;

	return 0;
}

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

using namespace std;

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

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

  vector<ll> ans(a.size(), 0);
  // 最初の山に降った雨量を決定する
  ans[0] = accumulate(a.begin(), a.end(), 0ll);
  for (int i = 1; i < a.size() - 1; i += 2) {
    ans[0] -= a[i] * 2; 
  }

  // 残りの山に降った雨量を決定する
  for (int i = 1; i < a.size(); i++) {
    ans[i] = 2 * a[i - 1] - ans[i - 1];
  }

  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i];
    cout << (i == ans.size() - 1 ? '\n' : ' ');
  }

  return 0;
}

Measured memory_bytes: 2816
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N, M, K := getInt(), getInt(), getInt()

	for i := 0; i <= N; i++ {
		for j := 0; j <= M; j++ {
			k := (M-j)*i + (N-i)*j
			if K == k {
				out("Yes")
				return
			}
		}
	}
	out("No")
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 3e3 + 100;

int n, m;
int a[N][N], k;
int dp[N][N][4];

int solve(int x, int y, int taken){
   if (x == n and y == m){
      if (taken < 3){
         return a[x][y];
      }
      return 0;
   }
   if (x >= n+1){
      return -inf;
   }

   if (y >= m +1 or x >= n +1){
      return -inf;
   }

   int &ans = dp[x][y][taken];
   if (ans != -1){
      return ans;
   }

   // dont includes possibility
   ans = solve(x, y + 1, taken);
   smax(ans, solve(x + 1, y, 0));

   if (taken < 3){
      smax(ans, a[x][y] + solve(x, y + 1, taken + 1));
      smax(ans, a[x][y] + solve(x + 1, y, 0));
   }

   return ans;
}

int32_t main(){_
   
   cin >> n >> m >> k;

   for (int i = 0; i < k; ++i)
   {
      int x, y, vals;
      cin >> x >> y >> vals;
      a[x][y] = vals;
   }
   
   // for (int i = 1; i <= n; ++i)
   // {
   //    ms.clear();
   //    for (int j = 1; j <= m; ++j)
   //    {
   //       ms.insert(a[i][j]);
   //       cost[i][j] = getMax();
   //    }
   // }

   memset(dp, -1, sizeof dp);

   cout<<solve(1,1,0);

   return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
  ll W,H; cin >> W >> H;
  
  ll a = W+1; 
  ll b = H+1;
  
  vector<pair<ll,ll>> edge;
  
  for(int i = 0; i < W; i++){
    ll p; cin >> p; edge.push_back({p,1});
    // 1 は x方向を意味
  }
  
  for(int j = 0; j < H; j++){
    ll q; cin >> q; edge.push_back({q,2});
  }
  
  sort(edge.begin(),edge.end());
  
 
  int itr = 0; 
  
  ll ans = 0; ll cnt = 0;
  
  while( true ){
    
    ll cost = edge[itr].first;
    int dir = edge[itr].second;
    
    if( dir == 1 && a > 0){ 
      ans += cost*b; cnt += b; a--; 
    }
    if( dir == 2 && b > 0){
      ans += cost*a; cnt += a; b--;
    }
    
    if( cnt >= (W+1)*(H+1)-1){break;}
       
    itr++;
  }
  
  cout << ans << endl;
  
  return 0;
}
    


Measured memory_bytes: 6384
package main

import (
	"fmt"
	"strconv"
)

func main() {
	// Code for A - Digit Sum 2
	var N string
	fmt.Scan(&N)

	var T string
	for i := 0; i < len(N)-1; i++ {
		T += "9"
	}

	var c int
	var ans int
	c, _ = strconv.Atoi(N[0:1])
	if N[1:len(N)] == T {
		ans = c + 9*len(T)
		fmt.Println(ans)
	} else {
		ans = c + 9*len(T) - 1
		fmt.Println(ans)
	}
}


Measured memory_bytes: 1772
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1] * (n+1)
    self.rank = [0] * (n+1)
  
  def find(self, x):
    if self.root[x] < 0:
      return x
    else:
      self.root[x] = self.find(self.root[x])
      return self.root[x]
  
  def unite(self, x, y):
    xr = self.find(x)
    yr = self.find(y)
    if xr == yr:
      return
    elif self.rank[xr] < self.rank[yr]:
      self.root[yr] += self.root[xr]
      self.root[xr] = yr
    else:
      self.root[xr] += self.root[yr]
      self.root[yr] = xr
      if self.rank[xr] == self.rank[yr]:
        self.rank[xr] += 1
   
  def same(self, x, y):
    return self.find(x) == self.find(y)
  
  def count(self, x):
    return -self.root[self.find(x)]

N, K, L = map(int, input().split())
roads = UnionFind(N)
for _ in range(K):
  x, y = map(int, input().split())
  roads.unite(x, y)
rails = UnionFind(N)
for _ in range(L):
  x, y = map(int, input().split())
  rails.unite(x, y)
r_dict = {}
for i in range(1, N+1):
  x, y = roads.find(i), rails.find(i)
  if (x, y) in r_dict:
    r_dict[(x, y)] += 1
  else:
    r_dict[(x, y)] = 1
ans = []
for i in range(1, N+1):
  x, y = roads.find(i), rails.find(i)
  ans.append(r_dict[(x, y)])
print(' '.join(map(str, ans)))

Measured memory_bytes: 52836
#include<bits/stdc++.h>
#define mino "test"
#define ll long long
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define matrix vector<vector<ll>>
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define Down(i,a,b) for(int i=a; i>=b; i--)
#define FOR_(i,a,b) for(int i=a; i<b; i++)
#define turbo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oo 1e18

const int N = 5e3 + 5;

using namespace std;

typedef pair<int,int> pii;


int n;
int a[N];
ll F[N][N];
ll A, B;

void nhap()
{
    cin >> n >> A >> B;
    FOR(i,1,n) cin >> a[i];

    FOR(i,1,n) F[1][i] = oo;
    F[1][a[1]] = 0;
    F[1][0] = A;
}

void xuli()
{
    ll res = oo;
    if(n == 1) res = 0;
    FOR(i,2,n)
    {
        FOR(j,0,n) F[i][j] = oo;
        FOR(j,0,n)
        {
            if(j > a[i]) F[i][j] = min(F[i][j], F[i-1][j] + B);
            else if(j < a[i])
            {
                F[i][a[i]] = min(F[i][a[i]], F[i-1][j]);
                F[i][j] = min(F[i][j], F[i-1][j] + A);
            }
            if(i == n) res = min(res, F[i][j]);
        }
    }
    cout << res;
}

int main()
{
    //freopen(mino".inp","r",stdin);
    //freopen(mino".out","w",stdout);
    nhap();
    xuli();
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  ll N, A, B, C, D; cin >> N >> A >> B >> C >> D;
  ll diff = B-A;
  string result = "NO";
  rep(i,N-1) {
    ll l = C*i - D*((N-1)-i);
    ll r = D*i - C*((N-1)-i);
    if (l<=diff && r>=diff) result = "YES";
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
ll arr[100000][3] = {};
ll res[100000][3] = {};
ll n;
ll solve(ll n){
	res[0][0] = arr[0][0];
	res[0][1] = arr[0][1];
	res[0][2] = arr[0][2];
	
	for (int u = 1; u < n; u++){
		for (int i = 0; i < 3; i++){
			for (int j = 0; j < 3; j++){
				if (i != j){
					res[u][i] = arr[u][i] + max(res[u-1][j], res[u-1][3 - i - j]);
				}
			}
		}
	}
	return max(max(res[n - 1][0], res[n - 1][1]), res[n - 1][2]);
}
int main(){
	cin >> n;
	for (ll i = 0; i < n; i++){
		for (ll j = 0; j < 3; j++){
			cin >> arr[i][j];
		}
	}
	cout<<solve(n);
	//getchar();
	//getchar();
	return 0;
}

Measured memory_bytes: 4992
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long 
#define ll long long 
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair 
#define INF 1000000000
#define MOD 1000000007
#define MAXN 100100
using namespace std;

int n,m;
vector<int>G[MAXN];
int color[MAXN];

bool isodd(int x,int c)
{
	color[x]=c;
	for(int i=0;i<G[x].size();i++)
	{
		if(color[G[x][i]]==c)return false;
		if(color[G[x][i]]!=-1)continue;
		if(!isodd(G[x][i],1-c))return false;
	}
	return true;
}

int main()
{
	scanf("%d%d",&n,&m);
	
	for(int i=0;i<m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--;y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	memset(color,-1,sizeof(color));
	
	if(isodd(0,0))
	{
		int cnt1=0,cnt2=0;
		for(int i=0;i<n;i++)
		{
			if(color[i]==0)cnt1++;
			else cnt2++;
		}
		printf("%lld\n",(ll)cnt1*cnt2-(ll)m);
	}
	else
	{
		printf("%lld\n",(ll)n*(n-1)/2-(ll)m);
	}

	return 0;	
} 

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int r = 0, g = 0, b = 0;
  for (char c : S) c == 'R' ? r++ : c == 'G' ? g++ : b++;
  long ans = 1L * r * g * b;
  for (int i = 0; i < N; i++) {
    for (int j = 1; i + j + j < N; j++) {
      if ((S.at(i) ^ S.at(i + j) ^ S.at(i + j + j)) == ('R' ^ 'G' ^ 'B')) ans--;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3636
def triangleArea(a, b)
  ((a[0] * b[1] - a[1] * b[0])/2.0).abs
end

def isParallel(p)
  eps = 1e-11
  va = [p[0] - p[2], p[1] - p[3]]
  vb = [p[4] - p[6], p[5] - p[7]]
  if triangleArea(va, vb) < eps
    true
  else
    false
  end
end

if __FILE__ == $0
  points = gets.to_i.times.map{ gets.split.map(&:to_f) }.each do |points|
    puts (isParallel(points) ? "YES" : "NO")
  end
end

Measured memory_bytes: 6120
#include <iostream>
#include <string>

int main()
{
    const std::string str_false = "Hoshino";
    const std::string str_true = "Hoshina";

    u_int num_of_data;
    std::string text;
    std::cin >> num_of_data;
    std::cin.ignore();
    
    for(u_int i = 0; i < num_of_data; ++i){
        getline(std::cin, text);
        int index = 0;
        
        while((index = text.find(str_false, index)) != (int)std::string::npos)
            text.replace(index, str_false.size(), str_true);
        std::cout  << text << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

char s;
bool flag;

int main() {
    while (std::cin >> s) {
        if (s == '7')   flag = true;
    }
    puts(flag ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3616
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            int[] A = in.Int(N + 1);
            if (N == 0) {
                if (A[0] <= 1) {
                    out.println(1);
                } else {
                    out.println(-1);
                }
                return;
            }
            if (N > 0 && A[0] > 0) {
                out.println(-1);
                return;
            }

            long[] B = new long[N + 1];
            B[N] = A[N];
            for (int i = N - 1; i >= 0; i--) {
                B[i] = B[i + 1] + A[i];
            }

            long ans = 1;
            long cur = 1;
            for (int i = 1; i < N; i++) {
                long temp = cur * 2 - A[i];
                if (temp <= 0) {
                    out.println(-1);
                    return;
                }
                cur = Math.min(temp, B[i + 1]);
                ans += cur + A[i];
            }
            if (cur > A[N] || cur * 2 < A[N]) {
                out.println(-1);
            } else {
                out.println(ans + A[N]);
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

        public int[] Int(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Int();
            }
            return a;
        }

    }
}



Measured memory_bytes: 45296
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N;
	string S;
	cin >> N >> S;
	string temp = "";

	rep(i, N/2)
		temp += S[i];
	if (temp + temp == S)
		cout << "Yes" << '\n';
	else
		cout << "No" << '\n';
	return 0;
}


Measured memory_bytes: 256
from collections import deque

H,W=map(int,input().split())
A=[input() for i in range(H)]
ans=0
V=[[0 for i in range(W)] for j in range(H)]

def bfs(q):
    tmp=deque(q)
    ch = [[False for i in range(W)] for j in range(H)]
    count = 0
    d=[[-1,0],[1,0],[0,-1],[0,1]]
    while tmp:
        x,y=tmp.popleft()
        for a,b in d:
            nx=x+a
            ny=y+b
            if 0<=nx<H and 0<=ny<W:
                if ch[nx][ny]!=True and A[nx][ny]==".":
                    V[nx][ny]=V[x][y]+1
                    ch[nx][ny]=True
                    tmp.append([nx,ny])
            else:
                continue
ju=[]
for i in range(H):
    for j in range(W):
        if A[i][j]=="#":
            ju.append([i,j])
bfs(ju)
for i in range(H):
    for j in range(W):
        if not A[i][j]=="#":
             ans=max(ans,V[i][j])
print(ans)



Measured memory_bytes: 165000
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

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

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

vector<vector<pii>>adj(2);
vector<int>ans;
int maxi = 0;

void dfs(int v,int prev,int skip){
     int color = 1;
     for(int i = 0;i<adj[v].size();i++){
        if(adj[v][i].first==prev) continue;
        if(color == skip) color++;
        int idx = adj[v][i].second;
        ans[idx] = color;
        maxi = max(maxi,color);
        color++;
        dfs(adj[v][i].first,v,color-1);
}
}

void solve(){
     int n;cin >> n;
     adj.resize(n+1);
     ans.resize(n+1);
     for(int i = 0;i<n-1;i++){
        int v,u;cin >> v >> u;
        adj[v].push_back({u,i});
        adj[u].push_back({v,i});
     }
     dfs(1,0,0);
     cout << maxi <<endl;
     for(int i = 0;i<n-1;i++)
        cout << ans[i] <<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 11148
# N以下の約数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


N = int(input())
cand = make_divisors(N)

ans = []
for c in cand:
    ans.append((N//c - 1) + c - 1)

print(min(ans))


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

int main(void) {
    long long N, A, B;
    cin >> N >> A >> B;

    long long c = N / (A+B);
    long long d = N % (A+B);
    long long e = 0;

    if (d >= A) e = A;
    else e = d;

    cout << (c * A) + e << endl;

    return 0;
}


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

int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y>> r;
	if ((x+r <=W)&&(x-r >= 0)&&(y+r <=H)&&(y-r >= 0) ){
		cout <<"Yes"<<endl;
	}else {
		cout <<"No"<<endl;
	}
	return 0;
}

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

bool BinarySearch(int n, int A[], int key){
    int left = 0;
    int right = n;
    while(left < right){
        int mid = (left + right) / 2;
        
        if(A[mid] == key)  return true;
        else if(key < A[mid])  right = mid;
        else left = mid + 1;
        
    }
    return false;
}

int main(void){
    // Your code here!
    int n,S[100000],q,T[100000];
    int count = 0;
    
    cin >> n;
    for(int i = 0; i < n;i++){  //S配列
        cin >> S[i];
        //cout << S[i] << endl;
    }
    
    cin >> q;
    for(int i = 0; i < q; i++){   //T配列
        cin >> T[i];
        //cout << T[i] << endl;
    }
    
    for(int j = 0; j < q; j++){
        if(BinarySearch(n, S, T[j])) count++;
    }
    
    cout << count << endl;
    
}



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

using lint = int64_t;
#define bit(n) ((lint)1 << n);
const int INF = 1e9;
const lint LINF = 1e18;

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

class IoSetup {
    public:
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
        cerr << fixed << setprecision(12);
    }
} iosetup;

struct Edge {
    vector<double> l, r;
    Edge(): l(3, 1e12), r(3, -1e12) {}

    void add(double x, int v) {
        v++;
        l[v] = min(x, l[v]);
        r[v] = max(x, r[v]);
    }
    vector<double> events() {
        vector<double> res;
        for (int i = 0; i < 3; i++) {
            for (int j = i + 1; j < 3; j++) {
                double cand = (l[i] - l[j]) / (j - i);
                if (cand > 0) {
                    res.push_back(cand);
                }
            }
        }
        for (int i = 0; i < 3; i++) {
            for (int j = i + 1; j < 3; j++) {
                double cand = (r[i] - r[j]) / (j - i);
                if (cand > 0) {
                    res.push_back(cand);
                }
            }
        }
        return res;
    }
    double get(double t) {
        double lmin = 1e12, rmax = -1e12;
        for (int i = 0; i < 3; i++) {
            lmin = min(lmin, l[i] + (i - 1) * t);
            rmax = max(rmax, r[i] + (i - 1) * t);
        }
        return rmax - lmin;
    }
};

int main() {
    int n;
    cin >> n;
    Edge xs, ys;
    for (int i = 0; i < n; i++) {
        double x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'R') {
            xs.add(x, 1);
            ys.add(y, 0);
        } else if (c == 'L') {
            xs.add(x, -1);
            ys.add(y, 0);
        } else if (c == 'U') {
            xs.add(x, 0);
            ys.add(y, 1);
        } else if (c == 'D') {
            xs.add(x, 0);
            ys.add(y, -1);
        }
    }

    vector<double> ev = {0, 1e12};
    auto e = xs.events(), f = ys.events();
    ev.insert(ev.end(), e.begin(), e.end());
    ev.insert(ev.end(), f.begin(), f.end());

    sort(ev.begin(), ev.end());
    double ans = 1e18;
    for (double t: ev) {
        ans = min(ans, xs.get(t) * ys.get(t));
    }
    cout << ans << endl;

    return 0;
}

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

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

	bool seven = false;
	for (int i = 0; i < 3; i++) {
		if (N[i] == '7') {
			seven = true;
		}
	}

	if (seven) {
		printf("Yes");
	} else {
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 3720
#include <stdio.h>

int main(void){
  int n;
  scanf("%d", &n);
  int a;
  int i;
  int flag = 1;
  for(i=0; i<n; i++){
    scanf("%d", &a);
    if(a % 2 == 0)
      if(!(a % 3 == 0 || a % 5 == 0)){
	flag = 0;
	break;
      }
  }
  if(flag == 0)
    puts("DENIED");
  else
    puts("APPROVED");
  
  return 0;
}


Measured memory_bytes: 128
N = input()
T = [input() for _ in range(N)]

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

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

ans = 1
for t in T:
    ans = lcm(ans, t)
print ans


Measured memory_bytes: 2568
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
Graph g;

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

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

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

	g = Graph(n);

	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;

		g[a].push_back(b);
		g[b].push_back(a);
	}

	REP(i, n) {
		if (g[i].size() == 0) {
			cout << "No""" << endl;
			return 0;
		}
	}

	vi dist(n, -1);
	queue<int> que;
	vi ans(n, -1);

	dist[0] = 0;
	que.push(0);

	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int nv : g[v]) {
			if (dist[nv] != -1)continue;

			//cout << nv + 1 << "to" << v + 1 << endl;
			ans[nv] = v;
			dist[nv] = dist[v] + 1;
			que.push(nv);
		}
	}

	cout << "Yes" << endl;
	REPS(i, n-1) {
		cout << ans[i]+1 << endl;
	}

}

Measured memory_bytes: 10720
S = input()

ans = 'Yes'
A = ['R', 'U', 'D']
B = ['L', 'U', 'D']
for i in range(len(S)):
  if (i % 2 == 0):
    if (S[i] not in A):
      ans = 'No'
      break
  else:
    if (S[i] not in B):
      ans = 'No'
      break
print(ans)

Measured memory_bytes: 38384
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 count = 0;
  int[] d = new int[5];
  for(int i = A;i<=B;i++){
    d[0] = i/10000;
    d[1] = (i%10000)/1000;
    d[2] = (i%1000)/100;
    d[3] = (i%100)/10;
    d[4] = i%10;
    if(d[0] == d[4]&& d[1] == d[3]){count += 1;}
  }
    System.out.println(count);
}
}
      
    


Measured memory_bytes: 22224
#include<iostream>
#include<stdio.h>

int main()
{
	int a[10000];
	int n;
	int max = -20000000;
	int min = 20000000;
	long long int sum = 0;
	std::cin >> n;
	int i;
	for (i = 0; i < n; i++){
		std::cin >> a[i];
		if (max < a[i])
			max = a[i];
		if (min > a[i])
			min = a[i];
		sum += a[i];
	}
	printf("%d %d %lld\n", min, max, sum);
	return 0;
}

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

using namespace std;

#ifdef Lin1043
    #define DEBUG(msg, ...) printf("(%s #%d) " msg, __FUNCTION__, __LINE__, __VA_ARGS__)
    #define massert(...) assert(...)
#else
    #define DEBUG(...)
    #define massert(...)
#endif

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

struct iopener
{
    iopener()
    {
#ifdef Lin1043
        freopen("./in" , "r" , stdin);
#endif
    }
} iop;

typedef long long LL;

template<typename T>inline bool chkmin(T &x , const T &y) { return x > y ? (x = y , 1) : 0; }
template<typename T>inline bool chkmax(T &x , const T &y) { return x < y ? (x = y , 1) : 0; }

template<typename T>inline T read(T &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c)) x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

const int N = 100000 + 5;

int n , A[N] , B[N];

int main()
{
    read(n);
    rep(i , 1 , n)
        B[i] = read(A[i]);
    sort(B + 1 , B + 1 + n);
    LL Ans = 0;
    rep(i , 1 , n)
    {
        int p = lower_bound(B + 1 , B + 1 + n , A[i]) - B;
        Ans += abs(p - i) % 2 == 1 ? 1 : 0;
    }
    cout << Ans / 2 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

typedef long long i64;
const int MAX_N = 100005;

int K, A[MAX_N];

int main() {
  scanf("%d", &K);
  for (int i = K; i; --i)
    scanf("%d", &A[i]);
  
  i64 L = 2, R = 2;
  for (int i = 1; i <= K; ++i) {
    if ((L - 1) / A[i] == R / A[i]) {
      puts("-1");
      return 0;
    }
    L = (L + A[i] - 1) / A[i] * A[i];
    R = R / A[i] * A[i] + A[i] - 1;
  }
  printf("%lld %lld\n", L, R);
  return 0;
}


Measured memory_bytes: 512
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.tail.head.split(' ').map(_.toLong).toArray
  val s = ls.sorted.reverse
  val longest = s.head
  val others = s.tail.sum
  val ret = if(longest < others) "Yes" else "No"
  println(ret)
}


Measured memory_bytes: 25508
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset>
#include<unordered_map> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include "boost/algorithm/string.hpp"
#define fio ios_base::sync_with_stdio(false)
#define mod 1000000007
#define mod1 mod
#define mod2 100000009
#define li long long int
#define ll li
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%I64d",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 1000000000000000000
#define MINN -1000000000000000000
#define INTMAX 1000001000
#define pii pair<ll,ll> 
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 200050
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 3.1415926535
#define lgn 20
 
 
// #define INTMAX 200000000 
 
// using namespace boost;
// #define si short int
 
using namespace std;
using namespace __gnu_pbds;             
typedef priority_queue<pii, vector<pii> ,greater < pii > > min_pq;
// typedef priority_queue<pii, vector<pii> , greater<pii >  > min_pq;
ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}
 
// using namespace __gnu_pbds;         
// typedef priority_queue<pair<ll,char> , vector<pair<ll , char> > > max_pq;
// typedef priority_queue<pii , vector<pii > ,greater<pii > > min_pq;
typedef tree<pii , null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> OST;
// typedef priority_queue<pair < ll , pair < pii , ll > >  , vector<pair < ll , pair < pii , ll > >  > ,greater<pair < ll , pair < pii , ll > >  > > min_pq;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif
#define nn 2000005
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    if ( n == 1 )
        cout <<"Hello World";
    else
    {
        ll a,b;
        cin >> a >> b;
        cout <<(a+b);
    }



}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <map>

using namespace std;

bool prime(int p){
	if ((p==0)||(p==1)){return false;}
	else if(p==2){return true;}
	else{
		for(int i=2; i*i<=p; i++){
			if(p%i == 0){return false;}
		}
	}
	return true;
}

int main()
{
	int n;
	map<int,bool> p;

	for(int i=0; i<1000000; i++){
		if(prime(i)){ p[i]=true;}
	}

	while(cin >> n){
		int count = 0;
		if(n>=2){count++;}
		for(int i=1; i<n+1; i=i+2){
			if(p[i]){count++;}
		}

		cout << count << endl;
	}
}

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N, M; cin>>N>>M;
    vector<int> A[31];
    for(int i = 0; i < N; i++)
    {
        int k;
        cin>>k;
        for(int j = 0; j < k; j++)
        {
            int a; cin>>a;
            A[i].push_back(a);
        }
        
    }


    int ans = 0;
    for(int i = 1; i <= M; i++)
    {
        int c = 0;
        for(int j = 0; j < N; j++)
        {
            for(int x : A[j]){
                if(x==i){
                    c++;
                }
            }
        }
        if(c==N)ans++;
    }
    
    cout<<ans<<endl;

    return 0;
}

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

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

t = 100000000000000000000000000000000000000000

for i in A:
    s = 0
    for s in range(i):
        if i % 2 == 0:
            i = i//2
            continue
        else:
            break
    if s < t:
        t = s
print(t)

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

int main() {
    int index = 0;
    char s[11], output[11];
    scanf("%s", s);

    for (int i = 0; s[i] != '\0'; i++) {
        if (s[i] == '0') {
            output[index] = '0';
            index++;
        } else if (s[i] == '1') {
            output[index] = '1';
            index++;
        } else if (s[i] == 'B') {
            if (index > 0) {
                index--;
                output[index] = '\0';
            }
        }
    }

    output[index] = '\0';
    printf("%s", output);
    
    return 0;
}

Measured memory_bytes: 1728
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    v = LIR(m)
    v.sort(key = lambda x:x[1])
    ans = 0
    r = 0
    for a,b in v:
        if r < a:
            ans += 1
            r = b-1
        else:
            continue
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


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

using namespace std;

#define ll long long

int main(void){
    string s;
    cin >> s;

    int front = 0, back = s.length()-1;

    int ans = 0;
    while(front <= back){
        if(s[front] != s[back]){
            ans++;
        }
        front++;
        back--;
    }

    cout << ans << endl;

    return 0;
}

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


int main(){
    int n;
    cin>>n;
    int judged[4]={0,0,0,0};

    string judge[n];
    rep(i,n){
        cin>>judge[i];
        if(judge[i]=="AC") judged[0]++;
        else if(judge[i]=="WA") judged[1]++;
        else if(judge[i]=="TLE") judged[2]++;
        else judged[3]++;
    }

    cout<<"AC x "<<judged[0]<<endl;
    cout<<"WA x "<<judged[1]<<endl;
    cout<<"TLE x "<<judged[2]<<endl;
    cout<<"RE x "<<judged[3]<<endl;
}

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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            var S = GetStr();
            var ans = YesNo(S[0] == S[2]);

            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public Double[] GetDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

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

int main() {
    long long N, ans;
    cin >> N;
    vector<long long> A(N, 0);
    bool flag = false;

    for(long long i = 0; i < N; i++){
        cin >> A[i];
        if(A[i] == 0){
            flag = true;
            break;
        }
    }

    if(flag){
        cout << 0 << endl;
        exit(0);
    }

    ans = 1;
    for(long long i = 0; i < N; i++){
        ans = ans * A[i];
        if(ans < 0){
            cout << "-1" << endl;
            return 0;
        }
    }
    if(ans > 0 && ans <= 1000000000000000000){
        cout << ans << endl;
    }else{
        cout << "-1" << endl;
    }
}

Measured memory_bytes: 4360
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1LL<<62;
const int MAX = 1e5;

int main() {
    int n, m; cin >> n >> m;
    vvint data(m);
    rep(i,n) {
        int a, b; cin >> a >> b;
        if (a > m) continue;
        a--;
        data[a].push_back(b);
    }
    priority_queue<int> q;
    int ans = 0;
    rep(i,m) {
        rep(j,data[i].size()) {
            q.push(data[i][j]);
        }
        if (!q.empty()) {
            ans += q.top(); 
            q.pop();
        }
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	vector<int> a(n);
	rep(i, n) cin >> a[i];

	int ans = 0;
	int tar = 1;
	rep(i, n){
		if(a[i] != tar){
			ans++;
		}else{
			tar++;
		}
	}

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


Measured memory_bytes: 1024
use proconio::input;                                                                                                         
                                                                                                                             
fn a() {                                                                                                                     
    input! {                                                                                                                 
        alpha: char                                                                                                          
    }                                                                                                                        
                                                                                                                             
    if alpha.is_ascii_lowercase() {                                                                                          
        println!("a");                                                                                                       
    }                                                                                                                        
    else {                                                                                                                   
        println!("A");                                                                                                       
    }                                                                                                                        
}

fn main() {
    a();
}


Measured memory_bytes: 2108
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <vector>
typedef long long ll;
using namespace std;

void solve(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int ans=0;
	if(a>=c) ans=b+c;
	else{
		ans+=a,c-=a;
		if(b<c) ans+=2*b+1;
		else ans+=b+c;
	}
	printf("%d\n",ans);
}

int main(){
	solve();

    return 0;
}

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

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

using namespace std;

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

	int res = n;
	int counter;
	for (int i = 0; i <= n; i++) {
		counter = 0;
		int t = i;
		while (t > 0) {
			counter += t % 6;
			t = t / 6;
		}
		t = n - i;
		while (t > 0) {
			counter += t % 9;
			t = t / 9;
		}
		res = min(res, counter);
	}
	cout << res << endl;

	return 0;
}

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

using namespace std;

using ll = long long;

void dfs(std::string &s, std::vector<std::string> &numbers, const ll i, const ll size) {
    static const std::vector<char> CHAR753 = {'3', '5', '7'};
    if (i == size) {
        numbers.emplace_back(s);
    } else {
        for (const char c : CHAR753) {
            s[i] = c;
            dfs(s, numbers, i + 1, size);
        }
    }
}

void Get753(std::vector<std::string> &numbers, const ll size) {
    std::string tmp(size, '3');
    dfs(tmp, numbers, 0, size);
}

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

    const ll digit = to_string(N).size();
    if (digit < 3) {
        cout << 0 << endl;
        return 0;
    }

    std::vector<std::string> numbers;

    for (ll i = 3; i <= digit; i++) {
        Get753(numbers, i);
    }

    ll ans = 0;
    for (const auto &x : numbers) {

        bool ok[3] = {false, false, false};
        for (const auto &c : x) {
            if (c == '3') { ok[0] = true; }
            if (c == '5') { ok[1] = true; }
            if (c == '7') { ok[2] = true; }
            if (ok[0] && ok[1] && ok[2]) { break; }
        }

        if (ok[0] && ok[1] && ok[2] && stoi(x) <= N) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  ll N;
  cin >> N;
  string S;
  cin >> S;
  ll r = 0;
  for (ll i = 0; i < N; i++) {
    if (S[i] == 'R') r++;
  }
  ll ans = 0;
  for (ll i = 0; i < r; i++) {
    if (S[i] != 'R') ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3760
import numpy as np


def is_good(mid, key):
    return A_sum - np.minimum(A, mid // F).sum() <= key


def binary_search(bad, good, key):
    while good - bad > 1:
        mid = (bad + good) // 2
        if is_good(mid, key):
            good = mid
        else:
            bad = mid
    return good


N, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)
F = np.array(input().split(), dtype=np.int64)
A.sort()
F[::-1].sort()
A_sum = A.sum()
ans = binary_search(-1, np.max(A * F), K)
print(ans)


Measured memory_bytes: 51852
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author toshibablack
 */

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1.0/LINF;
const char SLA = '\n'; // for JetBrains IDE only supports yen

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

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

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

using namespace std;

class DLamp {
public:
    int H, W;
    vector<string> board;

    void solve(std::istream& in, std::ostream& out) {
        in >> H >> W; in.ignore();

        REP(i, H) {
            string str;
            getline(in, str);
            board.push_back(str);
        }

        auto hor = vector<vector<int>>(2001, vector<int>(2001, 0));
        auto ver = vector<vector<int>>(2001, vector<int>(2001, 0));

        REP(y, H) {
            int cnt = 0;
            int pre = -1;
            REP(now, W+1) {
                if (now == W || board[y][now] == '#') {
                    for (int i = pre + 1; i < now; ++i) {
                        hor[y][i] = cnt;
                    }
                    pre = now;
                    cnt = 0;
                    continue;
                }
                if (board[y][now] == '.') {
                    cnt++;
                    continue;
                }
            }
        }

        REP(x, W) {
            int cnt = 0;
            int pre = -1;
            REP(now, H+1) {
                if (now == H || board[now][x] == '#') {
                    for (int i = pre + 1; i < now; ++i) {
                        ver[i][x] = cnt;
                    }
                    pre = now;
                    cnt = 0;
                    continue;
                }
                if (board[now][x] == '.') {
                    cnt++;
                    continue;
                }
            }
        }

        int ans = 0;
        REP(y, H) REP(x, W) chmax(ans, hor[y][x] + ver[y][x] - 1);
        OUT(ans);
    }
};


int main() {
    DLamp solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 35840