akhauriyash/Code-Regression huggingface dataset:
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
# mod = 998244353
# mod = 10 ** 9 + 9
mod = 10 ** 9 + 7
PI = Math::PI
dx = [ 1,  0, -1,  0,  1,  1, -1, -1]
dy = [ 0,  1,  0, -1,  1, -1,  1, -1]
eight = [0, 1, 1, 0, -1, -1, 1, -1, 0]
def max(a,b);       a > b ? a : b                              end
def min(a,b);       a < b ?  a : b                             end
def swap(a,b);      a, b = b, a                                end
def gi;             gets.to_s.to_i                             end
def gf;             gets.to_s.to_f                             end
def gs;             gets.to_s.chomp                            end
def gmi(n=nil); n.nil? ? gets.to_s.split.map{|t|t.to_i} : n.times.map{ gets.to_s.to_i } end
def gmf(n=nil); n.nil? ? gets.to_s.split.map{|t|t.to_f} : n.times.map{ gets.to_s.to_f } end
def gms(n=nil); n.nil? ? gets.to_s.split : n.times.map{ gets.to_s.chomp } end
def ga2i(h);        h.times.map{ gets.to_s.split.map{|t|t.to_i} }      end
def gm(h);        Array.new(h){ gets.to_s.split.map{|t|t.to_i} }      end
def yn(f); puts f ? "Yes" : "No" end
#def YN(f); puts f ? "YES" : "NO" end
def yes(f=nil); f.nil? ? (puts "Yes"; exit) : (puts f ? "Yes" : "No") end
def no(f=nil); f.nil? ? (puts "No"; exit) : (puts f ? "Yes" : "No") end
def yay(f=nil); f.nil? ? (puts "Yay!"; exit) : (puts f ? "Yay!" : ":(") end

#n = gets.to_s.to_i
#a = gets.to_s.split.map{|e|e.to_i}
#m = Array.new(n){ gets.to_s.split.map{|e|e.to_i} }
s = gets.to_s.chomp
t = gets.to_s.chomp

yn(s == t[0, s.size])
  






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

int main()
{
    cout << fixed << setprecision(10);

    int n;
    double s, sum1, sum2, ave, ave2, d;

    while(1)
    {
        cin >> n;
        if(n==0) break;
 

        sum1 = 0, sum2 = 0;
        for(int i=0; i<n; i++)
        {
            cin >> s;
            sum1 += s;
            s = s * s;
            sum2 += s;
        }
        ave = sum1/n;
        ave2 = sum2/n;

        d = sqrt(ave2 - ave*ave);
        
        cout << d << endl;
       /* cout << sum1 << endl;
        cout << sum2 << endl;
        cout << ave << endl;
        cout << ave2 << endl;*/
    }
    return 0;
}


Measured memory_bytes: 3276
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	long long n, a, b;
	cin >> n >> a >> b;
	if(a+b>=n) {
		cout << min(n, a);
		exit(0);
	}
	cout << a * (n/(a+b)) + min(a, (n % (a+b)));

	return 0;
}


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

int main(void){
    int n;
    cin >> n;
    int xa = 0;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
        xa ^= a[i]; 
    }
    rep(i, n){
        int ans = xa ^ a[i];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3984
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n, K; cin >> n >> K;
  vector<ll> a(n); cin >> a;
  vector<bool> dp(K+1, false);
  rep(i, 1, K+1) {
    each(x, a) {
      if (i >= x && !dp[i-x]) {
        dp[i] = true;
      }
    }
  }
  if (dp[K]) {
    cout << "First" << endl;
  }
  else {
    cout << "Second" << endl;
  }
}


Measured memory_bytes: 256
class node:
    def __init__(self, key):
        self.k = key
        self.p = None
        self.l = None
        self.r = None

def preParse(u):
    if u == None:
        return
    print(" " + str(u.k), end = '')
    preParse(u.l)
    preParse(u.r)

def inParse(u):
    if u == None:
        return
    inParse(u.l)
    print(" " + str(u.k), end = '')
    inParse(u.r)

def postParse(u):
    if u == None:
        return
    postParse(u.l)
    postParse(u.r)
    print(" " + str(u.k), end = '')

root = None
def insert(k):
    global root
    parent = None
    u = root
    z = node(k)
    while u != None:
        parent = u
        if z.k < u.k:
            u = u.l
        else:
            u = u.r

    z.p = parent
    if parent == None:
        root = z
    elif z.k < parent.k:
        parent.l = z
    else:
        parent.r = z

def find(k):
    global root
    u = root
    while u != None and u.k != k:
        if k < u.k:
            u = u.l
        else:
            u = u.r
    return u

def delete (k):
    global root
    u = find(k)
    if u.l == None or u.r == None:
        y = u
    else:
        y = getSuccessor(u)

    if y.l != None:
        x = y.l
    else:
        x = y.r

    if x != None:
        x.p = y.p

    if y.p == None:
        root = x
    elif y == y.p.l:
        y.p.l = x
    else:
        y.p.r = x

    if y != u:
        u.k = y.k

def getSuccessor(z):
    if z.r != None:
        return getMinimum(z.r)
    
    y = z.p
    while y != None and z == y.r:
        z = y
        y = y.p
    return y

def getMinimum(z):
    while z.l != None:
        z = z.l
    return z

n = int(input())
cmdList = [input() for _ in range(n)]

for cmd in cmdList:
    if cmd[0] == "p":
        inParse(root)
        print("")
        preParse(root)
        print("")
    elif cmd[0] == "f":
        print("no" if find(int(cmd[5:])) == None else "yes")
    elif cmd[0] == "d":
        a = 1
        delete(int(cmd[7:]))
    else:
        insert(int(cmd[7:]))


