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

using namespace std;

// Union-Find木
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号
    vector<long long> siz; // siz[i]:iが属する木の大きさ

    UnionFind(int N) : par(N), siz(N, 1) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {
            par[i] = i;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る
        if (par[x] == x) {
            return x;
        }

        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) {
            return; //xとyの根が同じ(=同じ木にある)時はそのまま
        }

        siz[ry] += siz[rx];
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    long long size(int x) {
        return siz[root(x)];
    }
};

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

    vector<long long> A(M), B(M);
    vector<long long> answer(M);

    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
    }

    UnionFind U(N);

    answer[M-1] = N*(N-1) / 2;

    for (int i = M-1; i >= 1; i--) {
        if (U.same(A[i], B[i]) == true) {
            answer[i-1] = answer[i];
        } else {
            answer[i-1] = answer[i] - U.size(A[i]) * U.size(B[i]);
            U.unite(A[i], B[i]);
        }
    }

    for (auto i : answer) {
        cout << i << endl;
    }

	return 0;
}

Measured memory_bytes: 6764
#include <iostream>
using namespace std;
int main() {
	int x, y, z, m, n;
	cin >> x;
	y = x / 3600;
	z = x % 3600;
	m = z / 60;
	n = z % 60;
	cout << y << ":" << m << ":" << n <<endl;
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define int long long
using namespace std;
int dp[1000][1000];
void add(deque<int> &d, int value){
    while (d.size() && value > d.back()){
        d.pop_back();
    }
    d.push_back(value);
}
void dlt(deque<int> &d, int value){
    if (d.front() == value) d.pop_front();
}
bool checker(int num, int others, int k){
    bool row[k], zap[k];
    for (int i=0; i < k; i++) row[i] = false;
    for (int i=0; i < k; i++) for (int j=0; j < k; j++) if (dp[i][j] > (num-1)*num) row[i] = true;
    vector<deque<int> > v(k);
    for (int i=0; i < k; i++) for (int j=0; j < others; j++){
        add(v[i], dp[i][j]);
    }
    //exit(0);
    int now = 0;
    for (int i=0; i < k;i++){
        //cout << i << " ";
        for (int j=0; j < k; j++) zap[j] = row[j];
        int mmx = 0;
        for (int j=0; j < k; j++) if (v[j].front() > (num-1)*(num-1)) zap[j] = true;
        for (int j=0; j < k; j++) mmx = max(mmx, v[j].front());
        bool abl = (mmx <= num*(num-1));
        int tet = 0;
        int sum = 0;
        for (int p=0;p<others;p++) sum+=zap[p];
        for (int p=0;p<k;p++){
            if (sum==0 && abl) return true;
            sum -= zap[tet%k];
            sum += zap[(tet+others)%k];
            tet++;
        }
        for (int j=0;j<k;j++){
            dlt(v[j], dp[j][now%k]);
            add(v[j], dp[j][(now+others)%k]);
        }
        now++;
    }
    return false;
}
signed main(){
    int n, k;
    cin >> n >> k;
    for (int i=0; i < n; i++){
        int x, y;
        cin >> x >> y;
        dp[x%k][y%k]++;
    }
    int mx = 0;
    for (int i=0;i<k;i++) for (int j=0;j<k;j++) mx = max(mx, dp[i][j]);
    int num = 1;
    while (num*num < mx) num++;
    int L = 0, R = k;
    while (R-L>1){
        int M = (L+R)/2;
        if (checker(num, M, k)) L = M;
        else R = M;
        //return 0;
    }
    cout << num*k-L-1 << endl;

}


Measured memory_bytes: 10888
W, H, N = map(int, input().split())
xyan = [map(int, input().split()) for _ in range(N)]

# 格子点の中間点 (n.5, m.5) について考える
ws = [False] * W
hs = [False] * H

for x, y, a in xyan:
    if a == 1:
        for i in range(0, x):
            ws[i] = True
    elif a == 2:
        for i in range(x, W):
            ws[i] = True
    elif a == 3:
        for i in range(0, y):
            hs[i] = True
    elif a == 4:
        for i in range(y, H):
            hs[i] = True

print(len([w for w in ws if not w]) * len([h for h in hs if not h]))


Measured memory_bytes: 3064
package main
 
import "fmt"
 
func main() {
	n := 37
	fmt.Printf("%d %d\n", n*n+n+1, n+1)
	a := make([][]int, n*n+n+1)
	for i := 0; i <= n; i++ {
		a[0] = append(a[0], i)
		for j := 0; j < n; j++ {
			a[i*n+1+j] = append(a[j+1+i*n], i)
		}
	}
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			color := i * n + j + n + 1
			for k := 0; k < n; k++ {
				index := 1 + k * n + (j + i * k) % n
				a[index] = append(a[index], color)
			}
			a[n*n+1+i] = append(a[n*n+1+i], color)
		}
	}
	for i := 0; i <= n*n+n; i++ {
		for j := 0; j <= n; j++ {
			fmt.Printf("%d", a[i][j] + 1)
			if j < n {
				fmt.Printf(" ")
			} else{
				fmt.Printf("\n")
			}
		}
	}
}



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

