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

using namespace std;

typedef long long ll;

inline ll read()
{
    char ch=getchar();
    ll x=0;
    while(ch<'0' || ch>'9') ch=getchar();
    while(ch>='0' && ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
    return x;
}

ll n,cnt;
ll a[2000010];
bool isnp[2000010];
ll tong[2000010];
ll p[2000010];

void init()
{
    isnp[0]=isnp[1]=true;
    for(ll i=2;i<=1e6;i++)
    {
        if(!isnp[i]) p[++cnt]=i;
        for(ll j=1;j<=cnt && i*p[j]<=1e6;j++)
        {
            isnp[i*p[j]]=true;
            if(i%p[j]==0) break;
        }
    }
}

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

int main()
{
    init();
    n=read();
    for(ll i=1;i<=n;i++) a[i]=read(),tong[a[i]]++;
    bool flag=true;
    for(ll i=1;i<=cnt;i++)
    {
        ll tot=0;
        for(ll j=1;;j++)
        {
            if(p[i]*j>1e6) break;
            tot+=tong[p[i]*j];
        }
        if(tot>=2)
        {
            flag=false;
            break;
        }
    }
    if(flag)
    {
        puts("pairwise coprime");
        return 0;
    }
    ll g=a[1];
    for(ll i=2;i<=n;i++) g=gcd(g,a[i]);
    puts(g==1 ? "setwise coprime" : "not coprime");
    return 0;
}

Measured memory_bytes: 20640
s = input()
k = int(input())
slen = len(s)
new_s = ""

for i in range(slen):
  val = (ord("z") + 1 - ord(s[i])) % 26
  if k >= val:
    k -= val
    new_s += "a"
  else:
    new_s += s[i]
    
if k > 0:
  tmp_val = ord(new_s[slen-1]) + k % 26
  if tmp_val > ord("z"):
    tmp_val -= 26
  new_s = new_s[:-1] + chr(tmp_val)

print(new_s)

Measured memory_bytes: 3444
#include <stdio.h>
int main(){
  int a,b,c,d,x,y,p;
  scanf("%d%d%d%d%d",&a,&b,&c,&d,&p);
  x = a * p;
  if(p <= c){
    y = b;
  }else{
    y = b + (p - c) * d;
  }
  if(x > y){
    printf("%d\n",y);
  }else{
    printf("%d\n",x);
  }
  return 0;
}

Measured memory_bytes: 596
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

# SA, SB, SC = [list(sys.stdin.readline().rstrip()) for _ in range(3)]
# SA.reverse()
# SB.reverse()
# SC.reverse()
#
# turn = 'a'
# while True:
#     if turn == 'a':
#         if len(SA) == 0:
#             print('A')
#             exit()
#         turn = SA.pop()
#     elif turn == 'b':
#         if len(SB) == 0:
#             print('B')
#             exit()
#         turn = SB.pop()
#     elif turn == 'c':
#         if len(SC) == 0:
#             print('C')
#             exit()
#         turn = SC.pop()

S = sys.stdin.readline().rstrip()

ans = []
for c in S:
    if c == 'B':
        if ans:
            ans.pop()
    else:
        ans.append(c)

print(''.join(ans))



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

using namespace std;
long long b[105];
const long long ko=5000000000000000;
int main()
{
	long long k;
	string s;
	cin>>s;
	cin>>k;
	long long tmp=0;
	for(int i=0;i<k;i++)
	{
		if(s[i]!='1')
		{
			cout<<s[i];
			return 0;
		}
		if(i==s.size()-1)
		{
			cout<<1;
			return 0;
		}
	} 
	cout<<1<<endl;
	return 0; 
}


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

int main(){
    string s;
    cin >> s;
    string ans;
    int len = s.size();
    for(int i=0;i<len;i++){
        if(s[i] == '0' or s[i] == '1'){
            ans.push_back(s[i]);
        }
        else if(ans.size() > 0){
            ans.pop_back();
        }
    }
    cout << ans;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	int N; cin >> N;
	vint H(N); cin >> H;
	int cnt = 0;
	int maxv = 0;
	for (int i = 1; i < N; i++) {
		if (H[i-1] >= H[i]) cnt++;
		else cnt = 0;
		chmax(maxv, cnt);
	}
	cout << maxv << endl;	
	return (0);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, k;
  cin >> n >> k;
  map<int, int> mp;
  rep(i, n) {
    int a;
    cin >> a;
    mp[a]++;
  }
  vi v;
  for(auto u : mp) v.push_back(u.second);
  sort(all(v));
  int ans = 0;
  rep(i, v.size() - k) ans += v[i];
  cout << ans << endl;
}

Measured memory_bytes: 10748
n = int(input())
a = list(map(int, input().split()))
from math import factorial
from collections import Counter
def comb(r):
    return int(factorial(r)/factorial(r-2)/factorial(2))
cum = [a[0]]
for i in range(1,n):
    cum.append(cum[-1] + a[i])
cnt = Counter(cum)
ans = 0
for v in cnt.values():
    if v >= 2:
        ans += comb(v)
print(ans+cum.count(0))

Measured memory_bytes: 41468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a,b;
ll mem[5005][5005];
int p[5005], pos[5005];
ll dp(int id, int cur){
    if (mem[id][cur] != -1) return mem[id][cur];
    if (id == 0) return mem[id][cur] = 0;
    if (pos[id] > cur) {
        //printf("%d at %d needs to move to %d, cost %d\n",id,pos[id],cur,b);
        return mem[id][cur] = dp(id-1,cur)+b; ///move id to cur.
    }
    //printf("%d at %d, can move to %d, cost %d\n",id,pos[id],cur,a);
    return mem[id][cur] =  min(dp(id-1,pos[id]),dp(id-1,cur)+a);;
}
int main(){
    scanf("%d%d%d",&n,&a,&b);
    for (int i = 1; i <= n; i++){
        scanf("%d",&p[i]);
        pos[p[i]] = i;
    }
    memset(mem,-1,sizeof(mem));
    printf("%lld",min(dp(n,n),dp(n,pos[n])));

}


Measured memory_bytes: 196224
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
using namespace std;

int main(){
  int x,y;
  cin >> x >> y;
  int Ans = 0;
  Ans = x + y/2;
  printf("%d\n", Ans);
  return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import qualified Control.Monad as Monad

main = loop

loop :: IO ()
loop = do
    [h,w] <- map (read :: String -> Int) . words <$> getLine
    Monad.when (h /= 0 || w /= 0) $ do
        printRectangle h w
        loop

printRectangle :: Int -> Int -> IO ()
printRectangle h w = do
    Monad.forM_ [1..h] $ \_ -> do
        putStrLn $ concat . take w $ repeat "#"
    putStrLn ""

Measured memory_bytes: 4032
#include <stdio.h>
#define MAX 10000

void linearSearch( int * array_s, int * array_t, int n, int q )
{
	int match_number = 0;
	int i = 0, j = 0;

	for ( i = 0 ; i < q; i = i + 1 )
	{
		for( j = 0 ; j < n ; j = j + 1 )
		{
			if ( array_s[j] == array_t[i] )
			{
				match_number = match_number + 1;
				break;
			}
		}
	}

	fprintf( stdout, "%d\n", match_number );
}

int main()
{
	int i;
	int n;
	int S[MAX];

	int q;
	int T[MAX];

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

	scanf( "%d", &q );
	for( i = 0 ; i < q ; i = i + 1 )
	{
		scanf( "%d", &T[i] );
	}

	linearSearch( S, T, n, q );

	return 0;
}

Measured memory_bytes: 648
#include<stdio.h>
int main(void){
    long long n;
    long long i;
    scanf("%lld",&n);
    long long a=1;
    long long b=n,c=n;
    //printf("%lld\n",n);
    for(i=2;i<=c-1;i++){
        if(n%i == 0){
            if((i+n/i-2) < (a+b-2)){
                a=i;
                b=n/i;
                c=b;
            }
        }
        else{
            c=n/i+n%i;
        }
    }
    b=a+b-2;
    printf("%lld",b);
    

    return 0;
}

Measured memory_bytes: 128
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s = sc.next().toArray.map(_.toString.toLong)
  var ans = 0L

  for (i <- 0 until 1 << (s.length - 1)) {
    var sum = s(0)
    for (j <- 0 until s.length-1) {
      if (((i >> j) & 1) == 1) {
        ans += sum
        sum = s(j+1)
      } else {
        sum = sum * 10 + s(j+1)
      }
    }
    ans += sum
  }

  println(ans)
}


Measured memory_bytes: 55308
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//以上テンプレ
int main(){
    string S;
    cin>>S;
    ll count=0;
    rep(i,S.size()-1){
        if(S.at(i)!=S.at(i+1)){
            count++;
        }
    }
    cout<<count<<endl;
    }


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

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

	for(int x, y, z; cin >> x >> y >> z, x;) {
		vector<int> money(y + 1, 0), move(y + 1, 0), v(x);
		for(int i = 0; i < x; ++i)
			cin >> v[i];

		for(int i = 0; i < z; ++i) {
			int n, e, a;
			cin >> n >> e >> a;
			if(e == 1)
				move[n] = a;

			else if(e == 2)
				money[n] = a;

			else
				money[n] = -a;
		}

		vector<vector<long double> > dp(y + 1, vector<long double>(y * 100 + 1, 0.0));
		dp[0][0] = 1;

		for(int i = 0; i < y; ++i) {
			for(int j = 0; j <= y * 100; ++j) {
				for(int k = 0; k < x; ++k) {
					int pos = min(y, i + v[k]);
					int next = j;
					if(pos < y) {
						if(move[pos])
							pos = min(y, pos + move[pos]);
						else
							next = min(y * 100, max(0, next + money[pos]));
					}

					dp[pos][next] += dp[i][j] / x;
				}
			}
		}

		long double ans = 0.0;
		for(int i = 0; i <= y * 100; ++i)
			ans += i * dp[y][i];

		cout << floor(ans) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
using namespace std;
typedef long long ll;
  
  int main(void){
    cin.tie(0); //cin高速化
    ios::sync_with_stdio(false); //cin高速化
	
    int n,m,x;
    cin >> n>> m >> x;
    int a[n],f=0,b=0;
    rep(i,m){
      cin >> a[i];
      if(a[i]<x){
        f++;
      }else{
        b++;
      }
    }
    if(f<b){
      cout << f << endl;
    }else{
      cout << b << endl;
    }
    return 0;
  }    

Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B, C = get_ints
K = get_int

test = [A, B, C].sort
max_value = test.last

puts max_value * (2 ** K) + test[0..1].sum


Measured memory_bytes: 14412
(defun solve (n a b)
  (let ((ans 0)
        (pre 0))
    (dotimes (i n)
      (cond
        ((< (aref a i) (+ (aref b i) pre))
         (incf ans (aref a i))
         (setq pre (min (aref b i) (- (+ (aref b i) pre) (aref a i)))))
        (t
         (incf ans (+ (aref b i) pre))
         (setq pre 0))))
    (when (not (zerop pre))
      (incf ans (min (aref a n) pre)))
    ans))


(defun main ()
  (let* ((n (read))
         (a (make-array (1+ n) :initial-contents (read-from-string (concatenate 'string "(" (read-line) ")"))))
         (b (make-array n :initial-contents (read-from-string (concatenate 'string "(" (read-line) ")")))))
    (princ (solve n a b))
    (fresh-line)))

(main)


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

int main()
{
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            char c;
            cin >> c;
            if (i == j)
            {
                cout << c;
            }
        }
    }
    cout << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll n;cin>>n;
  map<string,ll>mp;
  string s[n];
  ll ma=0;
  rep(i,0,n){
    cin>>s[i];
    mp[s[i]]++;
    chmax(ma,mp[s[i]]);
  }

  set<string>se;
  rep(i,0,n){
    if(mp[s[i]]==ma)se.insert(s[i]);
  }

  // ll size=0;
  // rep(i,0,n){
  //   chmax(size,(ll)s[i].size());
  // }
  // rep(i,0,n){
  //   if(s[i].size()==size)se.insert(s[i]);
  // }

  for(auto v:se)out(v);

  return 0;
}


Measured memory_bytes: 36096
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const ll INFL = (1LL << 62);
const ll MOD = 1000000007;
template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
ll mod_pow(ll a, ll n, T mod) {
    mod = (ll)mod;
    ll res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}
void print() { std::cout << std::endl; }
template <typename T, typename... A>
void print(const T& first, const A&... rest) {
    cout << sizeof...(rest) << endl;
    std::cout << first;
    if (sizeof...(rest)) std::cout << " ";
    print(rest...);
}
template <typename... A>
void print(const A&... rest) {
    print(rest...);
}
template <typename A>
void print(const std::vector<A>& v) {
    std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    set<int> cards;
    unordered_map<int, int> nums;
    rep(i, N) {
        int a;
        cin >> a;
        cards.insert(a);
        nums[a]++;
    }
    int cnt_even = 0;
    for (auto& c : cards) {
        if (!(nums[c] & 1)) cnt_even++;
    }
    if (!(cnt_even & 1))
        cout << cards.size() << endl;
    else
        cout << (int)cards.size() - 1 << endl;

    return 0;
}

Measured memory_bytes: 9124
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    long[] memo = new long[N+1];
    memo[0] = 2;
    memo[1] = 1;
    for(int i = 2; i <= N; i++){
      memo[i] = memo[i-1] + memo[i-2];
    }
    System.out.println(memo[N]);
  }
}

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

using namespace std;

typedef long long ll;

const int mod = 1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b;
	cin >> a >> b;
	if(2*b<a) cout << a-2*b << "\n";
	else cout << 0 << "\n";
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        String s = stdin.nextLine();
        
        
        for (int i = 0; i < s.length(); i++) {
            // XXパターンを探す。
            if (i + 1 < s.length() && s.charAt(i) == s.charAt(i + 1)) {
                System.out.printf("%d %d%n", i + 1, i + 2);
                System.exit(0);
            }
            
            // XYXパターンを探す
            if (i + 2 < s.length() && s.charAt(i) == s.charAt(i + 2)) {
                System.out.printf("%d %d%n", i + 1, i + 3);
                System.exit(0);
            }
        }
        
        System.out.printf("%d %d%n", -1, -1);
    }
}


Measured memory_bytes: 25136
#include <stdio.h>

int main (){
  int x,y,w,h,r;

  scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
  if(((x-r)<0)||((y-r)<0)||((x+r)>w)||((y+r)>h)) printf("No\n");
  else  printf("Yes\n");

  return 0;
}

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

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

    int n; cin >> n;

    int a[n], b[n], c[n];
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    for (int i = 0; i < n; ++i) cin >> c[i];

    sort(a, a+n);
    sort(c, c+n);

    ll res = 0;
    for (int i = 0; i < n; ++i) {
        int * posA = lower_bound(a, a+n, b[i]);
        ll distA = distance(a, posA);
        int* posC = upper_bound(c, c+n, b[i]);
        ll distC = distance(posC, c+n);
        res += distA * distC;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1408
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder {

    public class Program {
        public static void Main (string[] args) {
            new Program ().Solve (new ConsoleInput (Console.In, ' '));
        }

        public void Solve (ConsoleInput cin) {
            //WriteLine ("入力");
            var H = cin.ReadLong;

            long oneUnitBranchCount = 3;

            long rightUnitCount = (long) Math.Floor (Math.Log ((double) H, 2));

            long branchCount = 1;

            for (int i = 1; i <= rightUnitCount; i++) {

                branchCount -= (long) (1 * Math.Pow ((double) 2, (double) i - 1));
                branchCount += oneUnitBranchCount * (long) (1 * Math.Pow ((double) 2, (double) i - 1));
            }

            Console.WriteLine (branchCount);
        }

    }

    public class ConsoleInput {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput (System.IO.TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string> ();
        }
        public string Read {
            get {
                if (inputStream.Count != 0) return inputStream.Dequeue ();
                string[] tmp = _stream.ReadLine ().Split (_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue (tmp[i]);
                return inputStream.Dequeue ();
            }
        }
        public string ReadLine { get { return _stream.ReadLine (); } }
        public int ReadInt { get { return int.Parse (Read); } }
        public long ReadLong { get { return long.Parse (Read); } }
        public double ReadDouble { get { return double.Parse (Read); } }
        public string[] ReadStrArray (long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray (long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray (long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11348
# frozen_string_literal: true

class Node
  attr_accessor :id, :parent, :left, :right, :depth, :height

  def initialize
    @id = nil
    @parent = -1
    @left = -1
    @right = -1
    @height = nil
    @depth = nil
  end
  
  def degree
    [left, right].reject { |child| child == -1 }.size
  end
end

def set_height(node, h, nodes)
  h1 = h2 = 0
  h1 = set_height(nodes[node.right], h, nodes) + 1 if node.right != -1
  h2 = set_height(nodes[node.left], h, nodes) + 1 if node.left != -1
  node.height = [h1, h2].max
end

def set_depth(node, p, nodes)
  node.depth = p
  set_depth(nodes[node.right], p + 1, nodes) if node.right != -1
  set_depth(nodes[node.left], p + 1, nodes) if node.left != -1
end

def children(node)
  [node.left, node.right]
end

def get_sibling(node, nodes)
  return -1 if node.parent == -1 ||
               nodes[node.parent].left == -1 ||
               nodes[node.parent].right == -1

  if nodes[node.parent].left == node.id
    nodes[node.parent].right
  else
    nodes[node.parent].left
  end
end

n = gets.to_i
array = readlines.map { |s| s.split.map(&:to_i) }

nodes = []
n.times do
  nodes << Node.new
end

array.each do |e|
  id = e[0]
  children = e.slice(1..-1)

  nodes[id].id = id
  nodes[id].left = children.shift
  nodes[id].right = children.shift
  children(nodes[id]).each do |child|
    next if child == -1

    nodes[child].parent = id
  end
end

root = nodes.find { |e| e.parent == -1 }

set_depth(root, 0, nodes)
set_height(root, 0, nodes)

nodes.each_with_index do |node, id|
  type = if node.parent == -1
           'root'
         elsif (node.left != -1) || (node.right != -1)
           'internal node'
         else
           'leaf'
  end

  puts "node #{id}: parent = #{node.parent}, sibling = #{get_sibling(node, nodes)}, degree = #{node.degree}, depth = #{node.depth}, height = #{node.height}, #{type}"
end



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

const ll MOD = 1000000007;

int main(){
    int N; cin >> N;
    vector<ll> a(N);
    REP(i,N) cin >> a[i];
    vector<ll> v(60,0LL);
    REP(i,N){
        REP(j,60){
            if((a[i]>>j)&1) v[j]++;
        }
    }
    ll ans = 0;
    REP(j,60){
        ans += ((((1LL<<j)%MOD)*v[j]%MOD)*(N-v[j])%MOD);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }

ll A[100002];

int main(int argc, char* argv[])
{
	for (;;) {
		ll N;
		cin >> N;
		if (cin.fail()) break;

		ll total = 0;
		A[0] = 0;
		A[N + 1] = 0;
		for (int i = 1; i <= N; i++) {
			cin >> A[i];
			total += abs(A[i] - A[i - 1]);
		}
		total += abs(A[N]);

		for (int i = 0; i < N; i++) {
			printf("%lld\n", total - abs(A[i + 1] - A[i]) - abs(A[i + 2] - A[i + 1]) + abs(A[i + 2] - A[i]));
		}
	}

	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;

struct edge
{
    ll to;
    ll cost;
};
typedef pair<ll, ll> P;
vector<vector<edge>> G;
vector<ll> dijkstra(ll s, ll N)
{
    vector<ll> value(N, INF);
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));
    value[s] = 0;
    while (!que.empty())
    {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (value[v] < p.first)
        {
            continue;
        }
        rep(i, G[v].size())
        {
            edge e = G[v][i];
            if (value[e.to] > value[v] + e.cost)
            {
                value[e.to] = value[v] + e.cost;
                que.push(P(value[e.to], e.to));
            }
        }
    }

    return value;
}

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

    G = vector<vector<edge>>(N);

    rep(i, N - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        G[a - 1].push_back({b - 1, c});
        G[b - 1].push_back({a - 1, c});
    }

    int Q, K;
    cin >> Q >> K;

    vector<ll> d(N);

    d = dijkstra(K - 1, N);
    rep(i, Q) {
        int x, y;
        cin >> x >> y;
        cout << d[x - 1] + d[y - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 11888
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int> pii;
typedef long long ll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N, A, B;
int ary[1000010];
int ans[1000010];

// 0....0 -> 0...1 or 0...1 -> 0....0 の全列挙
void rec(int *seq, int len, int cnt, int back){
    if(cnt == 0) return;
    if(!back){
        for(int i = 0; i < len; i++)
            seq[i] *= 2;
        for(int i = 0; i < len; i++)
            seq[2 * len - 1 - i] = seq[i] + 1;
    }
    else{
        for(int i = 0; i < len; i++)
            seq[i + len] = seq[i] * 2;
        for(int i = 0; i < len; i++)
            seq[i] = seq[len - 1 - i + len] + 1;
    }
    rec(seq, len * 2, cnt - 1, back);
}

void calc_ans(int bitcnt, int upper, int &sz, int back){
    ary[0] = 0;
    rec(ary, 1, bitcnt, back);
    for(int i = 0; i < (1 << bitcnt); i++){
        ans[sz++] = upper | ary[i];
    }

}

int main(){

    cin >> N >> A >> B;
    const int X = A ^ B;
    if(__builtin_popcount(X) % 2){
        deque<int> ord; // 元の場所が値、インデックスが現在の場所
        int one_cnt = 0;
        for(int i = 0; i < N; i++){
            if((X >> i) & 1){
                ord.push_back(i);
                one_cnt++;
            }
            else{
                ord.push_front(i);
            }
        }
        
        int sz = 0;
        int pos = 0;
        int upper = 0;
        while(1){
            // あと1つうめる　
            if(N - pos == 1){
                ans[sz++] = upper | 0;
                ans[sz++] = upper | 1;
                break;
            }
            // あと1つうめる
            else if(N - pos == 2){
                ans[sz++] = upper | 0b00;
                ans[sz++] = upper | 0b01;
                ans[sz++] = upper | 0b11;
                ans[sz++] = upper | 0b10;
                break;
            }

            // 現在の一番上の桁を0に固定
            calc_ans(N - 1 - pos, upper, sz, 0);
            // 次に、現在の場所を1にして、その上で計算を行う
            upper |= (1 << (N - 1 - pos));
            pos++;

            if(pos == one_cnt){
                calc_ans(N - pos, upper, sz, 1);
                break;
            }
            else{
                calc_ans(N - 1 - pos, upper, sz, 1);
                // 次に、現在の場所を1にして、その上で計算を行う
                upper |= (1 << (N - 1 - pos));
                pos++;
            }
        }

        cout << "YES" << endl;
        // 最後に得られた数列を元に戻す
        for(int i = 0; i < sz; i++){
            int before = 0;
            int after = ans[i];
            for(int j = 0; j < N; j++){
                if((after >> j) & 1){
                    before |= (1 << ord[j]);
                }
                else{
                    before &= ~(1 << ord[j]);
                }
            }
            cout << (before ^ A) << " ";
        }
        cout << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 5632
n,w=map(int,input().split())
wv=[]
for i in range(n):
    wv.append(tuple(map(int,input().split())))
v=sum([i[1] for i in wv])

dp=[[float('inf')]*(v+1) for _ in range(n+1)]

for i in range(n+1):
    dp[i][0]=0

for i in range(1,n+1):
    wei,val=wv[i-1]
    for j in range(1,v+1):
        if 0<=j-val<=v:
            dp[i][j]=min(dp[i-1][j], dp[i-1][j-val]+wei)
        else:
            dp[i][j]=dp[i-1][j]

for i in range(v,-1,-1):
    if dp[-1][i]<=w:
        ans=i
        break
print(ans)

Measured memory_bytes: 376376
#include "bits/stdc++.h"
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;

// 定義
typedef long long           ll;
typedef pair<ll, ll>        P;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
const ll                    INF = 2e9;
const ll                    INF_LL = 1LL<<60;
const ll                    MOD = 1e9 + 7;
namespace {
	ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
	ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
	ll FloorN(ll x, ll n)     { return (x - x % n); }
	bool IsOdd(ll x)          { return ((x & 1) == 1); }
	bool IsEven(ll x)         { return ((x & 1) == 0); }
	template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
	template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
};


/* 約数の列挙 */
vector<ll> divisorExec(ll n)
{
	vector<ll> res;
	for (ll i = 1; i <= sqrt(n); i++){
		if ((n % i) == 0) {
			res.push_back(i);
			if ((i * i) != n) {
				res.push_back(n / i);
			}
		}
	}
	sort(res.begin(), res.end());
	return res;
}

// 処理
void Solve()
{
	ll N;
	cin >> N;
	ll ans = 0;
	vector<ll> div = divisorExec(N);
	for (auto one : div) {
		ll m = N / one;
		ll n = one - 1;
		if (m < n) ans += n;
	}

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    map<int,int> m;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        m[a]++;
    }
    vector<int> use;
    for(auto p:m){
        if(p.second>=4){
            use.push_back(p.first);
            use.push_back(p.first);
        }
        else if(p.second >=2){
            use.push_back(p.first);
        }
    }
    sort(use.begin(), use.end());
    reverse(use.begin(), use.end());
    if(use.size()<=1){
        cout << 0 << endl;
        return 0;
    }
    cout << (ll)use.at(0)*use.at(1) << endl;
}

Measured memory_bytes: 8244
import java.util.*;

public class Main{

    BitSet primes;
    private void primesOfEratosthenes(int n){
        primes = new BitSet(n+1);
        primes.flip(0,n+1);

        primes.set(0,false);
        primes.set(1,false);
        for(int i=4;i<primes.size();i+=2){
            primes.set(i,false);
        }

        int i=3;
        int rn = (int)Math.sqrt(n);
        while(true){
            for(int j=i;i*j<primes.size();j+=2){
                primes.set(i*j,false);
            }

            i = primes.nextSetBit(i+1);
            if(i>rn){
                break;
            }
        }
        for(int j=primes.length(); (j = primes.previousSetBit(j-1)) >= 0;){
            primes.set(j, primes.get((int)((j+1)/2)));
        }

    }

    private int solve(int l, int r){
        return primes.get(l,r+1).cardinality();
    }

    private void _main(String[] args){
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        int[] l = new int[q];
        int[] r = new int[q];

        for(int i=0;i<q;i++){
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }

        int max=0;
        for(int i=0;i<q;i++){
            max = Math.max(r[i], max);
        }
        primesOfEratosthenes(max);

        for(int i=0;i<q;i++){
            System.out.println(solve(l[i], r[i]));
        }

        sc.close();
    }

    public static void main(String[] args){
            (new Main())._main(args);
    }
}


Measured memory_bytes: 229620
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int a[100005]={0};
typedef pair<long long,long long> o;
int main()
{
	 int np,n;
	 cin>>np>>n;
	 map<long long,long long>m;
	 vector<long long>v[np+5];
	 vector<o>v1;
	
	 for(int i=0;i<n;i++)
	 { 
	 	int y,p;
	 	cin>>p>>y;
	o pp (p,y);
	 	v[p].push_back(y);
	 	v1.push_back(pp);
	 }
	 for(int i=1;i<=np;i++)
	 {
	 	 sort(v[i].begin(),v[i].end());
	 }
	  for(int i=1;i<=np;i++)
	 {
	    for(int j=0;j<v[i].size();j++)
	    {
	    	m[v[i][j]]=j+1;
		}
	 }
	for(int i=0;i<v1.size();i++)
	{  o ppp=v1[i];
		printf("%06lld%06lld\n",ppp.first,m[ppp.second]);
	}
	 
 } 

Measured memory_bytes: 14704
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int a,b,h;cin>>a>>b>>h;
  P((a+b)*h/2);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val K = sc.nextInt()

    var p0: Long = 0
    var ph: Long = 0
    for (i in 1..N) {
        when (i % K) {
            0 -> p0++
            K / 2 -> ph++
        }
    }
    if (K % 2 == 1) ph = 0
    println(p0 * p0 * p0 + ph * ph * ph)
}

Measured memory_bytes: 31516
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
long long a,b,c;
int main(){
	cin>>a>>b>>c;
	if(c<(a+b))
	{
		cout<<"No";
		return 0;
	}
	if(4*a*b<(c-a-b)*(c-a-b))
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
x,y,z,k = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
ab = []
for i in range(x):
  for j in range(y):
    tmp = a[i] + b[j]
    ab += [tmp]
ab.sort()
ab = ab[::-1][:k]
#print(ab)

ans = []
for i in range(len(ab)):
  for j in range(z):
    tmp = ab[i] + c[j]
    ans += [tmp]
ans.sort()
ans = ans[::-1][:k]
for i in ans:
  print(i)


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    ll k, a , b;
    cin >> k >> a >> b;
    ll x = ((a + k - 1) / k) * k;
    if(x >= a && x <= b) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
    return 0;
}


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

int N;
long long atcount = 0;

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        if((i + 1) % 3 == 0 || (i + 1) % 5 == 0){

        }
        else{
            atcount += i+1;
        }
    }
    cout << atcount << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int s = stdIn.nextInt();
		int w = stdIn.nextInt();

		if(w >= s) {
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}

		stdIn.close();
	}
}


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

using ll= long long;
const ll INF=1LL<<60;
const ll MOD=1e9+7;

int main(){
    string S; cin >> S;
    int res=0;
    for(int i=0; i<S.size(); i++){
        for(int j=0; j<S.size()-i; j++){
            bool ok=true;
            for(int k=i; k<S.size()-j; k++){
                switch(S[k]){
                    case 'A':
                    case 'C':
                    case 'G':
                    case 'T':
                        break;
                    default:
                        ok=false;
                }
            }
            if(ok) res=max(res, (int)S.size()-i-j);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  while(cin >>n){
    bool f = false;
    for(int i=1; i<=512; i*=2){
      if(n%2){
	if(f){cout <<" ";}
	cout <<i;
	f = true;
      }
      n/=2;
    }
    cout <<endl;
  }
  return 0;
}

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


int main(void) {
	char s[200001] = {0};
	scanf("%s", s);
	long long cnt = 0, dep = 0;
	
	for (int i = 0; i < strlen(s); i++) {
		switch (s[i]) {
			case 'B':
				dep++;
				break;
			case 'W':
				cnt+=dep;
				break;
		}
	}
	
	printf("%lld\n", cnt);
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
    #include <algorithm>
 
    using namespace std;
    int x[51], y[51];
 
    void BSort(int n)
    {
        int ok = 0;
        while (!ok) {
            ok = 1;
            for (int i = 1; i < n; ++i)
            if (x[i] > x[i + 1]) {
                swap(x[i], x[i + 1]);
                swap(y[i], y[i + 1]);
                ok = 0;
            }
        }
    }
 
    int min_3(int a, int b, int c, int d)
    {
        return min(min(min(a, b), c), d);
    }
 
    int max_3(int a, int b, int c, int d)
    {
        return max(max(max(a, b), c), d);
    }
 
    int ind_x(int border, int i, int j, int o, int l)
    {
        if (border == x[i])
            return i;
        if (border == x[j])
            return j;
        if (border == x[o])
            return o;
        if (border == x[l])
            return l;
        return 0;
    }
 
    int ind_y(int border, int i, int j, int o, int l)
    {
        if (border == y[i])
            return i;
        if (border == y[j])
            return j;
        if (border == y[o])
            return o;
        if (border == y[l])
            return l;
        return 0;
    }
 
    int main()
    {
        int n, k, first, cell_cnt[51][51] = {0};
        long long small_area, area;
 
        cin >> n >> k;
        for (int i = 1; i <= n; ++i)
            cin >> x[i] >> y[i];
        BSort(n);
 
        for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j) {
            for (int o = 1; o <= n; ++o)
                if (x[o] <= x[i] && y[o] <= y[j])
                    cell_cnt[i][j]++;
        }
 
        long long left_m, down_m, right_m, up_m;
        int left_i, down_i, right_i, up_i;
        first = 1;
        for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
        for (int o = 1; o <= n; ++o)
        for (int l = 1; l <= n; ++l) {
            left_m = min_3(x[i], x[j], x[o], x[l]);
            left_i = ind_x(left_m, i, j, o, l);
 
            down_m = min_3(y[i], y[j], y[o], y[l]);
            down_i = ind_y(down_m, i, j, o, l);
 
            right_m = max_3(x[i], x[j], x[o], x[l]);
            right_i = ind_x(right_m, i, j, o, l);
 
            up_m = max_3(y[i], y[j], y[o], y[l]);
            up_i = ind_y(up_m, i, j, o, l);
 
            if (cell_cnt[right_i][up_i] - cell_cnt[left_i - 1][up_i] - cell_cnt[right_i][down_i] + cell_cnt[left_i - 1][down_i] + 1 >= k) {
                area = (right_m - left_m) * (up_m - down_m);
                if (first) {
                    small_area = area;
                    first = 0;
                }
                else
                    small_area = min(small_area, area);
            }
        }
        cout << small_area;
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;

int main() {
  INIT;
  
  int a,b,c;
  cin >> a >> b >> c;
  std::set<int> s{a,b,c};
  cout <<  s.size() << endl;
  
  return 0;
}

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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;

    int plan1 = a * n;

    if (plan1 < b)
    {
        cout << plan1 << endl;
    }
    else
    {
        cout << b << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
count = 0
for i in range(1,101):
    flag = 1
    for j in range(n):
        if h[j] >= i:
            if flag:
                count += 1
                flag = 0
        else:
            flag = 1
print(count)

Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[100111];

int main() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);
    int o = 0;
    REP (i, N) if (A[i] & 1) o++;
    puts(o & 1? "NO": "YES");


    return 0;
}



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


def main():
    from math import ceil

    s = list(input())
    ans = [0 for _ in range(len(s))]

    # See:
    # https://www.youtube.com/watch?v=lyHk98daDJo
    for i in range(2):
        count = 0

        for index, si in enumerate(s):
            if si == 'R':
                count += 1
            else:
                ans[index] += count // 2
                ans[index - 1] += ceil(count / 2)
                count = 0

        s = s[::-1]
        ans = ans[::-1]

        for index, si in enumerate(s):
            if si == 'L':
                s[index] = 'R'
            else:
                s[index] = 'L'

    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 11648
// C - Sqrt Inequality
// https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_c
#include <iostream>
#include <bits/stdc++.h>
#include <map>
#include <queue>
#include <set>
#include <string> 
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, int> PLI;
typedef pair<int, int> PII;
const ll mxsize = 2e5 + 5;
const ll linf = 1e9;
const long double inf = 10000000000.0;
#define fastIO                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
const ll mod = 1e9 + 9;
#define clr(x) memset(x , 0 , sizeof(x));
 
/******************************************** CODE STARTS FROM HERE *************************************************/ 

int main()
{
    fastIO;
    ll a , b , c;
    cin >> a >> b >> c;
    ll val = 4 * a * b;
    ll val1 = (c - a - b) * (c - a - b);
    //cout << val << " " << val1 << endl;
    if((c - a - b) > 0 && val1 > val)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

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

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll x, a;
  cin >> x >> a; 
  if(x < a) cout << "0";
  else cout << "10";
  return 0;
} //good night.

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

int main()
{
	int n, x; cin >> n >> x;
	
	vector<int> l(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> l[i];
	}

	vector<int> d(n + 2);
	d[1] = 0;
	int ans = 1;
	for (int i = 2; i <= n + 1; i++) {
		d[i] = d[i - 1] + l[i - 1];
		if (d[i] <= x) ans++;
		else break;
	}

	cout << ans << endl;
	return 0;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x1, x2, x3, x4, x5, x6, x7, x8, x9;
	int a1, a2, a3;
	int b1, b2, b3;
	cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6 >> x7 >> x8 >> x9;
	for (int i = 0; i < 100; i++) {
		b1 = i;
		a1 = x1 - b1;
		a2 = x4 - b1;
		a3 = x7 - b1;
		b2 = x2 - x1 + b1;
		b3 = x3 - x1 + b1;
		if ( a1 + b1 == x1 && a1 + b2 == x2 && a1 + b3 == x3
			&& a2 + b1 == x4  && a2 + b2 == x5 && a2 + b3 == x6
			&& a3 + b1 == x7  && a3 + b2 == x8 && a3 + b3 == x9) {
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256