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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

ll simulate(vector<ll> &a) {
    int N = a.size();
    ll result = 0;
    while (true) {
        sort(all(a));
        if (a[N - 1] < N) {
            break;
        }
        REP(i, N - 1) {
            ++a[i];
        }
        a[N - 1] -= N;
        ++result;
    }
    return result;
}

int main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];

    ll result = 0;
    bool flag = false;
    REP(i, N) {
        if (a[i] >= N - 1 + N * N) {
            a[i] -= N * N;
            REP(j, N) {
                if (j != i) {
                    a[j] += N;
                }
            }
            result += N;
            flag = true;
            break;
        }
    }
    if (flag) {
        REP(i, N) {
            if (a[i] < N + 1) {
                continue;
            }
            ll k = a[i] / (N + 1);
            ll ops = (k - 1) * (N + 1);
            a[i] -= ops;
            result += ops;
        }
    }
    result += simulate(a);
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			int[] A = new int[101];
			while(true){
				String[] SS = sc.next().split(",", 0);
				int team = Integer.parseInt(SS[0]);
				int score = Integer.parseInt(SS[1]);
				if(team == 0 && score == 0){
					break;
				}

				A[team] = score;
			}
			while(sc.hasNext()){
				int num = A[sc.nextInt()];
				Set<Integer> set = new HashSet<>();
				for(int i = 0; i < 101; i++){
					if(num < A[i]){
						set.add(A[i]);
					}
				}
				System.out.println(set.size() + 1);
			}
		}
	}
}

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

int main() {
  int d, n;
  std::cin >> d >> n;
  if (n == 100) {
    n = 101;
  }
  for (int i = 0; i < d; i++) {
    n *= 100;
  }
  std::cout << n << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,alice,bob;
  alice = 0;
  bob = 0;
  cin >> N;
  vector<int> card(N);
  for (int i=0;i < N;i++) {
    cin >> card.at(i);
  }
  sort(card.begin(),card.end());
  reverse(card.begin(),card.end());
  for (int i=0;i < N;i++) {
    if (i % 2 == 0) {
      alice += card.at(i);
    }
    else {
      bob += card.at(i);
    }
  }
  cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  string n;
  cin >> n;
  rep(i, 3){
    if (n[i] == '1') n[i] = '9';
    else if (n[i] == '9') n[i] = '1';
  }
  cout << n << endl;
  
  return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> p(M);
    vector<string> s(M);
    for(int i=0; i<M; i++){
        cin >> p[i] >> s[i];
        p[i]--;
    }

    vector<bool> isAC(N, false);
    vector<int> countWA(N, 0);
    int AC = 0, pn = 0;
    for(int i=0; i<M; i++){
        if(isAC[p[i]]) continue;
        if(s[i]=="AC"){
            isAC[p[i]] = true;
            AC++;
            pn += countWA[p[i]];
        }
        else{
            countWA[p[i]]++;
        }
    }

    cout << AC << " " << pn << endl;
}

Measured memory_bytes: 6528
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 5e5 + 5;
char tmp[maxn];
int n;
string s;

bool read() {
  if (scanf("%s", tmp) < 1) {
    return false;
  }
  s = tmp;
  n = sz(s);
  return true;
}

