akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#define MAX_SIZE 500010
#define INFTY 2000000000
using namespace std;

int n, cmp=0, A[MAX_SIZE];

int partition(int p, int r) {
    int x = A[r];
    int i = p - 1;
    for (int j=p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}


int main(){
    cin >> n;
    for (int i=0; i < n; i++) scanf("%d", &A[i]);
    int q = partition(0, n-1);
    for (int i=0; i < q; i++) printf("%d ", A[i]);
    printf("[%d] ", A[q]);
    for (int i=q+1; i < n-1; i++) printf("%d ", A[i]);
    cout << A[n-1] << endl;
    return 0;
} 


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

int main() {
    int n,tmp;
    cin >> n;

    vector<int> vec(10010,0);

    for (int i =1 ; i<=100; i++){
        for (int j = 1; j<=100; j++){
            for (int k = 1; k<=100; k++){
                tmp = i*i + j*j + k*k +i*j + j*k + i*k;
                if (tmp <=10000){
                     vec.at(tmp) += 1;
                }
            }
        }
    }

    for (int l = 1; l <= n; l++){
        cout << vec.at(l) << endl;
    }
}

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

int main()
{
    int n, w;
    cin >> n >> w;

    vector<pair<int, int>> item(n);
    for (int i = 0; i < n; i++)
    {
        cin >> item.at(i).first >> item.at(i).second;
    }
    int64_t w0 = item.at(0).first;
    int64_t w1 = w0 + 1, w2 = w0 + 2, w3 = w0 + 3;

    vector<int> item0(0), item1(0), item2(0), item3(0);
    for (int i = 0; i < n; i++)
    {
        int wi = item.at(i).first, vi = item.at(i).second;
        if (wi == w0)
        {
            item0.push_back(vi);
        }
        else if (wi == w1)
        {
            item1.push_back(vi);
        }
        else if (wi == w2)
        {
            item2.push_back(vi);
        }
        else
        {
            item3.push_back(vi);
        }
    }
    sort(item0.begin(), item0.end(), greater<int>());
    sort(item1.begin(), item1.end(), greater<int>());
    sort(item2.begin(), item2.end(), greater<int>());
    sort(item3.begin(), item3.end(), greater<int>());

    int res = 0;
    for (int n0 = 0; n0 <= item0.size(); n0++)
    {
        for (int n1 = 0; n1 <= item1.size(); n1++)
        {
            for (int n2 = 0; n2 <= item2.size(); n2++)
            {
                for (int n3 = 0; n3 <= item3.size(); n3++)
                {
                    if (w0 * n0 + w1 * n1 + w2 * n2 + w3 * n3 > w)
                    {
                        continue;
                    }
                    int tmp = 0;
                    for (int i = 0; i < n0; i++)
                    {
                        tmp += item0.at(i);
                    }
                    for (int i = 0; i < n1; i++)
                    {
                        tmp += item1.at(i);
                    }
                    for (int i = 0; i < n2; i++)
                    {
                        tmp += item2.at(i);
                    }
                    for (int i = 0; i < n3; i++)
                    {
                        tmp += item3.at(i);
                    }
                    if (res < tmp)
                    {
                        res = tmp;
                    }
                }
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
# coding=utf-8

###
### for atcorder program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def get_input():
    N = []
    while True:
        try:
            N.append(input())
            #N.append(int(input()))
            #N.append(float(input()))
        except EOFError:
            break
    return N

def conv(s):
    num = 2
    if s == 'A':
        num = 0
    elif s == 'B':
        num = 1
    return num

N = get_input()
C = [1, 0, 0]

for i in N:
    a, b = [x for x in i.split(',')]
    a = conv(a)
    b = conv(b)
    C[a], C[b] = C[b], C[a]

if C[0] == 1:
    print("A")
elif C[1] == 1:
    print("B")
else:
    print("C")
    


Measured memory_bytes: 5644
#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_mut)]
use num::integer::gcd;
use proconio::fastout;
use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::f64::consts::PI;
use std::mem::swap;

type Pi = (i32, i32);

fn pri<T: std::fmt::Display>(x: T) {
    println!("{}", x);
}

#[fastout]
fn main() {
    input! {
        n: i64, m:i64, a:[i64; m],
    }
    let mut sum = a.iter().fold(0, |sum, x| sum + x);
    pri(if sum <= n { n - sum } else { -1 });
}


Measured memory_bytes: 2264
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)

ll sq(ll x){
	return x*x;
}

bool isvowel(char c){
	int i;
	string v="aeiou";
	for(i = (v.size()-1); i>=0; --i){
		if(c == v[i]){
			return true;
		}
	}
	return false;
}

int main(void){
	int n,i,m,p;
	ll t[123456],x,sum=0ll;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> t[i];
		sum += t[i];
	}
	cin >> m;
	for(i=0; i<m; ++i){
		cin >> p >> x;
		p--;
		cout << (sum-t[p]+x) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC 065 B
//
//  Created by Shuangyi Zhang on 2017/6/24.
//  Copyright © 2017年 Shuangyi Zhang. All rights reserved.
//

#include <iostream>
using namespace std;
int main() {
    int n,a[100000],t;
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>a[i];
    }
    int p=1,ans=0;
    while (p!=2){
        if (a[p]==p){
            cout<<"-1"<<endl;
            return 0;
        }
        t=p;
        p=a[p];
        a[t]=t;
        ans+=1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    var ans = Int.MAX_VALUE
    for (a in 1 until n) {
        val b = n - a
        val sumA = a.toString().map { (it - '0') }.sum()
        val sumB = b.toString().map { (it - '0') }.sum()
        ans = Math.min(ans, sumA + sumB)
    }
    println(ans)
}

Measured memory_bytes: 45336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int Y=0;
  string S;
  string T;
  cin>>S>>T;
  for(int X=0;X<S.size();X++){
    if(S.at(X)!=T.at(X)){
      Y++;
    }
  }
  cout<<Y<<endl;
}

Measured memory_bytes: 3832
N,K = map(int,input().split())
A = list(map(int,input().split()))
left = 0
right = K
while True:
  if right>=N:
    break
  else:
    if A[right]>A[left]:
      print('Yes')
    else:
      print('No')

    left += 1
    right += 1

Measured memory_bytes: 94256
#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1e9 + 1;

int main() {
  int n, m, l;
  cin >> n >> m >> l;
  vector<vector<int>> d(n, vector<int>(n, INF)), r(n, vector<int>(n, INF));
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (d[i][k] + d[k][j] < d[i][j]) d[i][j] = d[i][k] + d[k][j];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (d[i][j] <= l) r[i][j] = 1;
    }
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (r[i][k] + r[k][j] < r[i][j]) r[i][j] = r[i][k] + r[k][j];
      }
    }
  }

  int q;
  cin >> q;
  for (; q > 0; q--) {
    int s, t;
    cin >> s >> t;
    s--, t--;
    cout << (r[s][t] != INF ? r[s][t] - 1 : -1) << endl;
  }
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int N, K, Q;
    cin >> N >> K >> Q;
    int A[100000];
    int poi[100000];
    for (int i = 0; i < Q; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++)
    {
        poi[i] = K-Q;
    }
    for (int i = 0; i < Q; i++)
    {
        poi[A[i]-1]++;
    }
    for (int i = 0; i < N; i++)
    {
        if (poi[i] <= 0)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
    }
    //   cout << res << endl;
    return 0;
}

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