bool isTriangle(int a, int b, int c) {
    if((a + b) <= c) {
        return false;
    }
    if((b + c) <= a) {
        return false;
    }
    if((a + c) <= b) {
        return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    vector<int> L(n+1);

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

    int ret = 0;
    for(int i = 1; i <= (n - 2); i++) {
        for(int j = i+1; j <= (n - 1); j++) {
            for(int k = j+1; k <= n; k++) { 
                //cout << L[i] << L[j] << L[k] << endl;
                if(L[i] == L[j]) {
                    continue;
                }
                if(L[i] == L[k]) {
                    continue;
                }
                if(L[j] == L[k]) {
                    continue;
                }
                if(isTriangle(L[i], L[j], L[k])) {
                    ret++;
                }
            }
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static string Solve(string ABCD)
        {
            var v = Enumerable.Range(0, 4).Select(i => ABCD[i] - '0').ToArray();
            for (int i = 0; i < 8; ++i)
            {
                int sum = v[0];
                var sb = new StringBuilder(ABCD.Substring(0, 1));
                for (int j = 1; j < 4; ++j)
                {
                    if ((i & (1 << (j - 1))) != 0)
                    {
                        sum -= v[j];
                        sb.Append('-');
                    }
                    else
                    {
                        sum += v[j];
                        sb.Append('+');
                    }
                    sb.Append(ABCD[j]);
                }
                sb.Append("=7");
                if (sum == 7) { return sb.ToString(); }
            }
            return "";
        }
        static void Main(string[] args)
        {
            Console.WriteLine(Solve(Read()));
        }
    }
}


Measured memory_bytes: 13396
#include <stdio.h>

int main(){
  int N,i,c=0;
  scanf("%d",&N);
  int a[N];
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
     if(a[i]%2==0){
       if(a[i]%3==0||a[i]%5==0){
       }
       else
         c++;
     }
  }  
   if(c==0)
    printf("APPROVED");
  else
    printf("DENIED");
}

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

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

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    int n, m, x;
    cin >> n >> m>> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n){
        cin >> c[i];
        rep(j, m){
            cin >> a[i][j];
        }
    }

    int ans = INF;
    rep(bit, (1 << n)){
        vector<int> b(m);
        rep(i, n){
            if(bit & (1 << i)){
                rep(j, m){
                    b[j] += a[i][j];
                }
            }
        }

        bool ok = true;
        int sum = 0;
        rep(i, m){
            if(b[i] < x){
                ok = false;
            }
        }

        if(ok){
            rep(i, n){
                if(bit & (1 << i)){
                    sum += c[i];
                }
            }
            ans = min(ans, sum);
        }
    }

    if(ans == INF){
        cout << -1 << "\n";
    }else{
    cout << ans << "\n";

    }

    return 0;
}


Measured memory_bytes: 3656
import numpy as np


##get int
first_input = list(map(lambda x:int(x), input().split(" ")))
#second_input = list(map(lambda x:int(x), input().split(" ")))

##get float
#first_input = list(map(lambda x:float(x), input().split(" ")))
#second_input = list(map(lambda x:float(x), input().split(" ")))

##get string
#first_input = input().split(" ")

N = first_input[0]
M = first_input[1]

num_list = [0]*N+[1]*M

gusu_count = 0
for i in range(len(num_list)):
    for j in range(i+1,len(num_list)):
        if num_list[i]==num_list[j]:
            gusu_count = gusu_count+1

print(gusu_count)


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


int N, X, t;
unsigned p[101] = { 0 };

