akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()
	a := scanInts(m)

	b := []int{6, 2, 5, 5, 4, 5, 6, 3, 7, 6}
	dp := make([]string, n+1)
	dp[0] = "#"

	sort.Ints(a)

	for k := 0; k < m; k++ {
		num := strconv.Itoa(a[m-1-k])
		c := b[a[m-1-k]]
		for i := 0; i < n; i++ {
			if i+c > n || len(dp[i]) == 0 {
				continue
			}

			tmp := dp[i] + num
			if len(dp[i+c]) < len(tmp) || len(dp[i+c]) == len(tmp) && dp[i+c] < tmp {
				dp[i+c] = tmp
			}
		}
	}

	fmt.Fprintln(wr, dp[n][1:])
}


Measured memory_bytes: 51712
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;

void ans(bool flag)
{
	if(flag)cout<<"Yes"<<"\n";
	else cout<<"No"<<"\n";
}
int main(){
	int n;cin>>n;
	int x=n%10;
	if(x==2 || x==4 ||x==5 ||x==7||x==9)cout<<"hon"<<"\n";
	else if(x==3)cout<<"bon"<<"\n";
	else cout<<"pon"<<"\n";
	
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;

int R,G,B;
void solve() {
  string color[8] = {"black","blue","lime","aqua","red","fuchsia","yellow","white"};
  int icolor[8][3] = {{0,0,0},{0,0,255},{0,255,0},{0,255,255},{255,0,0},{255,0,255},{255,255,0},{255,255,255}};
  int nearest=0,dist,mindist=1000000;
  for(int i=0;i<8;i++) {
    dist =  (R-icolor[i][0])*(R-icolor[i][0]) + (G-icolor[i][1])*(G-icolor[i][1]) + (B-icolor[i][2])*(B-icolor[i][2]);
    if(dist < mindist) {
      mindist = dist;
      nearest = i;
    }
  }
  cout << color[nearest] << endl;
}

int main() {
  string str;
  while(getline(cin,str)) {
    if(str == "0") break;
    R = strtol(str.substr(1,2).c_str(),NULL,16);
    G = strtol(str.substr(3,2).c_str(),NULL,16);
    B = strtol(str.substr(5,2).c_str(),NULL,16);
    solve();
  }
  return 0;
}

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

vector<pair<int, int>> edges[100000];
int ans[100000];

void dfs(int i, int par, int pc){
    int c = 1;
    for(auto p : edges[i]){
        int j = p.first, idx = p.second;
        if(j == par) continue;
        if(c == pc) c++;
        ans[idx] = c;
        dfs(j, i, c);
        c++;
    }
}

int main(){
    int N;
    cin >> N;
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].emplace_back(b, i);
        edges[b].emplace_back(a, i);
    }
    dfs(0, -1, -1);
    cout << *max_element(ans, ans+N-1) << endl;
    for(int i=0; i<N-1; i++) cout << ans[i] << endl;
    return 0;
}


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

struct UnionFind {
	vector<int> par;
	int cnt;
	UnionFind(int size_) : par(size_, -1), cnt(size_) {}
	void unite(int x, int y) {
		if((x = find(x)) != (y = find(y))) {
			if(par[y] < par[x]) swap(x, y);
			par[x] += par[y]; par[y] = x; cnt--;
		}
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
	int size(int x) { return -par[find(x)]; }
	int size() { return cnt; }
};

const int INF = 1e9;

vector<int> dist(100000);
typedef pair<int, int> P;

struct edge {
	int from, to, d;
	bool operator <(const edge& x) const {
		return d > x.d;
	}
};

vector<edge> G[100000];
edge es[200000];
int a[100000];
int b[100000];
set<int> qs[100000];
int ans[100000];

int main() {
	int N, M, K, Q;
	scanf("%d%d%d%d", &N, &M, &K, &Q);

	for(int i = 0; i < M; i++) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		a--, b--;
		G[a].push_back({ a, b, c });
		G[b].push_back({ b, a, c });
		es[i] = { a, b, -1 };
	}

	fill(dist.begin(), dist.end(), INF);
	priority_queue <P, vector<P>, greater<P>> q;
	for(int i = 0; i < K; i++) {
		int a;
		scanf("%d", &a);
		a--;
		dist[a] = 0;
		q.push({ 0, a });
	}
	while(q.size()) {
		int v = q.top().second, d = q.top().first;
		q.pop();
		if(dist[v] < d) continue;
		for(auto& e : G[v]) {
			if(dist[e.to] > d + e.d) {
				dist[e.to] = d + e.d;
				q.push({ d + e.d, e.to });
			}
		}
	}

	for(int i = 0; i < M; i++) {
		int u = es[i].from, v = es[i].to;
		es[i].d = min(dist[u], dist[v]);

	}
	sort(es, es + M);