int main(){
    int k ;
    cin >> k ;
    k = 9 * k ;
    if (k % 7 == 0){
        k = k / 7 ;
    }
    if (k % 5 == 0 || k % 2 == 0){
        cout << -1 << endl ;}

    else {
            int ans = 1;
    int r = 10 % k ;
        rep(i, k){
        if(r == 1){
            break ;
        }
        else {
            r = (r*10) % k ;
            ans++ ;
        }}
        cout << ans << endl ;
    }


}

Measured memory_bytes: 3608
a, b = map(int, input().split())
if a <= 0 <= b:
    print("Zero")
elif a <= b < 0:
    if a == b:
        print("Negative")
    elif (abs(a) - abs(b)) % 2 == 1:
        print("Positive")
    else:
        print("Negative")
else:
    print("Positive")


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int main(void){
	int n; cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	ll sum = 1e9;
	for (int i = -100; i <= 100 ; ++i){
		ll tmp = 0;
		rep(j, n){
			tmp += pow((i - v[j]), 2);
		}
		sum = min(tmp, sum);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int N;
int coin[12] = {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};
int dp[100001];
 
int rec(int sum = N){
    
    int &res = dp[sum];
    if(~res) return res;
    
    res = INT_MAX;
    for(int i = 0; i < 12; ++i){
        if(coin[i] > sum) break;
        res = min(rec(sum - coin[i]) + 1, res);
    }
    
    return res;
}
 
int main(void){
    
    cin >> N;
    
    for(int i = 0; i < 100001; ++i) dp[i] = -1;
    dp[0] = 0;
    
    cout << rec() << endl;
    
    return 0;
    
}

Measured memory_bytes: 3712
function min(arr) {
  return Math.min(...arr);
}

log = console.log;

var stdin = require("fs").readFileSync("/dev/stdin", "UTF-8");
var lines = stdin.split("\n");
var N = lines[0];
var hs = lines[1].split(" ");

var count = 0;

function isAll0(ary) {
  return ary.every(v => v === 0);
}

function isNever0(ary) {
  return ary.every(v => v !== 0);
}

function main(ary) {
  if (isAll0(ary)) return;
  if (isNever0(ary)) {
    m = min(ary);
    count += m;
    ary = ary.map(v => {
      v -= m;
      return v;
    });
  }

  var start = ary.indexOf(ary.find(v => v !== 0));
  var end = ary.indexOf(0, start) === -1 ? ary.length : ary.indexOf(0, start);
  main(ary.slice(start, end));
  main(ary.slice(end, ary.length));
}

main(hs);
log(count);


Measured memory_bytes: 8880
#include <iostream>
#include <queue>
#include <map>
#include <vector>
#include <utility>
using namespace std;

int main(void){
  const string goalState = "01234567";

  // ???????????????????????¶???????±????????????????
  queue<pair<int, string> > wait;
  map<string, int> result;
  wait.push(make_pair(0, goalState));
  result[goalState] = 0;
  
  while(!wait.empty()){
    int cost = wait.front().first;
    string state = wait.front().second;
    wait.pop();
    
    // ??£??\??¶???????±???????
    int zeropos;
    for(zeropos = 0; state[zeropos] != '0'; zeropos++);
    vector<string> nextlist;
    // ?????????????§??????§????????´???
    nextlist.push_back(state);
    swap(nextlist[0][zeropos], nextlist[0][(zeropos + 4) % 8]);
    // ???????§??????§????????´???
    if(zeropos % 4 != 0){
      nextlist.push_back(state);
      swap(nextlist[nextlist.size() - 1][zeropos], nextlist[nextlist.size() - 1][zeropos - 1]);
    }
    // ???????§??????§????????´???
    if((zeropos + 1) % 4 != 0){
      nextlist.push_back(state);
      swap(nextlist[nextlist.size() - 1][zeropos], nextlist[nextlist.size() - 1][zeropos + 1]);
    }
    
    for(int i = 0; i < (int)nextlist.size(); i++){
      if(result.find(nextlist[i]) == result.end()){
        result[nextlist[i]] = cost + 1;
        wait.push(make_pair(cost + 1, nextlist[i]));
      }
    }
  }

  // ?????¨?????????
  vector<string> in(8);
  while(cin >> in[0] >> in[1] >> in[2] >> in[3] >> in[4] >> in[5] >> in[6] >> in[7]){
    string state = in[0] + in[1] + in[2] + in[3] + in[4] + in[5] + in[6] + in[7];
    cout << result[state] << endl;
  }

  return 0;
}

Measured memory_bytes: 5384
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int n,k,x;
	cin >> n >> k;
	vector <int> l(n);
	rep(i,n)
		cin >> l[i];
	sort(ALL(l), greater<int>());
	x = accumulate(l.begin(), l.begin()+k, 0LL);
	cout << x;
}

Measured memory_bytes: 256
// Problem : A - The Number of Even Pairs
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using mapl = map < ll , ll >;
using mapc = map < char , ll >;
using vectorl = vector < ll >;
using vectors = vector < string >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define pb push_back
#define endl "\n"
const ll mod = 1000000007;

ll i=0,j=0,k=0,t=0,n=0;

char x='a',y='a',z='a';
string s="",s1="";

vectorl pr;
void seive(int n){ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++){ 
        if (prime[p] == true){ 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for (int p=2; p<=n; p++) 
      if (prime[p]) 
          pr.push_back(p);
} 

double log_base(ll x, ll base) {
    return ((log(x)*1.0) / (log(base)*1.0));
}


ll power_without_mod(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1){
            ans=ans*a;
        }
        a = a * a;
        b >>= 1;
    }
    return ans;
}