int main(){
	scanf("%d", &N);
	for (int i = 0; i < 3; i++) {
		scanf("%d", &X);
		for (int j = 0; j < X; j++) {
			scanf("%d", &t);
			p[t] |= (1 << i);
		}
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if ((!(p[i] & 1) && (p[i] & 4) || (p[i] & 2 && p[i] &4))) {
			ans++;
		}
	}
	printf("%d\n", ans);


	return 0;
}

Measured memory_bytes: 2720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

ll mod = 1000000007;
ll mypow(ll a, ll b)
{
    if (b == 0)
    {
        return 1;
    }
    else if (b == 1)
    {
        return a;
    }
    else
    {
        return a * mypow(a, b - 1);
    }
}
signed main()
{
    int n, m;
    cin >> n >> m;
    priority_queue<pair<double, pair<int, int>>> pq;
    rep(i, n)
    {
        int a;
        cin >> a;
        pq.push({a, {a, 0}});
    }
    rep(i, m)
    {
        auto a = pq.top();
        pq.pop();
        pq.push({a.first / 2, {a.second.first, a.second.second + 1}});
    }
    ll ans = 0;
    while (!pq.empty())
    {
        auto a = pq.top();
        pq.pop();
        ll rate = 1;
        rep(i, a.second.second)
        {
            rate *=2;
            if(rate>a.second.first){
                break;
            }
        }
        ans += a.second.first / rate;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5300
#include <stdio.h>

int main(void){

   int i,N;
   double rs=0;
  scanf("%d",&N);
   int a[N];
  
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
    rs=rs+(double)1/a[i];
  }
    printf("%f",1/rs);
 
}

Measured memory_bytes: 128
import Data.List

main = do
  c <- getContents >>= return . map (map read . words) . lines :: IO [[Int]]

  putStrLn $ if all (\x -> and (func (==) $ map (func (\a b -> b - a)) x)) [c, transpose c]
    then "Yes"
    else "No"

  where
    func f (a:b:[]) = [f a b]
    func f (a:b:xs) = (f a b) : func f (b:xs)


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

int main()
{
    int b, f, r, v;
    int n;
    int data[4][3][10] = {};
    cin >> n;
    while (cin >> b >> f >> r >> v)
    {
        data[b - 1][f - 1][r - 1] += v;
    }
    for (int i = 0; i < 4; i++)
    {
        for (int floor = 0; floor < 3; ++floor)
        {
            for (int room = 0; room < 10; ++room)
            {
                cout << " " << data[i][floor][room];
            }
            cout << "\n";
        }
        if (i != 3)
        {
            cout << "####################\n";
        }
    }
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 300005;
const int mod = 1000000007;

int n;
ll a[maxn];
int c[60];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  cin>>n;
  ll ret = 0;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=n-1;i>=0;i--){
    for(int j=0;j<60;j++){
      if(a[i]&(1LL<<j)){
        int cc = (n-1-i)-c[j];
        ret=(ret+(1LL<<j)%mod*cc)%mod;
        c[j]++;
      } else {
        int cc = c[j];
        ret=(ret+(1LL<<j)%mod*cc)%mod;
      }
    }
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 2560
k=int(input())
l=[i for i in range(1,10)]
for i in range(k):
    r=l.pop(0)
    rr=r%10
    if rr!=0:
        l.append(10*r+rr-1)
    l.append(10*r+rr)
    if rr!=9:
        l.append(10*r+rr+1)
print(r)

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

int main(){
		int n,m;
		cin >> n >> m;
		int count=0, current = 1;
		
		while (true){
			if (current >= m){
				cout << count << endl;
				break;
			}
			else {
				current += n-1;
				count++;
			}
		}
        return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> d(n + 1);
  for (int i = 0; i < m; i ++) {
    int l, r;
    cin >> l >> r;
    l --, r --;
    d[l] ++, d[r + 1] --;
  }
  for (int i = 0; i <= n; i ++) {
    d[i + 1] += d[i];
  }

  int ans = 0;
  for (int i = 0; i < n; i ++) {
    if (d[i] == m) ans ++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;

ll dp[45][405][405];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,ma,mb;
    cin>>n>>ma>>mb;
    V<ll> a(n),b(n),c(n);
    rep(i,n) cin>>a[i]>>b[i]>>c[i];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=400;j++){
            for(int k=0;k<=400;k++){
                dp[i][j][k]=INF;
            }
        }
    }
    dp[0][0][0]=0;
    rep(i,n){
        for(int j=0;j<=400;j++){
            for(int k=0;k<=400;k++){
                chmin(dp[i+1][j][k],dp[i][j][k]);
                if(j-a[i]>=0&&k-b[i]>=0){
                    chmin(dp[i+1][j][k],dp[i][j-a[i]][k-b[i]]+c[i]);
                }
            }
        }
    }
    ll ans=INF;
    for(ll i=1;i*ma<=400&&i*mb<=400;i++) chmin(ans,dp[n][i*ma][i*mb]);
    if(ans==INF) ans=-1;
    out(ans);
}

Measured memory_bytes: 55764
#include<stdio.h>
#define WHITE 1
#define GRAY 2
#define BLACK 3

int array[500][500],d[100],f[100],color[100];
int n,time_;

void dfs(void);
void visit(int);
void print(void);

int main(){
    int u,v,i,j,jisu;

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

    for(i=0;i<n;i++){
        scanf("%d%d",&u,&jisu);
        u = u - 1;
        for(j=0;j<jisu;j++){
            scanf("%d",&v);
            v = v - 1;
            array[u][v] = 1;
        }
    }

    dfs();

    return 0;
}
void dfs(){
    int u;

    for(u=0;u<n;u++){
        color[u] = WHITE;
    }
    time_ = 0;

    for(u=0;u<n;u++){
        if(color[u] == WHITE){
            visit(u);
        }
    }
    print();
}
void visit(int u){
    int v;

    color[u] = GRAY;
    d[u] = ++time_;
    for(v=0;v<n;v++){
        if(array[u][v] == 0){
            continue;
        }
        if(color[v] == WHITE){
            visit(v);
        }
    }
    color[u] = BLACK;
    f[u] = ++time_;
}
void print(){
    int i;

    for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
    }
}