	for(int i = 0; i < Q; i++) {
		scanf("%d%d", &a[i], &b[i]);
		a[i]--, b[i]--;
		qs[a[i]].insert(i);
		qs[b[i]].insert(i);
	}

	UnionFind uf(N);
	for(int i = 0; i < M; i++) {
		int u = es[i].from, v = es[i].to;
		if(uf.same(u, v)) continue;
		int up = uf.find(u), vp = uf.find(v);
		if(uf.size(up) < uf.size(vp)) swap(up, vp);
		uf.unite(u, v);
		for(auto p : qs[vp]) {
			if(uf.same(a[p], b[p])) {
				ans[p] = es[i].d;
				qs[up].erase(p);
			}
			else {
				qs[up].insert(p);
			}
		}
	}
	for(int i = 0; i < Q; i++) {
		printf("%d\n", ans[i]);
	}
}

Measured memory_bytes: 59140
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

vector<ll> prime_factor(ll n) {
    vector<ll> ret;
    ret.push_back(1);
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        ret.push_back(n);
    }
    return ret;
}

ll next_combination(ll sub) {
    ll x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}

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

    ll res = 0;
    ll min_res = 1e14;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i != 0) {
            continue;
        }
        res = i + (N / i);
        if (res < min_res) {
            min_res = res;
        }
    }
    cout << min_res - 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  vector<int> cnt(1000005);
  for(int x:a){
     if(cnt[x]!=0){
       cnt[x]=2;
       continue;
     }
    for(int i=x;i<1000005;i+=x) cnt[i]++;
  }
  int ans=0;
  for(int x:a){
    if(cnt[x]==1) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 8000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int len = Math.abs(a-b);
		int height = 0;
		for(int i=1; i<=len; i++) {
			height += i;
		}
		System.out.println(height-Math.max(a, b));
	}
}


Measured memory_bytes: 21588
from collections import deque

H,W = map(int, input().split())
A = [input() for _ in range(H)]

d = [[10**6]*W for _ in range(H)]
q = deque()
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            d[i][j] = 0
            q.append((i, j, 0))
            
while q:
    temp = q.popleft()
    y = temp[0]
    x = temp[1]
    r = temp[2]
    if y != 0:
        if d[y-1][x] > r+1 and A[y-1][x] == ".":
            d[y-1][x] = r+1
            q.append((y-1, x, r+1))
    if y != H-1:
        if d[y+1][x] > r+1 and A[y+1][x] == ".":
            d[y+1][x] = r+1
            q.append((y+1, x, r+1))
    if x != 0:
        if d[y][x-1] > r+1 and A[y][x-1] == ".":
            d[y][x-1] = r+1
            q.append((y, x-1, r+1))
    if x != W-1:
        if d[y][x+1] > r+1 and A[y][x+1] == ".":
            d[y][x+1] = r+1
            q.append((y, x+1, r+1))
                        
ans = 0
for i in range(H):
    ans = max(ans, max(d[i]))
    
print(ans)

Measured memory_bytes: 166876
#include <cstdio>
#include <cmath>