Measured memory_bytes: 121200
_, _, M = map(int, input().split())
# price list
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
# min price
min_price = min(a_list) + min(b_list)
for _ in range(M):
  x, y, c = map(int, input().split())
  discount_price = a_list[x-1] + b_list[y-1] - c
  min_price = min(min_price, discount_price)
print(min_price)

Measured memory_bytes: 18608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long inf = 1000000000000;
int main() {
	int n, k, s;
	cin >> n >> k >> s;
	if (k == 0) {
		for (int i = 0; i < n; i++) {
			cout << s - 1 << " ";
		}
		return(0);
	}
	else if (n == k) {
		for (int i = 0; i < n; i++) {
			cout << s << " ";
		}
		return(0);
	}
	else {
		int now = 1;
		while(now <= k) {
			cout << s << " ";
			now++;
		}
		while (now <= n) {
			if (s == 2 || s==1) cout << s + 1 << " ";
			else cout << s - 1 << " ";
			now++;
		}
	}
	return(0);
}

Measured memory_bytes: 1280
#include <queue>
#include <cstdio>
#include <vector>
 
#define INF (1 << 23)
 
using namespace std;

void reader(int *x)
{
    int k = getchar_unlocked(); *x = k - '0';
    
    while(true)
    {
        k = getchar_unlocked();
        
        if(k < '0' || k > '9') break;
        
        *x = ((*x) << 1) + ((*x) << 3) + k - '0';
    }
}

char memarr[17000000]; void *mem = memarr;
 
int main()
{
    int N, M, s, t, u, v;
 
    reader(&N);
    reader(&M);
    reader(&s); s--;
    reader(&t); t--;
 
    vector<vector<int> > G(N);
 
    for (int i = 0; i < M; i++)
    {
        reader(&u);
        reader(&v);
 
        G[u - 1].push_back(v - 1);
        G[v - 1].push_back(u - 1);
    }
 
    vector<int> d1(N, INF); d1[s] = 0;
    vector<int> d2(N, INF); d2[t] = 0;
 
    queue<int> que;
 
    que.push(s);
 
    while (!que.empty())
    {
        int node = que.front(); que.pop();
 
        for (int i = 0; i < G[node].size(); i++)
        {
            if (d1[G[node][i]] == INF)
            {
                d1[G[node][i]] = d1[node] + 1; que.push(G[node][i]);
            }
        }
    }
 
    que.push(t);
 
    while (!que.empty())
    {
        int node = que.front(); que.pop();
 
        for (int i = 0; i < G[node].size(); i++)
        {
            if (d2[G[node][i]] == INF)
            {
                d2[G[node][i]] = d2[node] + 1; que.push(G[node][i]);
            }
        }
    }
 
    int shortest = d1[t];
 
    vector<int> r1(shortest - 1, 0); for (int i = 0; i < N; i++) { if (d1[i] < shortest - 1) r1[d1[i]]++; }
    vector<int> r2(shortest - 1, 0); for (int i = 0; i < N; i++) { if (d2[i] < shortest - 1) r2[d2[i]]++; }
 
    long long ret = 0;
 
    for (int i = 0; i < shortest - 1; i++) ret += 1LL * r1[i] * r2[shortest - i - 2];
     
    printf("%lld\n", ret);
 
    return 0;
}

Measured memory_bytes: 9600
import heapq

n,m  = map(int,input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)

for _ in range(m):
    tmax = heapq.heappop(a)
    tmax = -(-tmax //2)
    heapq.heappush(a,tmax)

print(-1*sum(a))

Measured memory_bytes: 14224
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
#include<iomanip>
#include<bitset>
#define mod 1000000007
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mad(a,b) a=(a+b)%mod
#define mul(a,b) a=a*b%mod

#define N 60
ll n,a[200010],rnd[200010];
int main(){
    cin>>n;
    for(int i=0;i<=n;i++)rnd[i]=i;
    bool ok=1;
    for(ll i=0;i<n;i++){
	cin>>a[i];
	a[i]-=i;
	if(a[i]>0){ ok=0; break;}
	chmax(rnd[-a[i]],i);
    }
    for(int i=0;i<n-1;i++){
	if(a[i]<a[i+1])ok=0;
    }
    ll ans=0;
    for(int i=0;i<=n;i++){
	ans+=rnd[i]-i;
    }
    if(ok==1)cout<<ans<<endl;
    else cout<<-1<<endl;
}



Measured memory_bytes: 3328
N = int(input())

if N < 2:
    ans = 1
elif N < 4:
    ans = 2
elif N < 8:
    ans = 4
elif N < 16:
    ans = 8
elif N < 32:
    ans = 16
elif N < 64:
    ans = 32
else:
    ans = 64

print(ans)

Measured memory_bytes: 3060
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
long double dp[(1 << 21)];
long double dist(tuple<long double, long double, long double> a, tuple<long double, long double, long double> b) {
	return pow(get<0>(a) - get<0>(b), 2.0) + pow(get<1>(a) - get<1>(b), 2.0) + pow(get<2>(a) - get<2>(b), 2.0);
}
void solve() {
	int n, m;
	cin >> n >> m;
	vector<tuple<long double, long double, long double>> inputs;
	REP(i, n) {
		long double a, b, c;
		cin >> a >> b >> c;
		inputs.push_back(make_tuple(a, b, c));
	}
	long double ans = 0;
	REP(i, (1 << n)) {
		int cnt = 0;
		for (int q = 0; q < inputs.size(); ++q) {
			if (i & (1 << q)) {
				cnt++;
				continue;
			}
			long double tmp = dp[i];
			REP(j, inputs.size()) {
				if (i & (1 << j)) {
					tmp += dist(inputs[q], inputs[j]);
				}
			}
			dp[i + (1 << q)] = max(dp[i + (1 << q)], tmp);
		}
		if (cnt == m) {
			ans = max(ans, dp[i]);
		}
	}
	cout << ans << endl;
}
#undef int
int main() {
	init();
	solve();
}


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

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

    int a, b;
    for (a = -120; a <= 120; a++)
        for (b = -120; b <= 120; b++)
            if (a * a * a * a * a - b * b * b * b * b == x)
            {
                cout << a << " " << b << endl;
                return 0;
            }
}