Measured memory_bytes: 2052
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int number = int.Parse(Console.ReadLine());
            int[] inputAs = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int[] inputBs = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int[] inputCs = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            // 先に C のうちポイントになるものを抽出
            int bonus = 0;
            for (int i = 0; i < number - 1; i++)
            {
                // 連続した番号のメニューを食べていた場合、
                if(inputAs[i + 1] - inputAs[i] == 1)
                {
                    // A は 1 ～ n の値で表現されるので、 C の index とは１ずれる。
                    bonus += inputCs[inputAs[i] - 1];
                }
            }

            // 後は料理単体の満足度だけど、こいつ常に全メニュー食ってるな
            int satisfaction = inputBs.Sum();

            Console.WriteLine((bonus + satisfaction).ToString());
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}


signed main(){
  int n,k,h[110000];cin>>n>>k;rep(i,n)cin>>h[i];
  int dp[110000];rep(i,110000)dp[i] = INF;
  dp[0] = 0;
  repd(i,1,n){
    repd(j,1,k+1){
      if(i-j < 0)break;
      dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  cout << dp[n-1] << endl;
}


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

int main(){
	int n;
	cin>>n;
	
	string s[100000];
	long long m=0,a=0,r=0,c=0,h=0;
	for(int i=0;i<n;i++){
		cin>>s[i];
		
		if(s[i][0]=='M') m++;
		if(s[i][0]=='A') a++;
		if(s[i][0]=='R') r++;
		if(s[i][0]=='C') c++;
		if(s[i][0]=='H') h++;
	}
	
	cout<<m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h<<endl;
	
	return 0;
}

Measured memory_bytes: 6144
/*	Success may not come to me immediately,
 *	but it will come definitely....
 */
#include<bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li	int64_t
#define ld	double_t
#define ulli	uint64_t
//=====================================================================
#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define repi(i,v)	for(i=v.begin();i!=v.end();i++)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))
#define nl		cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>	 vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb	push_back
#define pob	pop_back
#define pf	push_front
#define pof	pop_front
#define all(v)	v.begin(),v.end()
#define itr	iterator
#define sz	size()
#define lb	lower_bound
#define ub	upper_bound
#define bs	binary_search
#define mp	make_pair
#define F	first
#define S	second
//=====================================================================
#define mod	1000000007
#define inf	1000000000000000005
#define MX1	100005
#define MX2	1000005
#define pi	acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return 1<<n;}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

li n,a,b,arr[MX1];

bool chk(li mid){
	li i,ex=0;
	rep(i,0,n){
		if(arr[i]>=b*mid){
			ex+=(arr[i]-b*mid)/(a-b);
			if((arr[i]-b*mid)%(a-b)!=0) ex++;
		}
	}
	return ex<=mid;
}

void solve(){
	li i;cin>>n>>a>>b;
	rep(i,0,n) cin>>arr[i];
	li lo=0,hi=mod,mid,ans=0;
	while(lo<=hi){
		mid=lo+hi>>1;
		if(chk(mid)){
			ans=mid;
			hi=mid-1;
		}else lo=mid+1;
	}
	cout<<ans;
}

int main(){
    opt
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    li t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1024
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int
#define ld long double

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10
#define PI acos(-1LL)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	int n;
	cin>>n;

	string s;
	cin>>s;

	if(n&1)
	{
		cout<<"No"<<endl;
	}
	else
	{
		string t=s.substr(0,n/2);
		string u=s.substr(n/2,n/2);

		if(t==u)
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		}
	}

}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
  double a,b;
  int aa,bb;
  cin >> a >> b;
  aa = a;
  bb = b;
  cout << aa / bb << ' ' << aa % bb << ' ' << fixed << setprecision(5) << a/b << endl;
  return 0;
}