int main(){
	/*
	+ - 
	* / %
	=
	==  !=    <     >    <=    >=  
	double eps = 1e-8; 
	double x = 0.1, y = 0.2;
	fabs(x - y) < eps
	abs()
	if(x == y) printf("aa");
	*/
	/*
	位运算符

	&
	|
	^


	*/

	/*
	1 & 1 = 1
	1 & 0 = 0
	0 & 1 = 0
	0 & 0 = 0

	1 | 1 = 1
	1 | 0 = 1
	0 | 1 = 1
	0 | 0 = 0

	1 ^ 1 = 0
	1 ^ 0 = 1
	0 ^ 1 = 1
	0 ^ 0 = 0
	*/

	/*
   int n = 0;
   scanf("%d", &n);
   if((n & 1) == 1) printf("%d是奇数\n", n);
   else printf("%d是偶数\n", n);
	 */

	 /*
		 &&      || 
	 */
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if(a == 5 && b == 7 && c == 5) printf("YES\n");
	else if(a == 7 && b == 5 && c == 5) printf("YES\n");
	else if(a == 5 && b == 5 && c == 7) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


s = S() + 'T'
x, y = LI()
t_flag = 0
# 0の時横移動、1の時縦移動。
flag = 0
y_now = x_now = 1 << 8000
f_cnt = 0
for j in s:
    if j == 'T':
        if not flag:
            flag = 1
            x_now >>= f_cnt
        elif t_flag:
            y_now = y_now >> f_cnt | y_now << f_cnt
        else:
            x_now = x_now >> f_cnt | x_now << f_cnt
        t_flag ^= 1
        f_cnt = 0
    else:
        f_cnt += 1


if (1 << 8000 + y) & y_now and (1 << 8000 - x) & x_now:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 40432
from bisect import bisect

n, x = map(int, input().split())

P_N = [1]
L_N = [1]

for i in range(n):
  P_N.append(2*P_N[i]+1)
  L_N.append(2*L_N[i]+3)
  
def rec_check(n, x):
  if n==0:
    return(0 if x<=0 else 1)
  
  if x <= L_N[n-1]+1:
    return(rec_check(n-1, x-1))
  else:
    return(P_N[n-1]+1+rec_check(n-1, x-2-L_N[n-1]))
  
print(rec_check(n,x))    


Measured memory_bytes: 3064
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

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

    if(    (n.substr(0,1)==n.substr(1,1) && n.substr(0,1)==n.substr(2,1))
        || (n.substr(1,1)==n.substr(2,1) && n.substr(1,1)==n.substr(3,1))
    )  cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::vector<ll> vs(3);

int main() {
  for( auto &x : vs )
    std::cin >> x;

  std::sort(rall(vs));

  std::cout << vs[0]*10+vs[1]+vs[2] << endl;

  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
	int n;
	ll ans = 0;
	string s;
	map<string, int> mp;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}
	for (auto x : mp){
		if (x.second >= 2) ans += (ll)x.second*(x.second-1)/2;
	}

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



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

string divide[4] = {"dream","dreamer","erase","eraser"};

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

	reverse(S.begin(),S.end());
	for(int i = 0; i < 4;++i)reverse(divide[i].begin(),divide[i].end());

	bool can = true;
	for(int i = 0;i < S.size();){
		bool can2 = false;
		for(int j = 0;j < 4; ++j){
			string d = divide[j];
			if(S.substr(i,d.size()) == d){
				can2 = true;
				i += d.size();
			}
		}
		if(!can2){
			can = false;
			break;
		}
	}

	if(can) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 512
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                long X = scan.nextLong();
                long A = 0;
                long B = 0;
                ArrayList<Integer> arrayList = new ArrayList<Integer>();
               
                if(0<X || X<0){
                    for(int i=-120; i<=120; i++){
                        for(int j=-120; j<=120; j++){
                            if(i*i*i*i*i-j*j*j*j*j==X){
                                System.out.println(i + " " + j);
                                System.exit(0);
                            }
                        }
                    }
                }
                else if(X==0){
                    System.out.println("1 1");
                }
        }
}

Measured memory_bytes: 38936
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
    long long int n, i,j,k,sum=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                sum++;

            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		System.out.println((sc.nextInt()+sc.nextInt())>=sc.nextInt() ? "Yes" : "No");
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

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

int main(){
  int n; cin >> n;
  vector<int> v(n); cin >> v;
  ll sum = 0;
  for(int i = 0; i < n; ++i)sum += v[i];
  ll t = 0;
  ll ans = 1001001001001001;
  for(int i = 0; i < n; ++i){
    t += v[i];
    if(i!=n-1)ChangeMin(ans,abs(sum-2*t));
  }
  cout << ans << endl;
}



Measured memory_bytes: 4016
n,m=map(int,input().split())
mod=10**9+7
a=[]
for i in range(m):
    a.append(int(input()))
aa=set(a)
l=[0 for i in range(n+1)]
l[0]=1

for i in range(n):
    if i+1 not in aa:
        l[i+1]+=l[i]
        l[i+1]=l[i+1]%mod
    if i+2 not in aa and i+2<n+1:
        l[i+2]+=l[i]
        l[i+2]=l[i+2]%mod

print(l[n])


Measured memory_bytes: 13216
n,e = gets.split.map(&:to_i)
sushi = Array.new(n).map{Array.new(2, 0)}
for i in 0..n-1
  sushi[i] = gets.split.map(&:to_i)
end
eat1 = Array.new(n+1,0)
eat2 = []
base = 0
bonus = 0
ans = 0
sushi.sort_by! {|s| s[1]}
for i in 1..n
  if i <= e
    if eat1[sushi[-i][0]] == 0
      eat1[sushi[-i][0]] = 1
      base += sushi[-i][1]
      bonus += 1
    else
      eat2.push(sushi[-i][1])
      base += sushi[-i][1]
    end
    if ans < base+bonus**2
      ans = base+bonus**2
    end
  else
    if eat2.length > 0 && eat1[sushi[-i][0]] == 0
      base -= eat2[-1] - sushi[-i][1]
      bonus += 1
      eat2.delete_at(-1)
      eat1[sushi[-i][0]] = 1
      if ans < base+bonus**2
        ans = base+bonus**2
      end
    end
  end