ll power(ll a,ll b){
	a%=mod;
	ll ans=1;
	while(b>0){
		if(b&1){
			ans=ans*a%mod;
		}
		a = a * a%mod;
		b >>= 1;
	}
	return ans;
}
// if mod is prime: calculate x^(n mod (m-1))
// if  is string   find number calculating with mod of (m-1)

//for ex:
// string b = "100000000000000000000000000"; 
  
//     ll remainderB = 0; 
//     ll MOD = 1000000007; 
  
//     // Reduce the number B to a small number 
//     // using Fermat Little 
//     for (int i = 0; i < b.length(); i++) 
//         remainderB = (remainderB * 10 + b[i] - '0') % (MOD - 1); 
  
//     cout << power(a, remainderB, MOD) << endl; 


void solve(){
	ll n,m;
	cin>>n>>m;
	ll ans=0;
	for(i=1;i<n;i++)
		ans+=i;
	for(i=1;i<m;i++)
		ans+=i;
	cout<<ans<<endl;
}

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // ll t;
    // cin>>t;
    // while(t--){
    	solve();
    // }
    return 0;
}





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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    int ans = K;
    rep(i, N-1) ans*=K-1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#import <Foundation/Foundation.h>

int main(void){

     NSAutoreleasePool* pool = [NSAutoreleasePool new];
  	 {
    
        NSStringEncoding enc = NSUTF8StringEncoding;
        NSFileHandle *stdin = [NSFileHandle fileHandleWithStandardInput];
        NSFileHandle *stdout = [NSFileHandle fileHandleWithStandardOutput];
        
        NSData *indata = [stdin readDataToEndOfFile];
        NSMutableString *str = [NSMutableString alloc];
        [str initWithBytes:indata.bytes length:indata.length encoding:enc];
        
        NSScanner *scan = [NSScanner alloc];
        [scan initWithString:str];
        
        NSString *n_str = [NSString alloc];
        [scan scanUpToString:@"\n" intoString:&n_str];
        NSInteger n = [n_str integerValue];
      	
        
        [stdout writeData:[(n<1000?@"ABC":@"ABD") dataUsingEncoding:enc]];
    }
    [pool release];
    return 0;
}