Measured memory_bytes: 1288
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int n,i,j,k,m;(n=s.nextInt())>0;System.out.println(m)){int[][]a=new int[n][n];for(i=0;i<n;++i){String x=s.next();for(j=0;j<n;++j)a[i][j]=x.charAt(j)-48;}for(i=m=0;i<n;++i){for(j=0;j<n;++j){int[]c=new int[4];for(k=0;k<n;++k){if(i+k<n&&a[i+k][j]>0&&c[0]==k)c[0]++;if(j+k<n&&a[i][j + k]>0&&c[1]==k)c[1]++;if(i+k<n&&j+k<n&&a[i+k][j+k]>0&&c[2]==k)c[2]++;if(i+k<n&&j-k>=0&&a[i+k][j-k]>0&&c[3]==k)c[3]++;}for(int b:c)m=m<b?b:m;}}}}}

Measured memory_bytes: 13000
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#include <queue>

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int maxi=0;
	rep(w,1,n){ //単語同士の文字の幅
		int c=0,a=0;
		for(int i=0,j=w;j<n;i++,j++){
			if(s[i] == s[j]) a = max(a,++c);
			else c=0;
			maxi = max(maxi,min(a,w));
			}
		}
	cout << maxi << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000005
#define MOD (ll)(1e9+7)
using namespace std;

void solve()	{
    int n;
    cin >> n;
    int a[n],s=0;
    for(int i=0; i<n; i++)  {
        cin >> a[i];
        s+=a[i];
    }
    if(s%10)    cout << s << endl;
    else {
        sort(a,a+n);
        for(int i=0; i<n; i++)  {
            if(a[i]%10) {
                cout << s-a[i] << endl;
                return;
            }
        }
        cout << 0 << endl;
    }

}

int main()	
{
	int t=1;
	//cin >> t;
	for(int i=1; i<=t; i++)	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;


int main() {
    int n = 0;
    cin >> n;
    string s = "";
    cin >> s;
    int cnt = 1;
    for (int i=1; i<n; i++) {
        if (s.at(i) != s.at(i-1)) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
long long N;
void dfs(long long x,int bits, long long &cnt){
    if(x>N) return;
    if(bits==0b111) cnt++;
    dfs(x*10+3,bits|0b001,cnt);
    dfs(x*10+5,bits|0b010,cnt);
    dfs(x*10+7,bits|0b100,cnt);
}
int main(void){
    long long ans=0;
    cin >> N;
    dfs(0,0,ans);
    cout <<  ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define forn(i,n) for(int i = 0; i < (int) n; i++)
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

int main() {
   int a,b;
   cin >> a >> b;
   cout << a * b << "\n";
}


Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());

        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            a.add(Integer.parseInt(sc.next()));
        }

        for (int i = a.size() - 1; i >= 0; i--) {
            if (i == 0) {
                System.out.printf("%d\n", a.get(i));
            } else {
                System.out.printf("%d ", a.get(i));
            }
        }
    }
}

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

#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

// const int N = ;

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	long long a[3 * n], dp1[3 * n], dp2[3 * n];
	long long ans = -1e18;

	for(int i = 1; i <= 3 * n; i++)
		cin >> a[i];

	multiset<int> s;
	long long sum = 0;

	for(int i = 1; i <= 3 * n; i++) {
		s.insert(a[i]);
		sum += a[i];
		if(s.size() > n) {
			sum -= *s.begin();
			s.erase(s.begin());
		}
		dp1[i] = sum;
	}

	s.clear();
	sum = 0;
	for(int i = 3 * n; i > 0; i--) {
		s.insert(a[i]);
		sum += a[i];
		if(s.size() > n) {
			sum -= *s.rbegin();
			s.erase(prev(s.end()));
		}
		dp2[i] = sum;
	}