end
puts ans


Measured memory_bytes: 21368
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (int)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=100005;

int main()
{
    IO;
    int a[4];
    for(int i=0;i<4;++i)
        cin >> a[i];
    sort(a,a+3);
    cout<<a[0]+a[1]+(a[2]*(1<<a[3]))<<endl;
    re 0;
}

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

int main() {
 int a,b,c;
 cin >> a >> b >> c;
 if (a+b==c||b+c==a||c+a==b){
  cout << "Yes" << endl;
 }
 else{
  cout << "No" << endl;
 }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
using namespace std;
int nxt[200005][26];
int temp[26];
int dp[200005], bk[200005];
int main () {
	int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
	str A;
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> A; a = A.length(); A = "$" + A;
	for (i = 0; i < 26; i++) temp[i] = a + 1;
	SET(bk, -1);
	dp[a + 1] = 1; dp[a + 2] = 0;
	for (i = a; i >= 1; i--) {
		temp[A[i] - 'a'] = i;
		dp[i] = inf;
		for (j = 0; j < 26; j++) {
			nxt[i][j] = temp[j];
			if (dp[temp[j] + 1] + 1 < dp[i]) {
				dp[i] = dp[temp[j] + 1] + 1;
				bk[i] = temp[j] + 1;
			}
		}
	}
	str B;
	for (i = 1; i != -1; i = bk[i]) {
		for (j = 0; j < 26; j++) {
			if (bk[i] == nxt[i][j] + 1) {
				B.append(1, char(j + 97)); break;
			}
		}
	}
	printf("%s\n", B.c_str());
	return 0;
}

Measured memory_bytes: 22480
/* HARDWORK IS THE KEY TO SUCCESS.
       RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.!!!*/
    #include <bits/stdc++.h>
    #define pragma
    using namespace std;
    #define ll long long
    #define ld long double
    #define T ll t = 1; cin>>t; while(t--)
    #define vin ll n; cin>>n; vector<ll>x(n); for(ll i=0; i<n; i++) cin>>x[i]
    #define vout for(ll i=0; i<n; i++) cout<<x[i]<<" "
    #define ain ll n,k,i; cin>>n; ll a[n]; for( i=0; i<n; i++) cin>>a[i]
    #define aout for(ll i=0; i<n; i++) cout<<a[i]<<" "
    #define matin ll m,n; cin >> n; ll a[n + 1][n + 1] ; for(ll i=1;i<=n;i++) for(ll j=1;j<=n;j++) cin>>a[i][j];
    #define matout for(ll i=0;i<m;i++){for(ll j=0;j<n;j++) cout<<a[i][j]<<" "; cout<<"\n";}
    #define sin set<ll>s; ll n; cin>>n; ll tmp; for(ll i=0;i<n;i++){cin>>tmp; s.I(tmp);}
    #define sout for(auto it=s.begin();it!=s.end();++it) cout<<*it<<" "
    #define F first
    #define S second
    #define I insert
    #define pb push_back
    #define ppb pop_back
    #define AISORT sort(a,a+n)
    #define ADSORT sort(a,a+n,greater<ll>())
    #define VISORT sort(x.begin(),x.end())
    #define VDSORT sort(x.begin(),x.end(),greater<ll>())

    const ll maxs = 1e5+3;
    const ll maxs1 = 1e3+4;
    const ll mod = 1e9 + 7;

    //MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

    //POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

    //MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}

//     ll n;
//     ll a[maxs];
//     ll tree[maxs];
    bool vis[maxs];
    vector<ll>graph[maxs];
    //ALWAYS CLEAR THEM WHEN TESTCASES ARE GIVEN
    //ALWAYS RETURN WHEN ST == ED CONDITION IN SEGMENT TREES


    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
       
        ll a,b,c;
        cin >> a >> b >> c;
        swap(a,b);
        swap(a,c);
        cout << a << " " << b << " " << c;
        
    }

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;
//#define _USE_MATH_DEFINES

int main(void) {
	LL n, num = 0, ans = 0;
	cin >> n;
	vector<LL> a(n);
	vector<LL> odd;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			odd.push_back(a[i]);
		}
	}

	for (int i = 0; i < odd.size(); i++) {
		int j = 2;
		while (1) {
			if (odd[i] % j == 0) {
				num++;
				j *= 2;
			}
			else {
				break;
			}
		}
	}
	cout << num << endl;



	return 0;
}


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