Measured memory_bytes: 9760
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define rep(i,s,e) for (int64_t i=s; i<e; i++)
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int64_t a, b, c, d, ans;
  cin >> a >> b >> c >> d;
  ans=a*c;
  ans=max(ans,(a*d));
  ans=max(ans,(b*c));
  ans=max(ans,(b*d));
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<cmath>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const int MOD = 1e9+7;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b>c+d){
        cout << "Left" << endl;
    }else if(a+b<c+d){
        cout << "Right" << endl;
    }else{
        cout << "Balanced" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll n;


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

    cin>>n;
    if(n%2){
        cout<<0<<endl;
        return 0;
    }
    ll beki=10;
    ll ans=0;
    ll num=n;
    while(num>0){
        ans+=num/10;
        num/=10;
    }

    //50 かつ 100じゃない，500かつ1000じゃない
    ll besi=50;
    ll k=0;
    while(besi<=n){
        k+=n/besi;
        besi*=5;
    }
    cout<<n/10+k<<endl;
    return 0;
}
//133333333333333333
//124999999999999995
//1000000000000000000


Measured memory_bytes: 256
n = int(input())
XU = []
for _ in [0]*n:
    x, u = input().split()
    XU.append([float(x), u])
ans = 0
for x, u in XU:
    if u == 'JPY':
        ans += x
    else:
        ans += 380000 * x
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int editDistance(string x,string y){
    int n = (int)x.size();
    int m = (int)y.size();
    vector<vector<int> > dp(n+1,vector<int>(m+1));
    for(int i=0;i<=n;++i) dp[i][0] = i;
    for(int i=0;i<=m;++i) dp[0][i] = i;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            dp[i][j] = min(dp[i-1][j]+1,
                     min(dp[i][j-1]+1,dp[i-1][j-1]+(x[i-1]!=y[j-1])));
        }
    }
    return dp[n][m];
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b;
  cin >> a >> b;
  cout << editDistance(a,b) << endl;
}


Measured memory_bytes: 6756
#include<stdio.h>
int main(){
    int r,m,i,j;
    int a[150][150]={0};
    
    
    scanf("%d %d",&r,&m);
    for(i=0;i<r;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
            a[i][m]+=a[i][j];
            a[r][j]+=a[i][j];
            a[r][m]+=a[i][j];
        }
        
    }
    
    for(i=0;i<r+1;i++){
        for(j=0;j<m+1;j++){
            printf("%d",a[i][j]);
            if(j!=m)putchar(' ');
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2080
def prime_factorization(number):
    n = number
    i = 2
    factor = {}
    while i * i <= n:
        while n % i == 0:
            if i in factor:
                factor[i] += 1
            else:
                factor.update({i : 1})
            n //= i
        i += 1
    if n > 1 or not factor:
        if n in factor:
            factor[n] += 1
        else:
            factor.update({n : 1})
    return factor

def main():
    n = int(input())

    if n == 1:
        print(0)
        return

    prime_factor = prime_factorization(n)
    p = len(prime_factor)
    prime_count = [0 for _ in range(p)]
    for i, x in enumerate(prime_factor.items()):
        prime_count[i] = x[1]

    ans = 0
    for i in range(p):
        need = 1
        while prime_count[i] >= need:
            prime_count[i] -= need
            ans += 1
            need += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9244
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <map>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	int n;
	scanf("%d", &n);
	rep(i, n){
		bool can = true;
		int left = 0, right = 0;
		rep(j, 10){
			int a;
			scanf("%d", &a);
			if(min(left, right) > a){
				can = false;
			}
			if(max(left, right) < a){
				if(left<right) right = a;
				else left = a;
			}else{
				if(left<right) left = a;
				else right = a;
			}
		}

		puts(can ? "YES" : "NO");
	}

	return 0;
}

Measured memory_bytes: 0
def solve(a, b, c, d):

    if a < 0 and b > 0:
        x = [0, a, b]
    else:
        x = [a, b]
    if c < 0 and d > 0:
        y = [0, c, d]
    else:
        y = [c, d]

    tmp = x[0] * y[0]
    for xx in x:
        for yy in y:
            if tmp < xx * yy:
                tmp = xx * yy

    return tmp


if __name__ == "__main__":
    a, b, c, d = map(int, input().split())
    print(solve(a, b, c, d))


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    int t,k;
    cin >> t >> k;
    int count =0;
    for(int i=0; i<t; i++){
        int a;
        cin >> a;
        if(a<=k/2){
            count+=(a*2);
        }else{
            count += (k-a)*2;
        }
    }
    cout << count <<endl;

}