// dbg_v(dp1, 3 * n + 1);
// dbg_v(dp2, 3 * n + 1);

	for(int i = n; i <= 2 * n; i++)
		ans = max(ans, dp1[i] - dp2[i + 1]);
	cout << ans << '\n';
}	


Measured memory_bytes: 12032
n, k = gets.split.map(&:to_i)
hs = []
n.times do
  hs << gets.to_i
end

hs.sort!
ans = Float::INFINITY
n.times do |i|
  break if hs[i+k-1].nil?
  ans = [ans, (hs[i] - hs[i+k-1]).abs].min
end

puts ans


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
	int64 T, D, L;
	while (cin >> T >> D >> L && T+D+L) {
		vector<int64> x(T);
		REP(i, T) cin >> x[i];
		int64 res = 0;
		int64 last = -INF;
		REP(i, T) {  
			if (i - last <= D) res++;
			if (x[i] >= L) last = i;
		}
		cout << res << endl;
	}
}



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

int main() {
   string str;
   cin >> str ;
if (str == "a" || str == "i"||
str =="u" || str == "e"|| str=="o")
cout << "vowel"<< endl;
else { 
cout << "consonant"<<endl;
}


} 

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  int64_t ans=0;
  string s;
  cin >> n;
  cin >> s;
  vector<int> r(n), g(n), b(n);
  for(int i=0; i<n; i++){
    if(i==0){
      r[i]=0;
      g[i]=0;
      b[i]=0;
    }
    else{
      r[i]=r[i-1];
      g[i]=g[i-1];
      b[i]=b[i-1];
    }
    if(s[i]=='R')
      r[i]++;
    else if(s[i]=='G')
      g[i]++;
    else
      b[i]++;
  }
  for(int i=0; i<n-2; i++)
    for(int j=i+1; j<n-1; j++){
	if(s[i]==s[j])
	  continue;
	if(s[i]!='R' and s[j]!='R'){
	  ans += r[n-1]-r[j];
	  if(2*j-i<n and s[2*j-i]=='R')
	    ans--;
	}
	if(s[i]!='G' and s[j]!='G'){
	  ans += g[n-1]-g[j];
	  if(2*j-i<n and s[2*j-i]=='G')
	    ans--;
	}
	if(s[i]!='B' and s[j]!='B'){
	  ans += b[n-1]-b[j];
	  if(2*j-i<n and s[2*j-i]=='B')
	    ans--;
	}
      }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3688
n = int(input())
d = list(map(int,input().split()))
 
from collections import Counter
q=Counter(d)

# 例外対応
if q[0]!=1 or d[0]!=0:
  print(0)
  exit()

ans = 1
for i in range(1,max(d)+1):
  ans *= q[i-1]**q[i]
  if ans == 0:
    break
print(ans%998244353)

Measured memory_bytes: 19808
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.14159265;
const ll MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE;

int arr[MAXN];
int deg[MAXN];
int parent[MAXN];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b, k;
    cin >> a >> b >> k;
    ll d = min(k, a);
    k -= d;
    a -= d;
    if (!k) {
        cout << a << " " << b << endl;
        return 0;
    }
    d = min(k, b);
    k -= d;
    b -= d;
    cout << a << " " << b << endl;
    return 0;
}

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

void solve() 
{
    int a,b;cin>>a>>b;
    if(a<=5)cout<<0<<endl;
    else if(a<13)cout<<b/2<<endl;
    else cout<<b<<endl;
}

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

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

typedef long long ll;
typedef unsigned long long ull;
#define endl "\n";
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define POSITIVE_INFINITY 9223372036854775807
#define NEGATIVE_INFINITY -9223372036854775807
#define MOD 1000000007

int main()
{
  FASTER;
  int n, h, w;
  cin >> n >> h >> w;
  int x = max(0, n - h + 1);
  int y = max(0, n - w + 1);
  cout << x * y << endl;
  return 0;
}


Measured memory_bytes: 256
import operator

n=int(input().strip())
lst=input().split(' ')
map(int, lst)

d1 = {}
d2 = {}