int main() {
  int i, N;
  string C;
  cin >> N;
   for(i=0; i<N; i++){
    cin >> C;
     if(C=="Y"){
     cout << "Four" <<endl;
     break;}
     if(i==N-1){
     cout << "Three" <<endl;
     break;} 
   }
}

Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a,b;
  cin >> a >> b;
  if(a*b%2==0) cout << "Even" << endl;
  else cout << "Odd" << endl;

}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <vector> // vector
#include <set> // set
#include <string> // string
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <unordered_map> // hashed by keys
#include <iomanip> //cout<<setprecision(n)
#define rep(i,n) for(int i = 0; i < n; i++)

typedef long long ll; // at least int64 > 9*10^18
typedef unsigned long long ull; // at least uint64

int main() {
  std::string s;
  std::cin >> s;
  std::vector<int> v;
  int Acount = 0;
  ll sum = 0;
  if(s.size()<3) {
    std::cout << 0 << "\n";
    return 0;
  }
  rep(i,s.size()-1) {
    if(s[i]=='A') Acount ++;
    else if(s.substr(i,2)=="BC") {
      sum+=Acount;
      i+=1;
    }
    else if(s[i]!='A') Acount = 0;
  }
  std::cout << sum << "\n";
  return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
        public static void main(String[] args){
                try(Scanner sc = new Scanner(System.in)){
                        int N = sc.nextInt();
                        String[] A = new String[N+1], Z = new String[N+1];
                        String S = "";

                        for(int i = 0; i <= N; i++){
                                A[i] = Z[i] = S = sc.next();
                                A[i] = A[i].replaceAll("\\?", "a");
                                Z[i] = Z[i].replaceAll("\\?", "z");
                        }
                        Arrays.sort(A);
                        Arrays.sort(Z);
                        int start = 0, goal = 0;
                        for(int i = 0; i <= N; i++){
                                if(A[i].equals(S)){
                                        goal = i;
                                }
                        }
                        for(int i = N; i >= 0; i--){
                                if(Z[i].equals(S)){
                                        start = i;
                                }
                        }
                        start++; goal++;
                        for(int i = start; i <= goal; i++){
                                if(i == goal){
                                        System.out.println(i);
                                } else {
                                        System.out.print(i+" ");
                                }
                        }
                }
        }
}



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

int n, k, a[200000];

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n - k; ++i)
		cout << (a[i] < a[i + k] ? "Yes" : "No") << endl;

}


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

int main() {
    int n;
    cin >> n;
    int a[n];

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

    long cnt1 = 0;
    long sum1 = 0;
    for(int i=0; i<n; ++i) {
        sum1 += a[i];
        if(i%2 == 0 && sum1 <= 0) {
            cnt1 += (1 - sum1);
            sum1 = 1;
        }
        else if(i%2 == 1 && sum1 >= 0) {
            cnt1 += (1 + sum1);
            sum1 = -1;
        }           
    }

    long cnt2 = 0;
    long sum2 = 0;
    for(int i=0; i<n; ++i) {
        sum2 += a[i];
        if(i % 2 == 1 && sum2 <= 0) {
            cnt2 += (1 - sum2);
            sum2 = 1;
        }
        else if(i % 2 == 0 && sum2 >= 0) {
            cnt2 += (1 + sum2);
            sum2 = -1;
        }        
    }

    cout << min(cnt1, cnt2) << endl;
}

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

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;

int n, a[100005], b[100005];
int sum[100005];
LL tot;

int main()
{
	scanf("%d", &n);
	rep(i, n) scanf("%d%d", &a[i], &b[i]);
	rep(i, n) sum[i] = a[i] + b[i];
	rep(i, n) tot -= b[i];
	
	sort(sum, sum + n);
	reverse(sum, sum + n);
	rep(i, n) if(!(i & 1)) tot += sum[i];
	printf("%lld\n", tot);
	return 0;
}

Measured memory_bytes: 1408
n,l=gets.split.map(&:to_i)
s = Array.new(n+1)
sort = Array.new(n+1)
s[0] = ""
for i in 1..n
  s[i]= gets.chomp
end
sort = s.sort
for i in 1..n
  s[0]+=sort[i]
end

puts s[0]


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