Measured memory_bytes: 3592
#include <iostream>
// #include <string>
// #include <cstdio>
// #include <functional>
#include <algorithm>
#include <vector>
// #include <stack>
// #include <cmath>
// #include <climits>
// #include <bitset>
// #include <array>
using namespace std;
typedef long long ll;

int V, Mod;
vector<vector<int>> es;
vector<int> par;
vector<ll> dp0, dp1;

void erase(vector<int>& v, int x) { v.erase(remove(v.begin(), v.end(), x), v.end()); }

void dfs1(int u, int p)
{
	par[u] = p;
	erase(es[u], p);
	for (int v : es[u]) dfs1(v, u);
}

// par[0]=-1 は常に白とする
// dp0[u]=(uを黒, par[u]を白に塗る場合の数)
ll dfs2(int u)
{
	dp0[u] = 1L;
	for (int v : es[u]) dp0[u] = dp0[u] * (dfs2(v) + 1) % Mod;
	return dp0[u];
}

// dp1[u]=(uを白, par[u]を黒に塗る場合の数)
void dfs3(int u)
{
	int W = es[u].size();
	vector<ll> x(W + 1, 1);
	vector<ll> y(W + 1, 1);
	for (int i = 0; i < W; i++) x[i + 1] = x[i] * (dp0[es[u][i]] + 1) % Mod; // 前からの累積積, x[i] = t[0]*...*t[i-1]
	for (int i = W - 1; i >= 0; i--) y[i] = y[i + 1] * (dp0[es[u][i]] + 1) % Mod; // 後ろからの累積積, y[i] = t[i]*...*t[W-1]
	for (int i = 0; i < W; i++) dp1[es[u][i]] = (dp1[u] + 1) * x[i] % Mod * y[i + 1] % Mod;
	for (int v : es[u]) dfs3(v);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> V >> Mod;
	for (int i = 0; i < V; i++) { es.emplace_back(vector<int>()); par.emplace_back(0); dp0.emplace_back(0); dp1.emplace_back(0); }
	for (int i = 0; i < V - 1; i++)
	{
		int x, y; cin >> x >> y;
		es[x - 1].push_back(y - 1);
		es[y - 1].push_back(x - 1);
	}
	dfs1(0, -1);
	dfs2(0);
	dfs3(0);
	for (int u = 0; u < V; u++) cout << dp0[u] * (dp1[u] + 1) % Mod << endl;
    return 0;
}