for i in range(len(lst)):
    if i % 2 == 0:
        if lst[i] in d1:
            d1[lst[i]] += 1
        else:
            d1[lst[i]] = 1
    else:
        if lst[i] in d2:
            d2[lst[i]] += 1
        else:
            d2[lst[i]] = 1

sd1 = sorted(d1.values(), reverse=True)
sd2 = sorted(d2.values(), reverse=True)
key1 = max(d1.items(), key=operator.itemgetter(1))[0]
key2 = max(d2.items(), key=operator.itemgetter(1))[0]

if(key1 == key2):

    v11 = sd1[0]
    if(len(d1) == 1):
        v12 = 0
    else:
        v12 = sd1[1]

    v21 = sd2[0]
    if(len(d2) == 1):
        v22 = 0
    else:
        v22 = sd2[1]

    print(min(n-v11-v22, n-v12-v21))

else:
    print(n-sd1[0]-sd2[0])

Measured memory_bytes: 18280
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        char[] ch = sc.next().toCharArray();
        final int N = ch.length;
        char[] ar = new char[N];
        char[] br = new char[N];
        int a = 0;
        int b = 0;
        for (int i = 0; i < N; i++) {
            ar[i] = i % 2 == 0 ? '0' : '1'; 
            br[i] = i % 2 == 0 ? '1' : '0';
        }
        
        for (int i = 0; i < N; i++) {
            if (ch[i] != ar[i]) {
                a++;
            } else {
                b++;
            }
        }
        
        out.println(Math.min(a, b));
        
        out.flush();
    }
}

Measured memory_bytes: 27604
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