int main(){

  int n;
  cin>>n;
  vector<int> data(n);
  
  for (int i=0;i<n;i++){
    cin>>data.at(i);
  }
  
  sort(data.begin(),data.end());
  
  int sum=0;
  
  for (int i=0;i<n-1;i++){
    sum+=data.at(i);
  }
  
  if (sum>data.at(n-1)){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
  
  
  
}
  













Measured memory_bytes: 256
<?php
  $str = trim(fgets(STDIN));
  $result = " ";
  while (true) {
    $ary = explode(" ", trim(fgets(STDIN)));
    $result = "  " . $result . join("  ", $ary) . "  ";
    if (join("", $ary) == "END_OF_TEXT") {
      $result = strtolower($result);
      $str = (' ' . strtolower($str) . ' ');
      print(substr_count($result, $str) . "\n");
      return;
    }
  }
?>

Measured memory_bytes: 6576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  //vector<ll> a(n);  rep(i, 0, n) cin >> a[i];
  
  //cout << n << "\n";
  
  cout << ( (s[0]=='7' or s[1]=='7' or s[2]=='7') ?"Yes" :"No") << "\n";
  
  //cout << fixed << setprecision(15) << n << "\n";

}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
	int A,B,C,X,Y;
	cin >> A >> B >> C >> X >> Y;
	int res;
	if ((A+B) < (2*C)) {
		res = (X*A) + (Y*B);
	}
	else {
		if (X < Y) {
			res = min((2*X*C)+((Y-X)*B),(2*Y*C));
		}
		else {
			res = min((2*Y*C)+((X-Y)*A),(2*X*C));
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int> 
using namespace std ; 
signed main(){
    fast;
    int n,d;
    cin>>n>>d;
    d = d*d;
    int ans = 0;
    for(int i = 1;i<=n;i++){
    	int x,y;
    	cin>>x>>y;
    	int dis = x*x + y*y;
    	if(dis<=d) ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
typedef long long int ll;
#define mod 1000000007
#define ln "\n"
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll,ll>
#define f first
#define s second
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
void solve(){
    ll n,i;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n,greater<ll>());
    ll sum=0;
    sum+=a[0];
    ll sum1=0;
    if(n%2==0){
      for(i=1;i<(n+1)/2;i++)
        sum1+=a[i];
    sum+=(2*sum1);
    }
    else{
        for(i=1;i<(n+1)/2-1;i++)
        sum1+=a[i];
    sum+=(2*sum1);
    sum+=a[(n+1)/2-1];
    }
    cout<<sum;
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fio;
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
int L[110];

int main() {
  int n,x;
  cin >> n >> x;
  
  for(int i= 0;i< n;i++){
    cin >> L[i];
  }
  
  int count = 0;
  int D[n];
  D[1] = 0;
  for(int i = 2;i < n+2;i++){
    D[i] = D[i-1] + L[i-2];
    if(D[i] <= x){
      count++;
    }
  }
  
  cout << count + 1 << endl;
  
}

Measured memory_bytes: 256
public class Main {
	
		
		public static void main(String[] args) {
			java.util.Scanner scan = new java.util.Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(-1000 <= a && b <= 1000){;
		if( a > b){;
		System.out.println("a > b");
		}
		if( a < b){;
		System.out.println("a < b");
		}
		if( a == b){;
		System.out.println("a == b");
		}
		}
		}	
			
		
	
	}

Measured memory_bytes: 26220
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int k = sc.nextInt();
		// スペース区切りの整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
        int r = 0;
		// 判定
		for(int i = a; i <= b; i ++){
			if(i % k == 0){
				System.out.print("OK");
				r = 1;
				break;
			}
		}
		if(r == 0){
            System.out.print("NG");
		}
	}
}

Measured memory_bytes: 35772
#include <bits/stdc++.h>
#define int long long 
#define double long double 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(a) (a).begin(),(a).end()

using namespace std;

signed main(){
	IOS;
	int n , m;
	cin >> n >> m ; 
	int ans = (n*(n-1))/2 + (m*(m-1))/2;
	cout << ans << endl ;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    for(int i = 0; i < min((long long)s.size(), k); i++){
        if(s[i] >= '2'){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << '1' << endl;
    return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;


const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	///cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	
	vector<int> wa(k+10, 0);
	int ans =0;
	rep2(a, 1, n+1) wa[a%k]++;
		
	ll as2= (ll)wa[0] *wa[0] *wa[0] ;
	if(k%2==0) as2 += (ll)wa[k/2] * wa[k/2] * wa[k/2];
	/*
	rep2(a, 1, n+1){
		rep2(b, 1, n+1)rep2(c, 1, n+1){
			if((a+b) %k ==0 && (c+b) %k ==0 && (a+c) %k ==0) ans++;
		}
	}*/
	/*cout << ans<<"\n";*/
	cout << as2<<"\n";
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
int top,c[1000];
void push(int x){
c[++top]=x;
}
int pop(){
top--;
return c[top+1];
}
int main(){
    int a,b;
    top=0;
    char c[100];
    while(scanf("%s,",c)!=EOF){
        if(c[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }
        else if(c[0]=='-'){
            b=pop();
            a=pop();
            push(a-b);
        }
        else if(c[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }
        else push(atoi(c));
    }
    printf("%d\n",pop());
    return 0;
}

Measured memory_bytes: 2740
var
	N,i,j,ans:int64;
begin
	read(N);
	i:=1;
	while i<=N do begin
		j:=N div(N div i)+1;
		inc(ans,(j-i)*(i+j-1)*(N div i)*(N div i+1)div 4);
		i:=j;
	end;
	writeln(ans);
end.

Measured memory_bytes: 1384
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
//const ll MOD = 998244353
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int H, W, K;
int s[300][300];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W >> K;
    memset(s, -1, sizeof(s));
    int hoge = 0;
    rep(i,H) rep(j,W) {
        char c; cin >> c;
        if (c == '#') s[i][j] = hoge++;
    }
    bool app = false;
    rep(i,H) {
        bool ex = false;
        rep(j,W) {
            if (s[i][j] != -1) {
                ex = true;
            }
        }
        if (!ex) {
            if (i != 0) {
                rep(j,W) {
                    s[i][j] = s[i-1][j];
                }
            }
            continue;
        }
        int now = -1;
        rep(j,W) {
            if (s[i][j] != -1) {
                now = s[i][j];
            } else {
                s[i][j] = now;
            }
        }
        now = -1;
        for (int j = W-1; j >= 0; j--) {
            if (s[i][j] != -1) {
                now = s[i][j];
            } else {
                s[i][j] = now;
            }
        }
    }
    for (int i = H-2; i >= 0; i--) {
        bool ex = false;
        rep(j,W) {
            if (s[i][j] != -1) {
                ex = true;
            }
        }
        if (!ex) {
            rep(j,W) {
                s[i][j] = s[i+1][j];
            }
            continue;
        }
    }
    rep(i,H) {
        rep(j,W) {
            cout << s[i][j]+1;
            if (j == W-1) cout << endl;
            else cout << " ";
        }
    }
}

Measured memory_bytes: 1152
from itertools import combinations
H, W, K = map(int, input().split())
C = [input() for _ in range(H)]
res = 0
for i in range(1 << H):
    for j in range(1 << W):
        tmp = 0
        for h in range(H):
            if (i >> h) & 1:
                continue
            for w in range(W):
                if (j >> w) & 1:
                    continue
                tmp += C[h][w] == '#'
        if tmp == K:
            res += 1
print(res)

Measured memory_bytes: 9148
// D - Dice in Line
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
double in(){double x;cin>>x;return x;}
int N,K;
vector<double> S(1);//累積和

int main(){
	cin>>N>>K;
	rp(i,0,N) S.push_back(S[i] + (in()+1)/2);
	double ans = 0;
	rp(i,0,N-K+1) ans = max(ans, S[i+K]-S[i]);
	printf("%.12f\n",ans);
}

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


int main() {
    int a,sum=0;
    rep(i,3){
        cin>>a;
        sum+=a;
    }
    cout << (sum>=22 ? "bust":"win") <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;


int main() {
	int n, t, a;
	double x, posi;
	cin >> n >> t >> a;
	int index = 0;
	double abst = 10000;

	for (int i = 0; i < n; ++i) {
		cin >> x;
		posi = double(t) - (x * 0.006);
		if (abst > fabs(a - posi)) {
			abst = fabs(a - posi);
			index = i ;
		}
	}
	cout << (index + 1);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;


int main() {
	int A,B,C,D;
	cin >> A >> B >> C >> D;
	if (A + B > C + D) cout << "Left" << endl;
	if (A + B == C + D) cout << "Balanced" << endl;
	if (A + B < C + D) cout << "Right" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int mapp[200005];

int main()
{
	int n,i,j,k,a;
	scanf("%lld",&n);
	for(i=0;i<n-1;i++)
	{
		scanf("%d",&a);
		mapp[a]++;
	}
	for(i=1;i<=n;i++)
	{
		printf("%d\n",mapp[i]);
	}
	return 0;
}

Measured memory_bytes: 4604
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;
vector<vector<string>> graph;

//38 A
int main(void) {
	ll h, w, a, b;
	cin >> h >> w >> a >> b;
	if (h < b * 2 || w < 2 * a)cout << "No" << endl;
	else {
		string f = "", s = "";
		rep(i, 0, a) {
			f += "0";
			s += "1";
		}
		rep(i, 0, w - a) {
			f += "1";
			s += "0";
		}
		rep(i, 0, b) {
			cout << f << endl;
		}
		rep(i, 0, h - b) {
			cout << s << endl;
		}
	}
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



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

    int n; cin >> n;
    vector<vector<int>> sched(n+1, vector<int>(n+1));
    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j < n-1; ++j) {
            cin >> sched[i][j];
        }
    }

    vector<int> index(n+1, 0);
    
    vector<int> next(n+1);
    for(int i = 1; i <=n; ++i) next[i] = sched[i][0];

    int rem = n*(n-1)/2, prev = 0, ans = 0;
    while(rem && rem != prev) {
        prev = rem;

        vector<int> used;
        for(int i = 1; i <= n; ++i) {
            if(i == next[next[i]]) {
                used.push_back(i);
            }
        }

        rem -= used.size()/2;
        for(int use : used) {
            index[use]++;
            if(index[use] == n-1) next[use] = -1;
            else next[use] = sched[use][index[use]];
        }

        ++ans;
    }

    if(rem) cout << -1 << endl;
    else cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 8192
#include<stdio.h>
#include<algorithm>

int km(int m, int n, int s) { //m～9の数から異なるn個を引っ張ってsとなる組み合わせを出力
	int i = 0;
	int count = 0;

	if (n == 1) {
		if (m <= s && s <= 9) { count=1; }
	}
	else {
		for (i = m; i <= 8; i++) {
			count += km(i + 1, n - 1, s - i);
		}
	}
	return count;
}

int main(void) {
	int n = 0;
	int s = 0;
	while (true) {
		n = 0;
		s = 0;

		scanf("%d %d", &n, &s);
		if (n == 0 && s == 0) { break; }

		printf("%d\n", km(0, n, s));

		
	}
	return 0;
}


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

int main()
{
	long long int a, b;
	cin >> a >> b;
	if(a > 0) --a;
	long long int x = (a + 1) / 2 % 2;
	long long int y = (b + 1) / 2 % 2;
	for(auto i = 1LL; (1LL << i) <= a; ++i){
		long long int bit = 1LL << (i + 1);
		x |= (((a % bit) / (1LL << i) * (((a % bit) + 1) % 2) << i));
	}
	for(auto i = 1LL; (1LL << i) <= b; ++i){
		long long int bit = 1LL << (i + 1);
		y |= (((b % bit) / (1LL << i) * (((b % bit) + 1) % 2) << i));
	}
	cout << (x ^ y) << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
def fact(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
if n==1:
    print(0)
    exit()

f = fact(n)
ans=0
for itm in f:
    p,num=itm
    nxt=1
    while num > 0:
        if nxt<=num:
            ans+=1
            num-=nxt
            nxt+=1
        else:
            break
print(ans)

Measured memory_bytes: 63200
import bisect
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort()
B.sort()
C.sort()
ans=0
for b in B:
  aidx=bisect.bisect_left(A,b)
  cidx=bisect.bisect_right(C,b)
  ans+=aidx*(len(C)-cidx)
print(ans)

Measured memory_bytes: 23232
#include <iostream>

using namespace std;

int sumof2(int n) {
  int sum = 0;
  int tmp = n;

  while(true) {
    if ((tmp % 2) == 0) {
      sum++;
      tmp /= 2;
      continue;
    }
    break;
  }
  return sum;
}

int main() {
  int n;
  cin >> n;
  int sum = 0;
  for(int i=0; i<n; i++) {
    int tmp;
    cin >> tmp;
    sum += sumof2(tmp);
  } 

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <bitset>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;

using Pos = pair<int, int>;
using PosList = vector<Pos>;
using Lengths = vector<double>;
using Used = bitset<10>;

Lengths resultLengths;

double distance(const Pos &a, const Pos &b)
{
  double sq = (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second);
  return sqrt(sq);
}

void recur(const PosList &pss, Used used, PosList poslist, int N)
{
  if (poslist.size() == N)
  {
    double d = 0;
    for (int i = 1; i < poslist.size(); ++i)
    {
      auto p1 = poslist[i - 1];
      auto p2 = poslist[i];
      d += distance(p1, p2);
    }
    resultLengths.push_back(d);
    return;
  }

  for (int i = 0; i < N; ++i)
  {
    if (used.test(i))
    {
      continue;
    }
    Used nextUsed(used);
    nextUsed.set(i);
    PosList next(poslist);
    next.push_back(pss[i]);
    recur(pss, nextUsed, next, N);
  }
}

int main()
{
  int n;
  cin >> n;
  int x, y;
  PosList poslist;
  for (int i = 0; i < n; ++i)
  {
    cin >> x >> y;
    poslist.push_back(Pos(x, y));
  }

  Used used;
  PosList ps;
  recur(poslist, used, ps, n);

  double td = 0;
  for (auto d : resultLengths)
  {
    td += d;
  }
  td /= resultLengths.size();
  //cout << "n : " << n << endl;
  //cout << "n! : " << resultLengths.size() << endl;
  cout << std::setprecision(16) << td << endl;

  return 0;
}


Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
#define int long long 
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    string s;
    cin >> s;
    int cnt=0,ans=0;

    vector<int>pos;
    for(int i=0;i<s.length();i++){
        if(s[i]=='W')pos.push_back(i);
    }

    for(int i=0;i<pos.size();i++){
        ans+=pos[i]-i;
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 5320