Measured memory_bytes: 18860
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		int ans = Integer.MAX_VALUE;
		for(int i = -100 ; i <= 100 ; i++) {
			int temp = 0;
			for(int j = 0 ; j < n ; j++) {
				temp += (i - a[j]) * (i - a[j]);
			}
			ans = Math.min(ans, temp);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

#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 REPO(i, n) for(int i = 1;i <= n;i++)
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define ll long long
#define MOD 1000000007

ll a, b, c, d;
int main() {
	cin >> a >> b >> c >> d;
	cout << (a * b > c * d ? a * b : c * d) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <cmath>
#define JJBBLLLL long long int
#define JJBBLLLNOTPLUS int
using namespace std;
JJBBLLLNOTPLUS NiasduhaiusbisudfbusbdiausbdajksdkasjbdkjjasbdkasbdkajsbdakjsjbdqkndjUIIBIUBIUBIUBIUBUBIUBIBdiuadiuabsudbaiusdbausbIUBIUBIUBAsd(JJBBLLLNOTPLUS cifang,JJBBLLLNOTPLUS shu)//就是不喜欢用pow函数。
{
    JJBBLLLL CNOiasdubisubdfubidubasudbaiusbdiasbubaifubuiBIUBIUABSIUSBASIUDBIUABSDbiu12bu3biubIUBIUBAIUSBDiub=1;
    for (JJBBLLLNOTPLUS i=1;i<=cifang;i++)
        CNOiasdubisubdfubidubasudbaiusbdiasbubaifubuiBIUBIUABSIUSBASIUDBIUABSDbiu12bu3biubIUBIUBAIUSBDiub*=shu;
    return CNOiasdubisubdfubidubasudbaiusbdiasbubaifubuiBIUBIUABSIUSBASIUDBIUABSDbiu12bu3biubIUBIUBAIUSBDiub;
}
JJBBLLLNOTPLUS UBABISBIUBIUBIUBIUBDIUBAISUBDIUABSIDUBIAUBSIDUBIUABSCIUBIAUBSIUBDuhiuhaushiduhaiusubIUBASIUBCIBUAIUSBCIUABSICUBIASBCU12812222222222222222222222222222222222222222222222222222222222333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333(JJBBLLLNOTPLUS x)
{
    JJBBLLLNOTPLUS num=0;
    while (x)
    {
        num++;
        x/=10;
    }
    return num;
}
JJBBLLLNOTPLUS main()
{
    JJBBLLLNOTPLUS UIBIUBIABSUIDBIUASIUDBIAUSBDIUABSiDUBASIubaisubdiuasbdiuabsdiuabsdiausbdu111,b;
    cin>>UIBIUBIABSUIDBIUASIUDBIAUSBDIUABSiDUBASIubaisubdiuasbdiuabsdiuabsdiausbdu111>>b;
    JJBBLLLL s;
    s=UIBIUBIABSUIDBIUASIUDBIAUSBDIUABSiDUBASIubaisubdiuasbdiuabsdiuabsdiausbdu111*NiasduhaiusbisudfbusbdiausbdajksdkasjbdkjjasbdkasbdkajsbdakjsjbdqkndjUIIBIUBIUBIUBIUBUBIUBIBdiuadiuabsudbaiusdbausbIUBIUBIUBAsd(UBABISBIUBIUBIUBIUBDIUBAISUBDIUABSIDUBIAUBSIDUBIUABSCIUBIAUBSIUBDuhiuhaushiduhaiusubIUBASIUBCIBUAIUSBCIUABSICUBIASBCU12812222222222222222222222222222222222222222222222222222222222333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333(b),10);//位值原理。
    s+=b;
    JJBBLLLNOTPLUS g=sqrt(s);
    if (g*g==s)//判断是否为平方数。
        cout<<"Yes\n";//要换行。
    else
        cout<<"No\n";//要换行。
    return 0;//完美100AC的结束了。
} 

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll N, K;
ll H[200010];

int main()
{
  scanf( "%lld%lld", &N, &K );
  rep( i, N )
    scanf( "%lld", H+i );

  std::sort( H, H+N );

  ll ans = 0;
  rep( i, N-K )
    ans += H[i];

  printf( "%lld\n", ans );

  return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

int n;
string s;
map<int, char> mp;

string::const_iterator iter, end_;
string ans;

void consume(char ex) {
  assert(ex == *iter);
  iter++;
}

bool consume_if(char ex) {
  if(ex == *iter) { consume(ex); return true; }
  return false;
}


void rec(deque<char>& res, int qcnt = 0) {

  int prog = 0;
  while(iter != end_) {
    if(isalpha(*iter)) {
      res.push_back(char((*iter - 'A' + prog) % 26 + 'A'));
      consume(*iter);
      prog = 0;
    }
    else if(consume_if('+')) {
      prog ++;
    }
    else if(consume_if('-')) {
      prog --;
      if(prog < 0) prog = 25;
    }
    else if(consume_if('[')) {
      int pos = res.size();
      rec(res);
      assert(pos < (int)res.size());
      reverse(res.begin() + pos, res.end());
    }
    else if(consume_if(']')) {
      return;
    }
    else if(consume_if('?')) {
      prog = 0;
      res.push_back(mp[qcnt]);
      qcnt ++;
    }
  }

  if(iter == end_) {
    string x;
    rep(i, res.size()) {
      x.push_back(res[i]);
    }
    ans = min(ans, x);
  }
  
}

int main() {

  while(1) {
    cin >> s;
    if(s == ".") break;
    ans = string(88, 'Z');
    
    n = s.size();
    vector<int> qs;
    rep(i, n) {
      if(s[i] == '?') {
	qs.push_back(i);
      }
    }
    
    rep(i, pow(26, qs.size())) {
      mp.clear();
      int k = i;
      rep(j, qs.size()) {
	mp[j] = char('A' + (k % 26));
	k /= 26;
      }
      iter = s.begin(), end_ = s.end();
      deque<char> d;
      rec(d);
    }
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1268
using System;
using System.Collections.Generic;
using System.Linq;

class Program{

  static int ans;
  static int a;
  static int b;

  static int Main() {

    string[] nyu = Console.ReadLine().Split(' ');
    a = int.Parse(nyu[0]);
    b = int.Parse(nyu[1]);

    // ここまで入力

    int[] score = new int[3];
    score[0] = a * 2 - 1;
    score[1] = b * 2 - 1;
    score[2] = a + b;

    ans = score.Max();

    Console.WriteLine("{0}", ans);

    return 0;
  }

}


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

int main(){
	string s,ans = "None";
	int alpha[123] = {0};
	cin >> s;
	
	for(int i=0;i<s.size();i++){
		alpha[s[i]]++;
	}
	
	for(char ch = 'a';ch<= 'z';ch++){
		if(alpha[ch] == 0){
			ans = ch;
			break;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for i in range(N)]
XH.sort()
from math import ceil
times = ceil(XH[0][1]/A)
ans = times
damege = [times*A]
coor = [XH[0][0]+2*D]
start = 0
end = 1
dam = sum(damege[start:end])
for i in range(1,N):
    st = start
    while start < end and coor[start] < XH[i][0]:
        start += 1
    dam -= sum(damege[st:start])
    H = XH[i][1] - dam
    if H > 0:
        times = ceil(H/A)
        ans += times
        damege.append(times*A)
        dam += times*A
        coor.append(XH[i][0]+2*D)
        end += 1
print(ans)

Measured memory_bytes: 62556
#66
s = input()
if len(s)%2==1:
    s = s[:len(s)-1]
else:
    s = s[:len(s)-2]
x = int(len(s)/2)

if s[:x]==s[x:]:
    print(2*x)
else:
    while s[:x]!=s[x:]:
        s = s[:len(s)-2]
        x -=1
    print(2*x)

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

int main() {
  int A,B,C;
  int count = 0;
  cin >> A >> B >> C;
  if(B >= A){
  	for (int i = A; i <= B; i = i + A) {
      if(count == C){
        break;
   	  }
      ++count;
  	}
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

int main()
{
	long long int i, j, k, l, m,N,X,H,M,W, n,A,B, sum, flag, cc, cnt;
	sum = 0;
	flag = 1;
	cin >> N >> M>>k;
	for (i = 0; i <= M; i++) {
		for (j = 0; j <= N; j++) {
			if (i*N + j * M - 2*i * j == k) {
				flag = 0;
				break;
			}
		}
	}
	if (flag == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;






    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using P = pair<int,int>;

int main(){
    int n;
    cin >> n;
    vi a(n);
    ll sum = 0, ans = 0, mod = 1e9+7;
    rep(i,n) cin >> a[i];
    rep(i,n-1){
        sum = (sum + a[i])%mod;
        ans = (ans + sum*a[i+1])%mod;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int n,ans=INT_MAX;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  for(int i=-100;i<=100;i++)
  {
    int cost=0;
    for(int j=0;j<v.size();j++)
      cost=cost+pow(i-v[j],2);
    if(cost<ans)
      ans=cost;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            while(true){
                int n = sc.nextInt();
                if(n==0){break;}
                int max=0,min=0,fscore=0;
                int[] score = new int[n];

                for (int i = 0; i < n; i++) {
                    score[i] = sc.nextInt();
                }


                for(int i =0; i<n;i++){

                    if (score[max]<score[i]){
                        max=i;
                    }
                    if (score[min]>score[i]){
                        min=i;
                    }
                }
                for(int i=0;i<n;i++){
                    fscore += score[i];
                }

                fscore = (fscore-(score[max]+score[min]))/(n-2);
                System.out.println(fscore);
            }
        }
    }
}



Measured memory_bytes: 28856
N = int(input())
A = list(map(int,input().split()))

sep = 400
flag = [False]*8
c = 0
for a in A:
    s = a//sep
    if s >= 8:
        c += 1
    else:
        flag[s] = True

min = flag.count(True)
max = min + c
if min == 0:
    min = 1
print("{0} {1}".format(min,max))



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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const ll INF = 10000000000;

int main() {
	int N;
	cin >> N;
	int cnt[100001] = {};
	rep(i, N) {
		int a;
		cin >> a;
		if(a!=0)cnt[a - 1]++;
		cnt[a]++;
		if(a!=100000)cnt[a + 1]++;
	}
	int ans = 0;
	rep(i, 100001) {
		ans = max(ans, cnt[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>


void insertionSort(int A[], int N) {
	int i, j, k, v;


	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		printf("%d", A[i]);
		if (i == N - 1) {
			printf("\n");
		} else {
			printf(" ");
		}
	}

	for (i = 1; i < N; i++){
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v){
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;

		for (k = 0; k < N; k++) {
			printf("%d", A[k]);
			if (k == N - 1) {
				printf("\n");
			} else {
				printf(" ");
			}
		}
	}
}


int main() {
	int A[1000], N;

	scanf("%d", &N);
	insertionSort(A, N);

	return 0;
}

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

int main(){
    ll n,w; cin >> n >> w;
    vector<pair<ll , ll>> pro(n);
    for(int i=0; i<n; i++){
        ll wei,val; cin >> wei >> val;
        pro[i].first = wei;
        pro[i].second = val;
    }

    // 要素数：重み　、　要素が合計の価値
    ll dp[n+1][w+1] = {};
    

    for(int i=0; i<n; i++){
        for(int j=0; j<=w; j++){
            if(j >= pro[i].first){
                dp[i+1][j] = max(dp[i][j],dp[i][j-pro[i].first]+pro[i].second);
            }
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
        }
    }

    cout << dp[n][w] << endl;
}

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

using namespace std;

const int MAX_NM = 50;
const long long INF = (1LL<<32);

long long d[MAX_NM][MAX_NM];
int n, m;


int main(int argc, char const *argv[]) {
  cin >> n >> m;
  vector<pair<int,int>> pairs;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      d[i][j] = ((i==j) ? 0 : INF);
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    d[a][b] = 1;
    d[b][a] = 1;
    pairs.push_back(make_pair(a,b));
  }

  long long ans = 0;
  for (int i = 0; i < pairs.size(); i++) {
    int a = pairs[i].first, b = pairs[i].second;
    long long temp[n][n];
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        temp[j][k] = d[j][k];
      }
    }
    temp[a][b] = INF; temp[b][a] = INF;
    for (int k = 0; k < n; k++) {
      for (int i = 0; i < n; i++) {
        if (temp[i][k] == INF) continue;
        for (int j = 0; j < n; j++) {
          if (temp[k][j]==INF) continue;
          temp[i][j] = min(temp[i][j], temp[i][k]+temp[k][j]);
        }
      }
    }
    bool tf = true;
    for (int v = 1; v < n; v++) {
      if (temp[0][v]==INF) tf = false;
    }
    if (!tf) ans++;
  }
  cout << ans << endl;

  return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

lint V[3005][3005];
lint dp[3005][3005][4];

int main(){
    int R,C,K; cin>>R>>C>>K;
    rep(i, K){
        lint r,c,v; cin >>r>>c>>v;
        V[r][c] = v;
    }

    repn(i, R) repn(j, C) rep(k, 4){
        if(k==0){
            dp[i][j][0] = max({dp[i-1][j][3], dp[i][j-1][0]});
        }
        else{
            dp[i][j][k] = max({dp[i][j][k-1], dp[i-1][j][3], dp[i][j-1][k-1]+V[i][j], dp[i][j-1][k]});
            if(k == 1){
                dp[i][j][1] = max(dp[i][j][1], dp[i-1][j][3] + V[i][j]);
            }
        }
    }
    
    out(dp[R][C][3]);
}


Measured memory_bytes: 355744
#include <stdio.h>
#include <stdint.h>

int main(void)
{
    uint32_t a, b, c;
    scanf("%u %u %u", &a, &b, &c);
    if (b-a == c-b) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }   
    return 0;
}

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

using namespace std;

typedef unsigned long long ull ;

ull N , M , A , R , C, H ;

int main(void){
  cin >> N ;
  for(ull i = 0; i < N; i++){
    string str ;
    cin >> str ;
    switch (str[0]) {
      case 'M' : M++ ; break ;
      case 'A' : A++ ; break ;
      case 'R' : R++ ;break ;
      case 'C' : C++ ;break ;
      case 'H' : H++ ;break ;
    }
}

ull L[5] ;
L[0] = M ;
L[1] = A ;
L[2] = R ;
L[3] = C ;
L[4] = H ;

ull ans = 0;

for(int i = 0 ; i < 5 ; i++){
  for(int j = i + 1; j < 5; j++){
    for(int k = j + 1; k < 5 ; k++){
      ans += L[i]*L[j]*L[k] ;
    }
  }
}

cout << ans << endl ;


return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  long long h, w;
  cin >> n >> h >> w;
  int ans = 0;
  for(int i = 0; i < n; i++){
    long long a, b;
    cin >> a >> b;
    if(a >= h && b >= w) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const A = parseInt(args[0][0], 10)
	const B = parseInt(args[0][1], 10)

	const t1 = A - (B * 2)

	if (t1 < 0) console.log(0)
	else console.log(t1)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21064
#include<iostream>
#include<algorithm>
#include<vector>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

int main()
{
  int ans[1000000],n; 
  while(cin >> n,n)
    {
      vector<int> vec;
      rep(i,(int)((n-1)/2)+1)ans[i] = 0;
      REP(i,1,n)vec.push_back((i*i)%n);
      sort(vec.begin(),vec.end()); 
      vec.erase(unique(vec.begin(),vec.end()),vec.end());
      rep(i,vec.size())
	{
	  rep(j,vec.size())
	    {
	      int diff = vec[i] - vec[j];
	      if(diff < 0)diff += n;
	      if(diff > (n-1)/2)diff = n - diff;
	      if(1 <= diff && diff <= (n-1)/2)ans[diff]++;
	    }
	}
      REP(i,1,(int)((n-1)/2)+1)cout << ans[i] << endl;
    }
  return 0;
}

Measured memory_bytes: 1352
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for(int i = 0; i < n - 1; i++)
    {
        if(s[i] != s[i + 1])
        {
            ans++;
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3356
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int>* adj;
int* c;

void recurse(int v, int pv, int s){ 
    c[v] += s;
    for(auto& i : adj[v]){
        if(i != pv){
            recurse(i, v, c[v]);
        }
    }
}

int main(){
    int n, q, a, b;
    cin >> n >> q;
    adj = new vector<int>[n];
    c = new int[n];
    for(int i = 0; i < n; i++)c[i] = 0;
    for(int i = 0; i < n-1; i++){
        cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int j = 0; j < q; j++){
        cin >> a >> b;
        c[a-1] += b;
    }
    recurse(0, 0, 0);
    for(int i = 0; i < n; i++)cout << c[i] << ' ';
    cout << '\n';
}


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

int main() {
	int n;
	cin>>n;
	char c[n];
	for(int i=0;i<n;i++)cin>>c[i];
	int x=1;
	for(int i=1;i<n;i++){
		if(c[i]!=c[i-1])x++;
	}
	cout<<x<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>

using namespace std;
const double PI = acos(-1.0);

int main() {
    int A, B;
    char s[333];
    cin>>A>>B>>s;
    int yes = 1;
    for(int i = 0;i < A + B + 1 && yes;i++) {
        if(i != A && '0' <= s[i] && s[i] <= '9');
        else if(i == A && s[i] == '-');
        else yes = 0;
    }
    if(yes) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)


def dfs(n, rest):
    global C, N
    rst = 0
    if maxR[n] > 0:
        rst = maxR[n]
    elif rest >= C and S[n] == 'o':
        rst += 1
        if n + (C + 1) < N:
            rst += dfs(n + C + 1, C)
    else:
        if n + 1 < N:
            rst += dfs(n + 1, rest + 1)
    maxR[n] = rst
    return rst


def dfs2(n, rest):
    global C, N
    rst = 0
    if maxL[n] > 0:
        rst = maxL[n]
    elif rest >= C and S[n] == 'o':
        rst += 1
        if n - (C + 1) >= 0:
            rst += dfs2(n - (C + 1), C)
    else:
        if n - 1 >= 0:
            rst += dfs2(n - 1, rest + 1)
    maxL[n] = rst
    return rst


N, K, C = map(int, input().split())
S = input()
maxR = [-1] * N
for i in range(N):
    if S[i] == 'o' and maxR[i] == -1:
        maxR[i] = dfs(i, C)

if maxR[-1] == -1:
    maxR[-1] = 0
for i in range(N - 2, -1, -1):
    if maxR[i] == -1:
        maxR[i] = maxR[i + 1]

maxL = [-1] * N
for i in range(N - 1, -1, -1):
    if S[i] == 'o' and maxL[i] == -1:
        maxL[i] = dfs2(i, C)

if maxL[0] == -1:
    maxL[0] = 0
for i in range(1, N):
    if maxL[i] == -1:
        maxL[i] = maxL[i - 1]

ans = []
for i in range(N):
    r = maxR[i + 1] if i + 1 < N else 0
    l = maxL[i - 1] if i - 1 >= 0 else 0
    if r + l < K:
        ans.append(i + 1)

print(*ans, sep='\n')


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

int main() {
    int n;
    long long l;
    cin >> n >> l;
    vector<long long> a(n); 
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }

    long long maximum = 0;
    int index = 0;
    for (int i = 0; i < n - 1; i++) {
        if (maximum < a.at(i) + a.at(i + 1)) {
            maximum = a.at(i) + a.at(i + 1);
            index = i + 1;
        }
    }

    if (maximum < l) {
        cout << "Impossible" << endl;
        return 0;
    }
    
    cout << "Possible" << endl;
    for (int i = 1; i < index; i++) {
        cout << i << endl;
    }
    for (int i = n - 1; i >= index + 1; i--) {
        cout << i << endl;
    }
    cout << index << endl;
}

Measured memory_bytes: 1664
#include <stdio.h>
int main(){
	int i,j,k=0,n,l;scanf("%d",&n);
	for(i=1;i<=n;i+=2){
	l=0;
	for(j=1;j<=i;j++){
	if(i%j==0)l++;
	}
	if(l==8)k++;
	}
	printf("%d",k);
	return 0;
}

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

typedef long long ll;

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

	const int MAX_X = 3500;
	int h, n;
	ll w;
	for (int i = 1; i <= MAX_X; ++i) {
		for (int j = i; j <= MAX_X; ++j) {
			ll a = (ll)4 * i * j - (ll)N * (j + i);
			if (a <= 0)
				continue;
			ll b = (ll)N * i * j;
			if (b % a != 0)
				continue;
			h = i; n = j; w = b / a;
			i = j = MAX_X;
		}
	}

	cout << h << ' ' << n << ' ' << w << '\n';
	return 0;
}


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

using namespace std;

vector<long long> a;

bool comp(int i, int j) {
  return a[i] < a[j];
}

int main(int argc, char* argv[]) {
  long long N, M;
  cin >> N >> M;

  a.resize(N);
  vector<long long> b(N);
  vector<int> indices(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    cin >> b[i];
    indices[i] = i;
  }

  sort(indices.begin(), indices.end(), comp);

  long long cost = 0;
  for (int i = 0; i < N; ++i) {
    if (M == 0)
      break;
    int index = indices[i];
    long long n = b[index];
    if (n > M)
      n = M;
    cost += n * a[index];
    M -= n;
  }

  cout << cost << endl;

  return 0;
}

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

int main()
{
    int n,k,j,len1,len2,sum;
    char a[105],b[105],c[105];;
    // string a,b,c;
    cin>>n;
    //  cin>>a;
    scanf("%s",a);
    int maxx=0;
    for(int i=0; i<n-1; i++)
    {
        for( k=0; k<=i; k++)
            b[k]=a[k];
//len1=i+1;
        b[k]='\0';

        for( j=i+1,k=0; j<=n-1; j++,k++)
            c[k]=a[j];
      //  len2=n-(i+1);
        c[k]='\0';
        sort(b,b+i+1);
        sort(c,c+n-(i+1));
        sum=0;
     //   printf("%s\n%s\n",b,c);
        for(k=0; b[k]!='\0'; k++)
        {

                if(b[k-1]==b[k]&&k!=0)
                        continue;

            for(j=0; c[j]!='\0'; j++)
                if(b[k]==c[j])
                {
                    sum++;
                    break;
                }
        }
       // printf("%d\n",sum);
        maxx=sum>maxx?sum:maxx;
    }
    printf("%d",maxx);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int  main()
{
	int n[5]={0};
	int a;
	for(int i=1;i<=4;i++)
	    {
	    	cin>>a;
	    	if(a==1)n[1]=1;
	    	if(a==9)n[2]=1;
	    	if(a==7)n[3]=1;
	    	if(a==4)n[4]=1;	    	
		}
	if(n[1]+n[2]+n[3]+n[4]==4)
	  cout<<"YES";
	else
	  cout<<"NO";
	return 0;
	
}

Measured memory_bytes: 256
#include<iostream>

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

int main()
{
    double 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;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。(int64_t)
int main(){
    char X, Y;
    cin >> X >> Y;
    if(X < Y){
        cout << "<" << endl;
    }
    else if(X > Y){
        cout << ">" << endl;
    }
    else{
        cout << "=" << endl;
    }
}


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

const int N = 1e4 + 5;
const int mod = 998244353;
int len[N], ex[N], f[N][N], g[N][N], h[N];
int n, T, rt;

inline int quick_pow(int x, int k)
{
	int res = 1;
	while (k)
	{
		if (k & 1)
			res = 1ll * res * x % mod;
		x = 1ll * x * x % mod;
		k >>= 1;
	}
	return res;
}

inline void add(int &x, int y)
{
	x += y;
	x >= mod ? x -= mod : 0;
}

inline void dec(int &x, int y)
{
	x -= y;
	x < 0 ? x += mod : 0;
}

inline int solve(int l, int r, int lst)
{
	if (l > r)
		return 0;
	
	int mid = l, now = ++T;
	for (int i = l + 1; i <= r; ++i)
		if (h[i] < h[mid])
			mid = i;

	int lc = solve(l, mid - 1, h[mid]),
		rc = solve(mid + 1, r, h[mid]);
	for (int i = 0; i <= len[lc]; ++i)
		for (int j = 0; j <= len[rc]; ++j)
		{
			int t = i + j;
			int a = 1ll * f[lc][i] * f[rc][j] % mod,
				b = (1ll * g[lc][i] * (f[rc][j] + g[rc][j]) + 1ll * f[lc][i] * g[rc][j]) % mod;
			add(f[now][t], a);
			add(g[now][t], b);
			dec(f[now][t + 1], a);
			add(g[now][t + 1], a);
		}
	len[now] = len[lc] + len[rc] + 1;
	for (int j = 0; j <= len[now]; ++j)
	{
		f[now][j] = 1ll * f[now][j] * quick_pow(ex[len[now] - j], h[mid] - lst) % mod;
		g[now][j] = 1ll * g[now][j] * quick_pow(ex[len[now] - j] - 1, h[mid] - lst) % mod;
	}
	return now;
}

int main()
{
	f[0][0] = 1;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &h[i]);

	ex[0] = 1;
	for (int i = 1; i <= n; ++i)
		add(ex[i] = ex[i - 1], ex[i - 1]);
	rt = solve(1, n, 0);

	int ans = 0;
	for (int i = 0; i <= n; ++i)
	{
		add(ans, f[rt][i]);
		add(ans, g[rt][i]);
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 33280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    double L;
    cin >> L;
    cout << fixed;
    cout << setprecision(10) << (L / 3) * (L / 3) * (L / 3) << endl;
}

Measured memory_bytes: 256
N = int(input())
act = [list(map(int, input().split())) for _ in range(N)]

dp = [[0, 0, 0] for _ in range(N)]
dp[0][0] = act[0][0]
dp[0][1] = act[0][1]
dp[0][2] = act[0][2]

c = [0, 1, 2]   # choice
for i in range(1, N):
    for j in range(3):
        c.remove(j)
        if dp[i - 1][c[0]] > dp[i - 1][c[1]]:
            dp[i][j] = dp[i - 1][c[0]] + act[i][j]
        else:
            dp[i][j] = dp[i - 1][c[1]] + act[i][j]
        c.append(j)

print(max(dp[-1]))


Measured memory_bytes: 76316
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll a[10000001];

int main(){
	ll n;
	cin >> n;
	ull sum=0;
	for(ll i=1;i<n+1;i++){
		for(ll j=i;j<n+1;j+=i){
			a[j]++;
		}
	}
	arep(1,i,n+1){
		sum+=i*a[i];
	}
	cout << sum << endl;
}

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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int n,m,x;
int c[12];
int a[12][12];
int minn = 1e9;

void dfs(int i,int box[],int money){
  int check = 0;
  rep(s,m){
    cout << box[s] << endl;
    if(box[s] >= x){
      check++;
    }
  }
  if(check == m){
    minn = min(minn,money);
    return;
  }
  if(i == n)return;

  dfs(i+1,box,money);
  
  for(int s = 0;s < m;s++)box[s] += a[i][s];
  dfs(i+1,box,money+c[i]);
  return;
}

int main(){
  int r;
  cin >> r;
  cout << 2 * 3.1415 * r << endl;
}


Measured memory_bytes: 3752
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

typedef long long ll;

int main() {
	ll N, A, B; cin >> N >> A >> B;
	vector<ll>X(N); for (auto&& x : X)cin >> x;

	ll sum = 0;
	for (int i = 1; i < N; i++) {
		sum += min((X[i] - X[i - 1]) * A, B);
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
    fast;
    lli a,b;
    cin>>a>>b;
    cout<<a*b;
    
    return 0;
}

Measured memory_bytes: 3640
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

import numpy as np

def main():
  N, Q = map(int, input().strip().split(' '))
  S = input()
  ans = []
  rs = np.zeros(len(S), dtype=np.int)
  for i in range(1,len(S)):
    if S[i-1:i+1] == 'AC':
      rs[i] = rs[i-1]+1
    else:
      rs[i] = rs[i-1]
  for _ in range(Q):
    l, r = map(int, input().strip().split(' '))
    l -= 1
    r -= 1
    ans += [rs[r]-rs[l]]
  [print(a) for a in ans]
  pass

if __name__=='__main__':
  main()

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int a[3];
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
    }

    // 処理
    sort(begin(a), end(a));

    // 出力
    cout << a[2] * 10 + a[1] + a[0] << endl;

    return 0;
}


Measured memory_bytes: 256
ans = 0
n, w = map(int, input().split())
lst = [[0,0]]
for _ in range(n):
    a, b = map(int, input().split())
    lst.append([a,b])
dp = [[0] * (w+1) for _ in range(n+1)]

for i in range(0, n):
    for sum_w in range(0, w+1):
        if sum_w  >= lst[i+1][0]:
            dp[i+1][sum_w] = max(dp[i][sum_w -  lst[i+1][0]] + lst[i+1][1], dp[i][sum_w])
        else:
            dp[i+1][sum_w] = dp[i][sum_w]
        ans = max(ans, dp[i+1][sum_w])    
print(ans)


Measured memory_bytes: 120696
def main():
    n = int(input())
    d = list(map(int,input().split()))
    ans = 0
    for i in range(n):
        for j in range(n):
            if i < j:
                ans += d[i]*d[j]
    print(ans)    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 39024
#include<iostream>
#include<climits>

using namespace std;

long long int dp[100001][101] = {};

long long int knapsack(long long int wt[], long long int val[], long long int w, long long int i)
{
	if(w<0)
	{
		return INT_MIN;
	}
	else if(i==-1)
	{
		return 0;
	}
	else if(dp[w][i]!=0)
	{
		return dp[w][i];
	}
	else
	{
		dp[w][i] = max(knapsack(wt,val,w-wt[i],i-1) + val[i], knapsack(wt,val,w,i-1)); 
		return dp[w][i];
	}	
}

int main()
{
	long long int n,i,w;
	cin>>n>>w;
	long long int wt[n], val[n];
	for(i=0;i<n;++i)
	{
		cin>>wt[i]>>val[i];
	}
	cout<<knapsack(wt,val,w,n-1)<<endl;
	return 0;
}

Measured memory_bytes: 78848
#include <iostream>
#include <cstdio>

using namespace std;

char a;
char b;

void solve()
{
    if(a=='H')
    {
        if(b=='H')
            printf("H\n");
        else
            printf("D\n");
    }
    else
    {
        if(b=='H')
            printf("D\n");
        else
            printf("H\n");
    }
}

int main()
{
    while(cin>>a>>b)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define ll long long int
ll minn(ll a,ll b)
{
    if(a>b)
        return b;
    else
        return a;
}
ll maxx(ll a,ll b)
{
    if(a<b)
        return b;
    else
        return a;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    int count=0;
    if(n==1)
        cout<<"0";
    else
    {
        for(int i=2;i<=sqrt(n);i++)
        {
            int c=0;
            while(n%i==0)
            {
                n=n/i;
                c++;
            }
            count+=((-1+sqrt(1+8*c))/2);
        }
        if(n>1)
            count++;
        cout<<count;
    }

}









Measured memory_bytes: 3696