vec dx = {0, -1, 0, 1};
vec dy = {1, 0, -1, 0};

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

    ll H, W, K;
    cin >> H >> W >> K;
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    vector<string> c(H);
    Rep (i, H) {
        cin >> c[i];
    }

    x1--; x2--; y1--; y2--;
    mat dist(H, vec(W, inf));
    dist[x1][y1] = 0;

    queue<pair<ll, ll>> q;
    q.push({x1, y1});
    while (q.size()) {
        auto v = q.front();
        q.pop();
        ll x = v.first;
        ll y = v.second;
        Rep (i, 4) {
            for (ll j = 1; j <= K; j++) {
                ll ny = y + dy[i] * j;
                ll nx = x + dx[i] * j;
                if (0 <= nx and nx < H and 0 <= ny and ny < W) {
                    if (c[nx][ny] == '@') break;
                    if (dist[nx][ny] <= dist[x][y]) break;
                    if (dist[nx][ny] > dist[x][y] + 1) {
                        dist[nx][ny] = dist[x][y] + 1;
                        q.push({nx, ny});
                    }
                }

            }
                
        }
    }

    // Rep (i, H) {
    //     Rep (j, W) {
    //         if (dist[i][j] == inf) cout << "_" << " \n"[j==W-1];
    //         else cout << dist[i][j] << " \n"[j==W-1];
    //     }
    // }

    ll ans = dist[x2][y2];
    if (ans == inf) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 19816
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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 main() {
  int a, b;
  cin >> a >> b;

  int seq = b;
  if (b == 100) {
    seq += a * 1000;
  } else if (b >= 10) {
    seq += a * 100;
  } else {
    seq += a * 10;
  }

  for (int i = (int)sqrt(seq) - 2; i <= (int)sqrt(seq) + 2; i++) {
    if (i * i == seq) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  
int main(){
	
  int a, b;
  cin >> a >> b;
  
  int p = a * b;
  if (p % 2== 0)
  	cout << "Even" << endl;
  else 
  	cout << "Odd" << endl;
  


}  


Measured memory_bytes: 256
import sys
def prime(m):
    N=range(1,m+2,2)
    r=int(m**.5)
    h=len(N)
    N[0]=0
    for i in range(h):
        x=N[i]
        if x>r: break
        if x and i+x<h: N[i+x:h:x]=[0] * ((h-1-i-x)/x+1)
    N[0]=2
    return filter(None,N)
PRIMES=prime(105000)
for n in sys.stdin:
    n=int(n)
    if n==0: break
    print sum(PRIMES[:n])

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

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

void solve() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	if (a+b > c+d) cout << "Left";
	else if (a+b < c+d) cout << "Right";
	else cout << "Balanced";
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  ll N, M; cin >> N >> M;
  vector<ll> H(N); REP(i, N) cin >> H[i];
  vector<ll> A(M), B(M); REP(i, M) cin >> A[i] >> B[i];

  vector<ll> vec(N + 1); REP(i, N + 1) vec[i] = 0;
  vector<vector<ll>> tmp(N + 1);

  for(int i = 0; i < M; ++i) {
    if(!vector_finder(tmp[A[i]], B[i])) {
      tmp[A[i]].push_back(B[i]);
      tmp[B[i]].push_back(A[i]);
    }
  }

  for(int i = 1; i <= N; ++i) {
    if(!tmp[i].empty()) {
      int tmp_num = 0;
      for(int k = 0; k < tmp[i].size(); ++k) {
        if(tmp_num < H[tmp[i][k] - 1]) tmp_num = H[tmp[i][k] - 1];
      }
      vec[i] = tmp_num;
    } else {
      vec[i] = -1;
    }
  }

  int ans = 0;
  for(int i = 1; i <= N; ++i) {
    if(H[i - 1] > vec[i] || vec[i] == -1) {
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 12240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 87;
ll a[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(a,a+n);
    ll b = a[n/2], ans = 0;
    for (int i = 0; i < n; ++i)
        ans += abs(b - a[i]);
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int x1,x2,x3,x4,x5;
	cin >> x1 >> x2 >> x3 >> x4 >> x5;
	if(x1==0) cout << 1;
	else if(x2==0) cout << 2;
	else if(x3==0) cout << 3;
	else if(x4==0) cout << 4;
	else
		cout << 5;
	
	return 0;
}


Measured memory_bytes: 3564
#include <algorithm>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
const int inf = 1 << 30;
const int INF = INT_MAX;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;

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

    int alphabet[26] = {0};
    for (int i = 0; i < s.size(); i++) {
        alphabet[s[i] - 'a']++;
    }

    for (int i = 0; i < 26; i++) {
        if (!alphabet[i]) {
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }

    cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

// int prime[1000001];
// vector<ll> primes;

// void soe() {
//     int i,j;
//     for(i=2;i<1000001;i++) prime[i] = 1;
//     for(i=2;i<=sqrt(1000001);i++) {
//         if(prime[i] == 1) {
//             for(j=i*i;j<1000001;j+=i) {
//                 prime[j] = 0;
//             }
//         }
//     }
//     for(i=2;i<1000001;i++) {
//         if(prime[i]) primes.pb(i);
//     }
// }

int d[10];

bool valid(int n) {
    while(n) {
        if(d[n%10]) return false;
        n/=10;
    }
    return true;
}

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

    int n;
    cin >> n;
    cout << n*(n+1)/2 << "\n";
    return 0;
}




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

int main()
{
	int n,i,sum=0,x;int res=0;
	cin>>n>>x;
	int m[n];
	for(i=0;i<n;i++)
	cin>>m[i];
	for(i=0;i<n;i++)
	sum+=m[i];
	
	res=x-sum;
	int temp = m[0];
   for(int i=0; i<n; i++) {
      if(temp>m[i]) {
         temp=m[i];
      }
   }
   
   int rem=res/temp;
    
    int ans=n+rem;
    cout<<ans<<endl;
	
	
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int  a, b ,c;
    char X,Y;
    string S1,S2;
    cin >> S1 >> S2;
    if(S1[0]==S2[2] && S1[1]==S2[1] && S1[2]==S2[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    
}


Measured memory_bytes: 256
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

int main() {
    ios_base::sync_with_stdio(false);

    ll h, n;
    cin >> h >> n;
    ll total = 0;
    for(int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        total += x;
    }
    if(total >= h) {
        cout << "Yes\n";
    }else {
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m&&n&&m){
    vector<int>h(n),w(m);
    int sumh=0,sumw=0;
    for(int i=0;i<n;++i){
      cin>>h[i];
      sumh+=h[i];
    }
    for(int i=0;i<m;++i){
      cin>>w[i];
      sumw+=w[i];
    }
    vector<int>cnth(max(sumh,sumw),0);
    for(int i=1;i<=n;++i){
      for(int j=0;j<=n-i;++j){
	int sum=0;
	for(int k=0;k<i;++k) sum+=h[j+k];
	++cnth[sum-1];
      }
    }
    int cnt=0;
    for(int i=1;i<=m;++i){
      for(int j=0;j<=m-i;++j){
	int sum=0;
	for(int k=0;k<i;++k) sum+=w[j+k];
	cnt+=cnth[sum-1];
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}



Measured memory_bytes: 4984