Measured memory_bytes: 3528
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n;
    cin >> n;
    vector<Int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    Int ans = 1;
    Ld eps = 10e-15;
    for (int i = 0; i < n; i++) {
        if (log10l(ans) + log10l(a[i]) + eps > (Ld)18) {
            if (ans * a[i] != 1000000000000000000) {
                ans = -1;
                break;
            }
        }

        ans *= a[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3980
n, m = list(map(int, input().split()))

mat = [[False] * m for _ in range(0, n)]
for i in range(0, n):
  v = list(map(int, input().split()))
  for x in v[1:]:
    mat[i][x-1] = True

ans = 0
for i in range(0, m):
  ok = True
  for j in range(0, n):
    ok &= mat[j][i]
  if ok:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    int H,W,i,j;
    while(true){
        cin>>H>>W;
        if(H == 0)break;
        for(i=1;i<=H;i++){
            for(j=1;j<=W;j++){
                cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;    
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  cout << -(H1*60 + M1 - H2*60 - M2 ) - K << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  ll Q,H,S,D,N; cin>>Q>>H>>S>>D>>N;
  if(Q*2<H){ H = Q*2; }
  if(H*2<S){ S = H*2; }
  if(S*2<D){ D = S*2; }
  
  ll r = (N/2)*D + (N%2)*S;
  cout << r<<"\n";
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int D = scanner.nextInt();
    int A = scanner.nextInt();
    Monster[] monsters = new Monster[N];
    for (int i = 0; i < N; i++) {
      int x = scanner.nextInt();
      int h = scanner.nextInt();
      monsters[i] = new Monster(x, (h - 1) / A + 1);
    }
    Arrays.sort(monsters, Comparator.comparingLong(m -> m.x));

    long cum = 0;
    int[] delta = new int[N];
    int j = 0;
    for (int i = 0; i < N; i++) {
      while (j < i && monsters[j].x + 2 * D < monsters[i].x) {
        cum -= delta[j];
        j++;
      }
      if (monsters[i].h > cum) delta[i] = monsters[i].h - (int) cum;
      cum += delta[i];
    }
    long res = 0;
    for (int i = 0; i < N; i++) res += delta[i];
    System.out.println(res);
  }

  private static class Monster {
    private final long x;
    private final int h;

    private Monster(int x, int h) {
      this.x = x;
      this.h = h;
    }
  }
}


Measured memory_bytes: 115108
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)

int main(void) {
  int A, B, C;
	cin >> A >> B >> C;
  REP(i,B) {
    if (A*(i+1) % B == C) {
      cout << "YES" << '\n';
      return 0;
    }
  }
  cout << "NO" << '\n';
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;

int N;
vector<P> a;

bool compare_y(P a, P b) {
  return a.second < b.second;
}

// [l, r)
double closest_pair(int l, int r) {
  int n = r - l;
  if(r - l <= 1) return 2e9; // 1点しかない
  int m = (l + r) / 2;
  int x = a[m].first;
  int d = min(closest_pair(l, m), closest_pair(m, r));
  inplace_merge(a.begin(), a.begin() + m, a.begin() + n, compare_y); // 二つのソート済み配列をマージする 範囲指定->(先頭,中間,最後)

  vector<P> b;
  FOR(i,l,r){
    if(abs(a[i].first - x) >= d) continue;
    FOR(j,0,b.size()){
      // 近いものから見て行く
      int dx = a[i].first - b[b.size() - j - 1].first;
      int dy = a[i].second - b[b.size() - j - 1].second;
      if(dy >= d) break; // 枝狩り?
      d = min(d, dx * dx + dy * dy);
    }
    b.push_back(a[i]);
  }
  return d;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>N;
  a.resize(N);
  FOR(i,0,N)cin>>a[i].first>>a[i].second;
  sort(a.begin(), a.end());
  cout<<closest_pair(0, N)<<endl;

}


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


int main()
{
  ll N;
  cin >> N;
  vector<ll> hankei(N);
  rep (i,N)
  {
    cin >> hankei.at(i);
  }
  sort(hankei.begin(),hankei.end());
  ll count = 1;
  rep(i,N - 1)
  {
    if(hankei.at(i) != hankei.at(i + 1))
    {
      count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        String s = in.next();
        String r = "";
        if(k>1) {
            r = s.substring(0, k-1);
        }
        r += s.substring(k-1, k).toLowerCase();
        if(k<n) {
            r += s.substring(k, n);
        }
        System.out.println(r);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
using namespace std;
int a[200001],b[2000001],t[200001];
int main()
{     int m,n,i,j,k;
      cin>>n>>m;memset(t,0,sizeof(t));
      for(i=1;i<=m;i++){
	  cin>>a[i]>>b[i];
      if(a[i]==1)t[b[i]]++;
      if(b[i]==n)t[a[i]]++;}
      for(i=2;i<n;i++)
         if(t[i]==2){cout<<"POSSIBLE"<<endl;return 0;}
      cout<<"IMPOSSIBLE"<<endl;
	  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

const ll M = 1e9 + 7;

ll n, k, ans;
ll a[100005];
ll fac[100005] = {1, 1};
ll inv[100005] = {1, 1};
ll fiv[100005] = {1, 1};

int main()
{
    scanf("%lld%lld", &n, &k);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    sort(a, a + n);
    for(ll i = 2; i <= n; i++) {
        fac[i] = fac[i - 1] * i % M;
        inv[i] = inv[M % i] * (M - M / i) % M;
        fiv[i] = fiv[i - 1] * inv[i] % M;
    }
    for(ll i = 0; i < n; i++)
    {
        ll j = n - i - 1;
        if(i >= k - 1) ans += a[i] * fac[i] % M * fiv[k - 1] % M * fiv[i - k + 1] % M;
        ans %= M;
        if(j >= k - 1) ans -= a[i] * fac[j] % M * fiv[k - 1] % M * fiv[j - k + 1] % M;
        ans += M;
        ans %= M;
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define endl '\n'

int mod = 1e9 + 7;

int pw(int a, int k) {
    if (k == 0) return 1;
    if (k % 2) return ((long long) pw(a, k - 1) * a) % mod;
    int t = pw(a, k / 2);
    return ((long long) t * t) % mod;
}

int rv(int a) {
    return pw(a, mod - 2);
}

int ml(int a, int b) {
    return ((long long)a * b) % mod;
}

int ml(int a, int b, int c) {
    return ml(ml(a, b), c);
}

int dv(int a, int b) {
    return ml(a, rv(b));
}

int sm(int a, int b) {
    return (a + b) % mod;
}

int df(int a, int b) {
    return ((long long)a + mod - b) % mod;
}

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

string yy = "Yes\n";
string nn = "No\n";
string imp = "IMPOSSIBLE\n";



int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1; // cin >> t;
    while (t--) {
        int n; cin >> n;
        int ans = 0;
        for (int a = 1; a < n; a++) {
            ans += (n - 1) / a;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int a, b, c;
	cin >> a >> b >> c;

	int ans = max(max(a, b),c) * 9 + a + b + c;
	cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
/******************************define**********************************/

/*****************************functions********************************/

/****************************main function*****************************/
int main(void){
    int n,m;cin>>n>>m;
    vector<int> l(m),r(m);
    rep(m) cin>>l[i]>>r[i];
    sort(all(l));reverse(all(l));
    sort(all(r));
    if(r[0]-l[0]<0) cout << 0 << endl;
    else cout << r[0]-l[0]+1 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>

//入力
#define in(N) cin >> N
#define in2(N,M) in(N) >> M
#define in3(N,M,K) in2(N,M) >> K
#define in4(N,M,K,L) in3(N,M,K) >> L
//出力
#define out(ans) cout << (ans) << endl
#define out2(a,b) cout << (a) << " " << (b) << endl
#define out3(a,b,c) cout << (a) << " " << (b) << " " << (c) << endl
#define outf(ans) cout << fixed << setprecision(6) << ans << endl

#define rep(i,n) for(int i=0; i<n; i++) //n回ループ
#define all(v) v.begin(), v.end() //vectorの全体を指定
#define sort_g(A,T) sort(all(A),greater<T>()) //降順ソート

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vstr;
const ll mod=1e9+7;

int main(){
	int N,M;
	in2(N,M);
	vi A(N);
	int sum=0;
	rep(i,N){
		in(A[i]);
		sum+=A[i];
	}
	sort_g(A,int);

	out( ( A[M-1] < (double)sum/(4*M) ) ? "No" : "Yes" );

	return 0;
}

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

using namespace std;

template <typename T>
struct LazySegtree {
	private:
		size_t n;
		vector<T> node, lazy;
		T M0, L0;

	public:
		LazySegtree(size_t sz, T m0, T l0) {
			n = 1;
			M0 = m0;
			L0 = l0;
			while (n < sz) { n *= 2; }
			node.assign(2*n - 1, M0);
			lazy.assign(2*n - 1, L0);
		}

		T merge(T a, T b) { return min(a, b); }
		void updateNode(int k, T x) { lazy[k] = min(lazy[k], x); }
		void propagate(int k) { node[k] = min(node[k], lazy[k]); }

		void eval(int k, int l, int r) {
			if (lazy[k] == L0) { return; }
			propagate(k);
			if (r - l > 1) {
				updateNode(2*k + 1, lazy[k]);
				updateNode(2*k + 2, lazy[k]);
			}
			lazy[k] = L0;
		}

		void update(int a, int b, T x, int k=0, int l=0, int r=-1) {
			if (r < 0) { r = n; }
			eval(k, l, r);
			if (r <= a || b <= l) { return; }
			if (a <= l && r <= b) {
				updateNode(k, x);
				eval(k, l, r);
			} else {
				update(a, b, x, 2*k + 1, l, (l + r) / 2);
				update(a, b, x, 2*k + 2, (l + r) / 2, r);
				node[k] = merge(node[2*k + 1], node[2*k + 2]);
			}
		}

		T query(int a, int b, int k=0, int l=0, int r=-1) {
			if (r < 0) { r = n; }
			eval(k, l, r);
			if (r <= a || b <= l) { return M0; }
			if (a <= l && r <= b) { return node[k]; }
			T vl = query(a, b, 2*k + 1, l, (l + r) / 2);
			T vr = query(a, b, 2*k + 2, (l + r) / 2, r);
			return merge(vl, vr);
		}
};

int main() {
	const int INF = 1e9;
	int N, M;
	string s;
	cin >> N >> M >> s;

	LazySegtree<int> seg(N + 10, INF, INF);
	seg.update(N, N + 1, 0);
	for (int i = N; i > 0; --i) {
		if (s[i] == '1') { continue; }

		int val = seg.query(i, i + 1) + 1;
		int l = max(0, i - M), r = i;
		seg.update(l, r, val);
	}

	if (seg.query(0, 1) == INF) {
		cout << -1 << endl;
		return 0;
	}

	int x = seg.query(0, 1);
	vector<int> ans(x + 1, INF);
	ans[x] = 0;
	for (int i = 0; i <= N; ++i) {
		if (s[i] == '1') { continue; }
		int val = seg.query(i, i + 1);
		if (val >= x) { continue; }

		ans[val] = min(ans[val], i);
	}

	for (int i = x - 1; i >= 0; --i) {
		cout << ans[i] - ans[i + 1] << (i == 0 ? "\n" : " ");
	}

	return 0;
}


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

int main(){
     int n,k;
    cin>>n>>k;
    vector<double>p(n);
    vector<double>sum(n+1);
    for(int i=0; i<n; i++){
        cin>>p.at(i);
        double bu=(1+p.at(i))/2;
        sum.at(i+1)=sum.at(i)+bu;
    }
    double mak=0;
    for(int i=k; i<n+1; i++){
        mak=max(mak,sum.at(i)-sum.at(i-k));
    }
    cout << fixed << setprecision(6);
    cout<<mak<<endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[500][500];

int main(){
  cin >> n >> s;
  rep(i,0,s.sz){
    if(s[i] == 'I')d[i]++;
    else d[i]--;
    d[i+1] = d[i];
  }
  ll ans = 0;
  rep(i,0,s.sz){
    ans = max(ans,d[i]);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
void fuk() { puts("NO"); exit(0); }

const bool debug = 0;
const int MAXN = 100055;
const int MAXH = 1055;

vector<int> G[MAXH];
int GI[MAXH];

bitset<MAXH> chk;

int DgI[MAXH], DgO[MAXH];

int A[MAXN], B[MAXN], C[MAXN], D[MAXN];

vector<int> SV, EV;
int N, H;

void f(int i) {
	chk[i] = true;
	if(sz(G[i]) == GI[i]) return;
	int v = G[i][GI[i]];
	GI[i]++;
	f(v);
}

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

	cin >> N >> H;
	for(int i = 1; i <= N; i++) {
		cin >> A[i] >> B[i] >> C[i] >> D[i];

		int s = -1, e = -1;

		if(C[i]) s = C[i]<<1;
		else s = A[i]<<1 | 1;

		if(D[i]) e = D[i]<<1 | 1;
		else e = B[i]<<1;

		G[s].eb(e);
		DgO[s]++; DgI[e]++;

		if(debug) printf("%d : %d -> %d\n", i, s, e);
	}

	for(int i = 0; i < MAXH; i++) {
		if(DgI[i] == DgO[i]) continue;
		if(DgI[i] < DgO[i]) {
			for(int j = DgO[i] - DgI[i]; j--;)
				SV.eb(i);
		} else {
			for(int j = DgI[i] - DgO[i]; j--;)
				EV.eb(i);
		}
	}

	if(SV.empty() || sz(SV) != sz(EV)) fuk();

	for(int v : SV) if(!(v & 1)) fuk();
	for(int v : EV) if(v & 1) fuk();

	for(int i = 0; i < MAXH; i++) {
		srand(time(0));
		random_shuffle(allv(G[i]));
	}

	for(int v : SV) {
		f(v);
	}

	for(int i = 0; i < MAXH; i++) if(chk[i]) {
		for(; GI[i] < sz(G[i]);) f(i);
	}

	for(int i = 0; i < MAXH; i++)
		if(sz(G[i]) != GI[i]) fuk();

	puts("YES");
	return 0;
}

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

int main() {
  int n, b, f, r, v;
  vector<vector<vector<int> > > data(5, vector<vector<int> > (4, vector<int>(11)));

  //  初期化
  for (int h = 1; h < 5; h++){
    for (int i = 1; i < 4; i++) {
      for (int j = 1; j < 11; j++) {
        data.at(h).at(i).at(j) = 0;
      }
    } 
  }

  cin >> n;
  int i = 0;
  while (i < n){
    cin >> b >> f >> r >> v;
      data.at(b).at(f).at(r) += v;
    i++;
  }  

  //  表示
  for (int h = 1; h < 5; h++){
    for (int i = 1; i < 4; i++) {
      for (int j = 1; j < 11; j++) {
        cout << " " << data.at(h).at(i).at(j);  
      }
      cout << endl;
    } 
    if (h <= 3){
      cout << "####################" << endl;
    }
  }
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    bool flag=true;
    rep(i, n){
        int a;
        cin >> a;
        if(flag&&a%2==0){
            if(a%3!=0&&a%5!=0){
                flag = false;
            }
        }
    }
    if(flag){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=2e5;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int head[N],nxt[N],to[N];
int f[N];
//给每个点一个标号，使得任意两个相同标号的点的路径上存在点标号大于这两个点
//每次贪心选择最小的标号
inline void dfs(int k,int fa) {
	int s=0,all=0;
	for (int i=head[k];i;i=nxt[i])
		if (to[i]!=fa) {
			dfs(to[i],k);
			all|=s&f[to[i]];
			s|=f[to[i]];
		}
	(all<<=1)|=1;
	for (int i=30;i>=0;i--)
		if (all>>i&1) {
			while (s>>i&1) i++;
			f[k]=(s^(s&((1<<i)-1)))|(1<<i);
			return;
		}
}
int main()
{
	int n=gi(),i,a,b,tot=0;
	for (i=1;i<n;i++) {
		a=gi(),b=gi();
		to[++tot]=b,nxt[tot]=head[a],head[a]=tot;
		to[++tot]=a,nxt[tot]=head[b],head[b]=tot;
	}
	dfs(1,0);
	for (i=30;i>=0;i--)
		if (f[1]>>i&1)
			return printf("%d\n",i),0;
	return 0;
}


Measured memory_bytes: 4864
use std::io::*;
use std::str::*;

const MOD: i32 = 1000000007;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let n: usize = read().unwrap();
    let mut vec = Vec::new();

    for i in 0..n {
        let tmp: i64 = read().unwrap();
        vec.push(tmp);
    }

    let sum = vec.iter().sum::<i64>();
    let mut x = vec[0];
    let mut y = sum - vec[0];
    let mut ans = (x - y).abs();
    //    println!("ans ... {}", ans);
    for i in 1..n - 1 {
        x += vec[i];
        y = sum - x;
        //        println!("{} {} ", x, y);
        ans = std::cmp::min(ans, (x - y).abs());
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

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

    int table[100] = {0};

    /* 
    for(int i = 0; i < n; i++) {
        cout << table[i] << " ";
    }
    cout << endl;
    */

    for(int P = 0; P < 100; P++) {
        for (int j = 0; j < n; j++) {
            table[P] += pow((x[j] - (P + 1)), 2);
        }
    }

    /*
    for(int i = 0; i < 100; i++) {
        cout << table[i] << " ";
    }
    cout << endl;
    */

    sort(table, table + 100);

    cout << setprecision(15) << table[0] << endl;

    

    return 0;
}

Measured memory_bytes: 256