void solve() {
  long long res = 0;
  for (int j = 0; j < n;) {
    int a = 0;
    while (j < n && s[j] == '<') {
      a++;
      j++;
    }
    int b = 0;
    while (j < n && s[j] == '>') {
      b++;
      j++;
    }
    res += (long long) a * (a - 1) / 2;
    res += (long long) b * (b - 1) / 2;
    res += max(a, b);
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    int n,x,y;
    cin >> n >> x >> y;
    int ans[n] = {};
    for(int i = 1;i < n;i++)
    {
        for(int j = i + 1;j <= n;j++)
        {
            int a = fabs(j - i);
            int b = fabs(x - i) + 1 + fabs(j - y);
            int c = fabs(y - i) + 1 + fabs(j - x);
            ans[min(a,min(b,c))]++;
        }
    }
    for(int i = 1;i < n;i++)
    {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
n , k = map(int, input().split())
a = list(map(int,input().split()))
a.sort()

MOD = 1000000007

factorial = [1]
inverse = [1]
for i in range(1, n+2):
    factorial.append(factorial[-1] * i % MOD)
    inverse.append(pow(factorial[-1], MOD - 2, MOD))

def combi(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % MOD

max_sum=0
min_sum=0

for i in range(k-1,n):
    t = combi(i,k-1)
    max_sum+=a[i]*t
    max_sum%=MOD
    min_sum+=a[n-i-1]*t
    min_sum%=MOD
if max_sum-min_sum<0:
    max_sum+=MOD
print(max_sum-min_sum)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int a,b;
  while(~scanf("%d%d",&a,&b)){
    int c = a+b;
    int cnt = 1;
    while(c/=10)++cnt;
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include <iostream>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a > b) {
		cout << "a > b" << endl;
	} else if (a == b) {
		cout << "a == b" << endl;
	} else {
		cout << "a < b" << endl;
	}

	return 0;
}



Measured memory_bytes: 3096
def calc(a, op, b):
    if op == "+":
        r = a + b
    elif op == "-":
        r = a - b
    elif op == "*":
        r = a * b
    else:
        r = a / b
    return r
 
while True:
    a, op , b = raw_input().split()
    if op == "?":
        break
    print(calc(int(a), op, int(b)))

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

int main(){
    string s, ans;
    cin >> s;
    ans = "Yes";
    rep(i, s.length()){
        if((i + 1) % 2 == 0){
            if(s[i] == 'R'){
                ans = "No";
                break;
            }
        }
        else{
            if (s[i] == 'L'){
                ans = "No";
                break;
            }
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

X, Y, A, B, C = lr()
P = lr(); P.sort(reverse=True)
Q = lr(); Q.sort(reverse=True)
R = lr()
P = P[:X]
Q = Q[:Y]
whole = P + Q + R
whole.sort(reverse=True)
answer = sum(whole[:X+Y])
print(answer)


Measured memory_bytes: 22560
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<long long> x(n), s(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> s[i];
  }
  vector<long long> sum(n + 1);
  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + s[i];
  }
  long long best = -1e18;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    best = max(best, -sum[i] + x[i]);
    ans = max(ans, sum[i + 1] + best - x[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

vector <int> edges[100000];
vector <int> reverse_edges[100000];
int in_degree[100000];
vector <int> tp_ord;
bool used[100000];
int dp[100000];
void dfs(int cur){
    used[cur] = true;
    for(int i = 0; i < edges[cur].size(); i++){
        int next = edges[cur][i];
        if(!used[next]){
            dfs(next);
        }
    }
    tp_ord.push_back(cur);
}

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N - 1; i++){
        int a;
        cin >> a;
        edges[i + 1].push_back(a - 1);
        reverse_edges[a - 1].push_back(i + 1);
        in_degree[a - 1] ++;
    }

    for(int i = 0; i < N; i++){
        if(in_degree[i] == 0){
            dfs(i);
        }
    }
    reverse(tp_ord.begin(), tp_ord.end());
    for(int i = 0; i < N; i++){
        int cur = tp_ord[i];
        int max_depth = 0;
        int min_depth = INT_MAX;
        if(reverse_edges[cur].size() == 0){
            dp[cur] = 0;
            continue;
        }

        vector <int> prev_depths;
        prev_depths.push_back(0);
        for(int j = 0; j < reverse_edges[cur].size(); j++){
            prev_depths.push_back(1 + dp[reverse_edges[cur][j]]);
        }
        sort(prev_depths.begin(), prev_depths.end());
        for(int j = 0; j < prev_depths.size(); j++){
            dp[cur] = max(dp[cur], prev_depths[prev_depths.size() - 1 - j] + j);
        }
        //cout << cur << " " << dp[cur] << endl;
    }
    cout << dp[0] << endl;
    return 0;
}


Measured memory_bytes: 15740
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	sx := readInt()
	sy := readInt()
	tx := readInt()
	ty := readInt()

	u := ty - sy
	r := tx - sx

	for i := 0; i < u; i++ {
		printf("U")
	}
	for i := 0; i < r; i++ {
		printf("R")
	}
	for i := 0; i < u; i++ {
		printf("D")
	}
	for i := 0; i < r; i++ {
		printf("L")
	}
	printf("L")
	for i := 0; i <= u; i++ {
		printf("U")
	}
	for i := 0; i <= r; i++ {
		printf("R")
	}
	printf("D")
	printf("R")
	for i := 0; i <= u; i++ {
		printf("D")
	}
	for i := 0; i <= r; i++ {
		printf("L")
	}
	printf("U")
	println()
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
    int n, ans = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        int cnt = 0, x = i;
        while (x != 0)
        {
            x /= 10;
            cnt++;
        }
        if (cnt & 1)
            ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1704
h, w, k = map(int, input().split())
C = []
for _ in range(h): C.append(input())
import itertools
ans = 0
for hbit, wbit in itertools.product(range(1<<h), range(1<<w)):
    c = 0
    for i, j in itertools.product(range(h), range(w)):
        if hbit>>i & 1 and wbit>>j & 1 and C[i][j] == '#': c += 1
    if c == k: ans += 1
print(ans)


Measured memory_bytes: 9084
N = int(input())
a = [int(input()) for i in range(N)]

pushed = [False] * N
ans = 0
current = 0
while True:
    ans += 1
    current = a[current] - 1
    if pushed[current]:
        ans = -1
        break
    if current == 1:
        break
    pushed[current] = True
print(ans)


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

void solve(long long A, long long B){
	if (A == 1 && B == 1) {
    cout << "Draw" << endl;
  } else if (A == 1) {
    cout << "Alice" << endl;
  } else if (B == 1) {
    cout << "Bob" << endl;
  } else {
    if (A == B) {
      cout << "Draw" << endl;
    } else if ( A > B ) {
      cout << "Alice" << endl;
    } else {
      cout << "Bob" << endl;
    }
  }

}

int main(){	
	long long A;
	long long B;
	scanf("%lld",&A);
	scanf("%lld",&B);
	solve(A, B);
	return 0;
}



Measured memory_bytes: 764
#include <iostream>

int main(){
    int vertex;
    std::cin.tie( 0 );
    std::cin >> vertex;

    bool** adjMatrix = new bool*[vertex];
    for( int i = 0; i < vertex; ++i ){
        adjMatrix[i] = new bool[vertex];
    }

    for( int i = 0; i < vertex; ++i ){
        for( int j = 0; j < vertex; ++j ){
            adjMatrix[i][j] = false;
        }
    }

    int tag;
    int degree;
    int tmp;
    for( int i = 0; i < vertex; ++i ){
        std::cin >> tag >> degree;
        while( degree-- > 0 ){
            std::cin >> tmp;
            adjMatrix[tag-1][tmp-1] = true;
        }
    }

    for( int i = 0; i < vertex; ++i ){
        for( int j = 0; j < vertex; ++j ){
            std::cout << static_cast<int>( adjMatrix[i][j] ) << ( ( j < vertex-1 )? " " : "\n" );
        }
    }

    delete[] adjMatrix;
}


Measured memory_bytes: 3076
x, k, d = map(int, input().split())

# 0をまたぐかで場合わけ
if x == 0:
    if k % 2 == 0:
        print(0)
    else:
        print(d)
    exit()

x = abs(x)

if x-k*d <= 0:
    # 0をまたぐ
    a, b = divmod(x, d)
    if (k-a) % 2 == 0:
        print(b)
    else:
        print(min(b+d, d-b))
else:
    # 0をまたがない
    print(x-k*d)


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

int main(){
  int n;
  cin >> n;
  int l, r;
  l = 0; r = n;
  string sl, sr, sm;
  cout << 0 << endl;
  fflush(stdout);
  cin >> sl;
  if(sl == "Vacant") return 0;
  sr = sl;
  while(true) {
    int m = (l+r)/2;
    cout << m << "\n";
    fflush(stdout);
    cin >> sm;
    if(sm == "Vacant") return 0;
    if((m-l) % 2) {
      if(sl == sm) {
        r = m; sr = sm;
      } else {
        l = m; sl = sm;
      }
    } else {
      if(sl == sm) {
        l = m; sl = sm;
      } else {
        r = m; sr = sm;
      }
    }
  }
  return 0;
}

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

const int N = 1e5 + 5;
const int M = N * 4;

#define int long long

int n, m, x, y, a, b, A[M], B[M], cnt, fir[N], ne[M], to[M], s, t;

void add(int x, int y, int a, int b) {
	ne[++ cnt] = fir[x];
	fir[x] = cnt;
	to[cnt] = y;
	A[cnt] = a;
	B[cnt] = b;
}

void link(int x, int y, int a, int b) {
	add(x, y, a, b);
	add(y, x, a, b);
}

#define Foreachson(i, x) for(int i = fir[x]; i; i = ne[i])

int dis1[N], dis2[N], S[N];

struct NODE {
	int x, dis;
	friend bool operator < (NODE a, NODE b) {
		return a.dis > b.dis;
	}
};

priority_queue <NODE> q;

bool vis[N];

void get(int s, int *A, int *dis) {
	while(!q.empty()) q.pop();
	for(int i = 1; i <= n; ++ i) vis[i] = 0;
	q.push((NODE){s, 0});
	while(!q.empty()) {
		while(1) {
			if(!q.size()) break;
			NODE ind = q.top();
			if(vis[ind.x]) {
				q.pop();
				continue;
			}
			else break;
		}
		if(!q.size()) break;
		NODE ind = q.top();
		q.pop();
		vis[ind.x] = 1;
		dis[ind.x] = ind.dis;
		Foreachson(i, ind.x) {
			int V = to[i];
			if(vis[V])
			continue;
			q.push((NODE){V, ind.dis + A[i]});
		}
	}
}

main(void) {
	cin >> n >> m >> s >> t;
	for(int i = 1; i <= m; ++ i) {
		scanf("%lld%lld%lld%lld", &x, &y, &a, &b);
		link(x, y, a, b);
	}
	get(s, A, dis1);
	get(t, B, dis2);
	for(int i = 1; i <= n; ++ i) S[i] = dis1[i] + dis2[i];
	//for(int i = 1; i <= n; ++ i) cerr << dis1[i] << " ";
	//puts("");
	//for(int i = 1; i <= n; ++ i) cerr << dis2[i] <<" ";
	//puts("");
	for(int i = n - 1; i >= 1; -- i) S[i] = min(S[i], S[i + 1]);
	for(int i = 1; i <= n; ++ i) printf("%lld\n", (int)1e15 - S[i]);
}

Measured memory_bytes: 16756
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0

for i in range(n):
    ans += b[a[i]-1]
    if 1<=i and a[i]-a[i-1] == 1:
        ans += c[a[i]-2]

print(ans)

Measured memory_bytes: 8964
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double pi = Math.PI;
		double area = r * r * pi;
		double length = 2 * pi * r;
		System.out.printf("%f %f\n", area, length);
	}
}


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

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


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int first,last;
  char s[5];
  scanf("%s",s);
  first=(s[0]-'0')*10;
  first+=(s[1]-'0');
  last=(s[2]-'0')*10;
  last+=(s[3]-'0');
  if(1<=first&&first<=12)
  {
    if(1<=last&&last<=12)printf("AMBIGUOUS");
    else printf("MMYY");
  }
  else
  {
    if(1<=last&&last<=12)printf("YYMM");
    else printf("NA");
  }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
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 ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n = 100;
    ll x;cin >> x;
    ll cnt = 0;
    while(n<x){
        n = n + n*0.01;
        n = (ll)n;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, m, i, j;
	ll x, y, z, ans = 0;
	cin >> num >> m;
	vector<vector<ll>> d(8, vector<ll>(num, 0));
	for (i = 0; i < num; i++) {
		cin >> x >> y >> z;
		d[0][i] = x + y + z;
		for (j = 1; j < 8; j++) {
			d[j][i] = d[0][i];
			if (j & 1)
				d[j][i] -= x << 1;
			if (j & 2)
				d[j][i] -= y << 1;
			if (j & 4)
				d[j][i] -= z << 1;
		}
	}
	for (i = 0; i < 8; i++) {
		sort(d[i].begin(), d[i].end(), greater<ll>());
		for (x = 0, j = 0; j < m; j++)
			x += d[i][j];
		ans = max(ans, x);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include "cstdio"
int a[100005],i,n;long long s;
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<=n;i++){
		if(!a[i])continue;
		s+=a[i]>>1;
		a[i]&=1;
		if(a[i])if(a[i+1])a[i]--,a[i+1]--,s++;
	}
	printf("%lld\n",s);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int count = 0;
    int divcount = 0;
    for (int i = 1 ; i < N + 1 ; i += 2){
        divcount = 0;
        for(int j = 1 ; j < i + 1 ; j++){
            if(i % j == 0){
                divcount++;
            }
        }
        if (divcount == 8){
            count++;
        }
    }
    printf("%d\n",count);

}

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

#define N_MAX 100000
#define W_MAX 10000

int ws[N_MAX];
int n;
int k;

int check(const int P) {
	int sum = 0;
	int count = 0;
	for (int i = 0; i < n; ++i) {
		sum += ws[i];
		while (sum > P) {
			sum = ws[i];
			++count;
			if (count == k) {
				return i;
			}
		}
	}
	return n;
}

int solve() {
	int begin = 0;
	int end = N_MAX * W_MAX;

	while (begin < end) {
		int mid = (begin + end) / 2;
		if (check(mid) < n) {
			begin = mid + 1;
		} else {
			end = mid;
		}
	}
	return begin;
}

int main() {
	std::cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		std::cin >> ws[i];
	}

	std::cout << solve() << std::endl;

	return 0;
}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int dp[510];
int p[510];
int E[510][510];

void loop(int a, int b, int l) {
	// debug(a, b, l);
	if(b - a <= 1) return;
	int m = (a + b) / 2;
	rep(i, a, m) {
		rep(j, m, b) {
			E[i][j] = l;
			E[j][i] = l;
		}
	}
	loop(a, m, l + 1);
	loop(m, b, l + 1);
}

void solve() {
	cin >> N;
	loop(0, N, 0);
	for(int i = 0; i < N; i++) {
		rep(j, i + 1, N) {
			cout << E[i][j] + 1 << " ";
		}
		cout << "\n";
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 1536
# Fast IO (only use in integer input)

import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

N = int(input())
a = list(map(int,input().split()))

subSeqStart = []
subSeqEnd = []

subSeqStart.append(a[0])

for i in range(N):
    if i == N-1:
        subSeqEnd.append(a[i])
        break
    if a[i] > a[i+1]:
        subSeqEnd.append(a[i])
        subSeqStart.append(a[i+1])

Money = 1000
Stock = 0
for i in range(len(subSeqStart)):
    Stock += Money // subSeqStart[i]
    Money -= Stock * subSeqStart[i]
    Money += Stock * subSeqEnd[i]
    Stock = 0
print(Money)

Measured memory_bytes: 62104
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};



int main(){
    int n;cin >> n;
    vector<LL> x(n),s(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> s[i];
    }
    vector<LL> L(n,0),R(n,0);
    LL S = 0;
    for (int i = n-2; i >= 0; i--) {
        S = max(0LL, S + s[i+1] - (x[i+1] - x[i]));
        R[i] = S;
    }
    S = 0;
    for (int i = 1; i < n; i++) {
        S = max(0LL, S + s[i-1] - (x[i] - x[i-1])); 
        L[i] = S;
    }
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        chmax(ans, L[i] + R[i] + s[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cins(int, 4, n);
    Cout(min(n[0], n[1]) + min(n[2], n[3]));
}

Measured memory_bytes: 256
X = int(input())

if X >= 400 and X <= 599:
    print('8')
elif X >= 600 and X <= 799:
    print('7')
elif X >= 800 and X <= 999:
    print('6')
elif X >= 1000 and X <= 1199:
    print('5')
elif X >= 1200 and X <= 1399:
    print('4')
elif X >= 1400 and X <= 1599:
    print('3')
elif X >= 1600 and X <= 1799:
    print('2')
else:
    print('1')


Measured memory_bytes: 9172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

  public static void main(String args[]) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    List<String> list = new ArrayList<>();
    String data;
    while ((data = br.readLine()) != null) {
      list.add(data);
    }

    int n = Integer.parseInt(list.get(0)); // 長さ
    String s = list.get(1); // 文字列
    br.close();

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

      if (size - i >= 3) {
        String tmp = s.substring(i, i + 3);

        if ("ABC".equals(tmp)) {
          count++;
        }
      } else {
        break;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 23252
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <cmath>
#define INF 1000000007
using namespace std ;

int main(int argc, char const *argv[])
{


	
	vector<vector<int> > mat(3,vector<int>(3,0)) ;
	map<int,int> row,col,daig1,daig2;
	map<int,pair<int,int> > m ;

	for(int i = 0 ; i < 3 ; i++) for(int j = 0 ; j < 3 ; j++){ cin>>mat[i][j] ; m[mat[i][j]] = make_pair(i,j) ; } 

	int n;
 	cin>>n ;

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

 		if(m.find(temp) != m.end())
 		{
 			row[m[temp].first]++ ;
 			if(row[m[temp].first] == 3) {cout<<"Yes"<<endl ; return 0 ;}

 			col[m[temp].second]++ ;
 			if(col[m[temp].second] == 3) {cout<<"Yes"<<endl ; return 0 ;} 

 			daig1[m[temp].first - m[temp].second]++ ;
 			if(daig1[m[temp].first - m[temp].second] == 3){cout<<"Yes"<<endl ; return 0 ;}

 			daig2[m[temp].first + m[temp].second]++ ;
 			if(daig2[m[temp].first + m[temp].second] == 3) {cout<<"Yes"<<endl ; return 0 ;}

 		}

 	}

 	cout<<"No"<<endl ; 
	return 0;
}

Measured memory_bytes: 256
/*program by mangoyang*/
#include<bits/stdc++.h>
#define inf (0x7f7f7f7f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
    int f = 0, ch = 0; x = 0;
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    if(f) x = -x;
}
#define int ll
#define par pair<int, int>
#define fi first
#define se second
par f[(1<<19)+105]; 
main(){
	int n; read(n);
	for(int i = 0; i < (1 << n); i++) read(f[i].fi);
	for(int j = 0; j < n; j++)
		for(int i = 1; i < (1 << n); i++){
			if(i & (1 << j)){
				par now = f[i^(1<<j)];
				if(now.fi > f[i].fi){
					f[i].se = Max(f[i].fi, now.se);
					f[i].fi = now.fi;
				}
				else f[i].se = Max(f[i].se, now.fi);	
			}
		}
	for(int i = 1; i < (1 << n); i++){
		//cout << i << " " << f[i].fi << " " << f[i].se << endl;
		par now = f[i-1];
		if(now.fi + now.se > f[i].fi + f[i].se) f[i] = now;
		printf("%lld\n", f[i].fi + f[i].se);
	}
	return 0;
}


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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
int gcd(int a, int b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint comb(int n, int m) {
    return perm(n) / (perm(n - m) * perm(m));
}

// 定数 //
#define pi acos(-1)
// End of Template //

vvi graph;
vector<tuple<int, int, int>> length;
vli color;
vb colored;
int getLength(int k, int n) {
    int l = 0;
    int min = 0;
    int max = length.size();
    int mid = max / 2;
    int s = k > n ? n : k;
    int b = k > n ? k : n;
    while(1) {
        if (s > get<0>(length[mid])) {
            min = mid;
            mid = (mid + max) / 2;
        }
        else if (s < get<0>(length[mid])) {
            max = mid;
            mid = (mid + min) / 2;
        }
        else {
            if (b == get<1>(length[mid])) {
            l = get<2>(length[mid]);
            return l;
            }
            else if (b > get<1>(length[mid])) {
                min = mid;
                mid = (mid + max) / 2;
            }
            else if (b < get<1>(length[mid])) {
                max = mid;
                mid = (mid + min) / 2;
            }
        }
    }
    return l;
}

void coloring(int n, lint co) {
    colored[n] = true;

    for (auto i : graph[n]) {
        if (colored[i]) continue;
        color[i] = co + getLength(i, n);
        coloring(i, color[i]);
    }
}

int main() {

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

    color.resize(N);
    colored.assign(N, false);
    length.resize(N - 1);
    graph.assign(N, vi(0));
    int a, b, l;
    rep(i, N - 1) {
        cin >> a >> b >> l;
        graph[a - 1].push_back(b - 1);
        graph[b - 1].push_back(a - 1);
        length[i] = make_tuple(a > b ? b - 1, a - 1, l : a - 1, b - 1, l);
    }

    sort(length);

    coloring(0, 0);
    rep(i, N) {
        cou(color[i] % 2);
    }
}

Measured memory_bytes: 10496
#include<iostream>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,a,b,c,x,nx;
	while(cin>>n>>a>>b>>c>>x,(((n||a)||b)||c)||x){
		int y[n];
		rep(i,n)cin>>y[i];
		int cnt=0,ans;
		bool check=true;
		if(x==y[cnt]&&cnt<n)cnt++;
		if(cnt>=n){
			check=false;
			ans=0;
		}else{
			loop(i,1,10001){
				nx=(a*x+b)%c;
				if(nx==y[cnt]&&cnt<n)cnt++;
				if(cnt==n){
					check=false;
					ans=i;
					break;
				}
				x=nx;
			}
		}
		if(check)cout<<-1<<endl;
		else cout<<ans<<endl;
	}
	return 0;
}


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

class Cube{
  public:
  int f[6];
  Cube(){}
  void roll_z(){ roll(1, 2, 4, 3);}
  void roll_y(){ roll(0, 2, 5, 3);}
  void roll_x(){ roll(0, 1, 5, 4);}
  void roll(int i, int j, int k, int l){
  	int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
  }
};

int main(){
  Cube c1, c2;
  
  for ( int i = 0; i < 6; i++ ) cin >> c1.f[i];
  for ( int i = 0; i < 6; i++ ) cin >> c2.f[i];
  
  for ( int i = 0; i < 6; i++ ){
  	for ( int j = 0; j < 4; j++ ){
  	  for ( int k = 0; k < 6; k++ ){
  	  	if ( c1.f[k] == c2.f[k] ){
  	  	  if ( k == 5 ){
  	  	  	cout << "Yes" << endl;
  	  	  	return 0;
  	  	  }
  	  	} else break;
  	  }
  	  c2.roll_z();
  	}
  	if ( i % 2 == 0 ) c2.roll_y();
  	else c2.roll_x();
  }
  
  cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main(){
  long n,m,x,s=0;
  cin>>n>>m;
  while(m--){
    cin>>x; s+=x;
  }
  if(n-s < 0) cout<<-1;
  else cout<<n-s;
  return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//int[] array_k = new int[100000];
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		int large = 0;
		if(h>w) {
			large=h;
		}
		else {
			large=w;
		}
		int count=0;
		int answer=0;
		for(int i=0;large>i;i++) {
			count=count+large;
			answer++;
			if(count>=n) {
				System.out.println(answer);
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 23892
#include "bits/stdc++.h"
using namespace std;
#ifdef ONLINE_JUDGE
#define trace(...)
#endif

using LL = long long;

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

	int a, b; cin >> a >> b;
	cout << (max(a, b) <= 9 ? a * b : -1) << endl;
	
	return 0;
}


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... Args> void rd(Args&... args) {((cin >> args), ...);}
template<typename... Args> void write(Args... args) { ((cout << args << " "), ...); cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC";
    else cout<<"ABC";
    return 0;
}



Measured memory_bytes: 3624
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pii;
typedef tuple<ll,ll,ll> t3;

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<ll>> g;
    g.assign(n, vector<ll>(n, 1e15));
    auto c = g;
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < n;j++)
        {
            cin >> g[i][j];
        }
    }
    ll ans = 0;
    for(int i = 0;i < n;i++)
    {
        for(int j = i+1;j < n;j++)
        {
            if(i == j) continue;
            ll mi = 1e15;
            for(int k = 0;k < n;k++)
            {
                if(i != k && j != k)
                {
                    mi = min(mi, g[i][k] + g[k][j]);
                }
            }
            if(mi>g[i][j]) ans+=g[i][j];
            if(mi<g[i][j])
            {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1664
/************************************/
/* NoobM							*/
/* File Name : atjp.cpp				*/
/* Date : 27.06.2020 19:24:07 +06	*/
/************************************/

#include <bits/stdc++.h>

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

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


Measured memory_bytes: 3564
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

	int a, b;
	cin >> a >> b;
	if (a * b % 2 == 0) {
		cout << "Even";
	}
	else {
		cout << "Odd";
	}
	return 0;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())
count=0
for i in range(0,a+1):
  for j in range(0,b+1):
    for k in range(0,c+1):
      if 500*i+100*j+50*k==x:
        count+=1
print(count)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
typedef long long ll ;


int main()
{
     string a,b;
     cin >> a>>b;
     int c,d;
     cin >>c>>d;
     string f;
     cin >> f;
     if(f==a)c--;
     else d--;
     cout << c << " "<<d;
     
}

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

int main() {
    int n, q;
    cin >> n;
    map<ll,ll> mp;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        mp[a[i]]++;
    }
    ll sum = 0;
    cin >> q;
    rep(i,n) sum+=a[i];
    
    rep(i,q){
        int b, c;
        cin >> b >> c;
        ll x = mp[b];
        if(x==0) {cout << sum << endl; continue;}
        mp[b]=0;
        sum-=x*b;
        mp[c]+=x;
        sum+=c*x;
        cout << sum << endl;
    }
   
    return 0;
}

Measured memory_bytes: 9648
#include <stdio.h>

#define MAX 10000
#define NIL -1

struct Node {int p, l, r;};
struct Node T[MAX];
int n;

/* 先行順巡回 */
void preParse(int u) {
  if(u == NIL) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

/* 中間順巡回 */
void inParse(int u) {
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

/* 後方順巡回 */
void postParse(int u) {
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(void) {
  int i, v, l, r, root;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    T[i].p = NIL;
  }
  
  for(i=0; i<n; i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }
  
  for(i=0;i<n;i++) if(T[i].p == NIL) root = i;
  
  printf("Preorder\n");
  preParse(root);
  printf("\n");

  printf("Inorder\n");
  inParse(root);
  printf("\n");

  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
#include <bitset>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = k;
    REP(i, n - 1) ans *= (k - 1);
    cout << ans << endl;
}

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

int x[3];

int main(){
    for(int i=0;i<3;i++) scanf("%d",x+i);

    int ret = 0;
    while(1){
        sort(x,x+3);
        if(x[0]==x[1] && x[1]==x[2]) break;

        if(x[1] - x[0] >= 2){
            x[0] += 2;
            ret++;
        }
        else{
            x[0]++, x[1]++;
            ret++;
        }
    }

    printf("%d\n", ret);
}


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

#define N 100010
int n, k, h[N];

int main()
{
	while (scanf("%d%d", &n, &k) != EOF)
	{
		for (int i = 1; i<= n; ++i) scanf("%d", h + i);
		sort(h + 1, h + 1 + n, [](int a, int b) { return a > b; });
		int res = 1e9;
		for (int i = 1; i + k - 1 <= n; ++i) res = min(res, h[i] - h[i + k - 1]);
		printf("%d\n", res);
	}
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
 
int main()
{
   int a, b;
   scanf("%d %d\n", &a, &b);
 
   if ( a > b )
      printf("a > b\n");
   else if ( a == b)
      printf("a == b\n");
   else if ( a < b )
      printf("a < b\n");
 
   return 0;
 
}
 

Measured memory_bytes: 584
from bisect import bisect


if __name__ == "__main__":
    n = int(input())
    a = list(map(lambda x: int(x), input().split()))
    num_query = int(input())

    for _ in range(num_query):
        k = int(input())
        print(f"{bisect(a, k - 1)} {bisect(a, k)}")



Measured memory_bytes: 17228
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>

//by Skeef79

//НЕ ИСПОЛЬЗУЙ endl, есть свой en!!
//Иногда нужно не просто придумывать решение, а метматически расписать систему уравнений
//для задач с cin/cout в большом кол-ве - gnu , иначе вижуалки. А ваще пробуй два если TL

//для интерактивок - cout<<flush
// cin.tie и sync_with_stdio убирать для интерактивок

typedef long long ll;
typedef long double ld;

#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 1e9 + 1233;
const ll LINF = 1e18 + 1233;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
}

template <typename T> void Input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

bool IsSorted(vector<int>& a)
{
	for (int i = 1; i < a.size(); i++)
	{
		if (a[i] < a[i - 1])
			return false;
	}
	return true;
}

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

	int n;
	cin >> n;
	vector<ll> a(n + 1);
	vector<ll> b(n);

	Input(a);
	Input(b);

	ll ans = 0;

	for (int i = n - 1; i >= 0; i--)
	{
		ans += min(a[i + 1], b[i]);
		b[i] = max(ll(0), b[i] - a[i + 1]);
		ans += min(a[i], b[i]);
		a[i] = max(ll(0), a[i] - b[i]);

	}

	cout << ans;

}





Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int a,b;
  cin>>a>>b;
  if(a==b){
    cout<<1<<endl;
    return 0;
  }
  Int k=62;
  while((a>>k)==(b>>k)) k--;
  //for(Int i=k;i<62;i++) cout<<((a>>i)&1)<<" "<<((b>>i)&1)<<endl;

  a=a&((1LL<<k)-1);
  b=b&((1LL<<k)-1);
  Int ans=(1LL<<k)-a;

  Int x=0;
  while(b>>x) x++;
  b|=(1LL<<x)-1;
  chmin(b,a-1);
  ans+=b+1;
  ans+=(1LL<<k)-a;
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256