akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
    using namespace std;
    long long x[100010],y[100010],p[100010];
    long long q[100010];
    int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a,b,c,d,e,n,ccnt=0,ans=0;
    string s,v,o;
    char z[100010],y[100010];
     
    cin>>a>>b;
    if(a<b) swap(a,b);
    if(a>=b+2){
    cout<<a+(a-1)<<'\n';
    }else{
    cout<<a+b<<'\n';
    }
    }

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;
using P =pair<int,int>;

int main(){
    ll n;
    cin >> n;
    vector <ll> a(n),b(n);
    ll aa,bb;

    rep(i,n){
        cin >> aa;
        a[i]=i+aa+1;
        b[i]=i-aa+1;
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    ll k=0,k2=0;
    ll ans=0;

    

    rep(i,n){
        
        if(a[i]==a[i-1] and i!=0){
            ans+=k2;
        }
        else{
            k2=0;
            if(k>n-1){
                break;
            }
        while(a[i]>=b[k]){
            if(a[i]==b[k]){
                ++ans;
                ++k2;
            }
            ++k;
        }
        
        }
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 6344
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        mut n: isize,
    }
    n -= 1;

    let mut ans = vec![];
    while n >= 0 {
        let c = ((n % 26) as u8 + b'a') as char;

        ans.push(c);
        n /= 26;
        n -= 1;
    }

    ans.reverse();
    let ans = ans.iter().collect::<String>();

    println!("{}", ans);
}

Measured memory_bytes: 2200
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

@lru_cache(maxsize=None)
def f(x):
    if x < 0:
        return False
    if (x%100==0) or (x%101==0) or (x%102==0) \
            or (x%103==0) or (x%104==0) or (x%105==0):
        return True
    return f(x-100) or f(x-101) or f(x-102) \
            or f(x-103) or f(x-104) or f(x-105)

def main():
    X = ii()
    print(1 if f(X) else 0)


if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	double t, x;
	cin >> t >> x;

	printf("%f\n", t / x);
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
V=LIST()
C=LIST()

ans=0
for i in range(N):
    if V[i]>C[i]:
        ans+=V[i]-C[i]
print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int a[100000];
int main()
{
	int i, j, n, count = 0;
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for (j = 0; j < n; j++)
		count += abs(a[j] - a[j + 1]);
	int m = count;
	for (i = 1; i < n; i++)
	{
		count = m + abs(a[n]) - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]);
		printf("%d\n", count);
		count = m;
	}
	count = 0;
	for (j = 0; j < n - 1; j++)
	count += abs(a[j] - a[j + 1]);
	count = count + abs(a[n - 1]);
	printf("%d",count);
	return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
const ll INF = 1<<30;

ll N,M;
vector<vector<ll> > Edge;
vector<ll> v;

bool search();

int main(){
    cin >> N >> M;
    Edge.resize(N);
    v.resize(N-1);
    rep(i,M){
        ll a, b; cin >> a >> b;
        a--; b--;
        Edge[a].push_back(b); Edge[b].push_back(a);
    }
    rep(i,N-1) v[i] = i+1;

    ll res = 0;
    if(search()) res++;
    while(next_permutation(v.begin(),v.end())){
        if(search()) res++;
    }
    cout << res << endl;
}

bool search(){
    int now = 0;
    bool ok;
    rep(i,N-1){
        ok = false;
        for(auto it : Edge[now]){
            if(it == v[i]){
                ok = true;
                now = v[i];
                break;
            }
        }
        if(!ok) return false;
    }
    return ok;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long n,a,b;
  cin>>n>>a>>b;
  long c=a+b;
  long j1=n/c;
  long j2=n%c;
  if(a<j2){
    cout<<a*j1+a<<endl;
  }
  else{
    cout<<a*j1+j2<<endl;
  }
  return 0;
}


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

int main(){
    long long s, sum = 0, array[10];
    int k;
    cin >> s;
    for(int i = 0; i < 10; i++){
        array[i] = (s / (int)pow(10, i)) % 10;
        //cout << array[i] << endl;
        if(array[i] != 0) k = i;
    } //cout << k << endl;
    for(int tmp = 0; tmp < (1<<k); tmp++){
        int max = -1, count = 0;
        bitset<10> s(tmp);
        //cout << s << endl;
        for(int i = 0; i < 10; i++){
            if(s.test(i) == 0){
                sum += array[i] * pow(10, count);
                count++;                
            }else{
                sum += array[i] * pow(10, count);
                count = 0;
            }
        }
        //cout << sum << endl;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int N,M;
int a[12][12],ans;

int main () {
	while(1) {
			ans = 0;
		scanf("%d%d",&N,&M);
		if(N == 0) break;
		for(int i = 1;i <= N;++i) {
			for(int j = 1;j <= M;++j) {
				scanf("%d",&a[i][j]);
			}
		}

        for(int i1 = 1;i1 <= N;++i1) {
			for(int j1 = 1;j1 <= M;++j1) {
                for(int i2 = 1;i2 <= N;++i2) {
					for(int j2 = 1;j2 <= M;++j2) {


                        if(  (i1 - i2 > 0 ? i1 - i2 : i2 - i1) < 2 || (j1 - j2 > 0 ? j1 - j2 : j2 - j1) < 2)
							continue;

						int x1 = min(i1,i2);
						int y1 = min(j1,j2);
						int x2 = max(i1,i2);
						int y2 = max(j1,j2);


						int Min = 0x3f3f3f3f;

						for(int i = y1;i <= y2;++i) {
                            Min = min(Min,a[x1][i]);
                            Min = min(Min,a[x2][i]);
						}
						for(int i = x1;i <= x2;++i) {
                            Min = min(Min,a[i][y1]);
                            Min = min(Min,a[i][y2]);
						}

						int re = 0;bool f = 0;

						for(int i = x1 + 1;i <= x2 - 1;++i) {
							for(int j = y1 + 1;j <= y2 - 1;++j) {
                                re += Min - a[i][j];
                                if(a[i][j] >= Min) {
									f = 1;
									break;
                                }
							}
						}
						if(!f) {
							ans = max(ans,re);
						}

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



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

typedef long long ll;

const ll MAX_N = 1e5 + 5;
ll n, q, N;
ll Arr[MAX_N];
ll cnt[MAX_N];
ll num[MAX_N];
ll psum[MAX_N];
vector <ll> vec;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> q;
	N = n;
	Arr[0] = n;
	for (ll i = 1; i <= q; i++)
		cin >> Arr[i];

	vec.push_back(Arr[0]);
	for (ll i = 1; i <= q; i++) {
		while (vec.size() && Arr[i] <= vec.back())
			vec.pop_back();

		vec.push_back(Arr[i]);
	}

	n = vec.size();
	for (ll i = 0; i < n; i++)
		Arr[i] = vec[i];

	num[n - 1] = 1;
	for (ll i = n - 1; i; i--) {
		num[i - 1] += (Arr[i] / Arr[i - 1]) * num[i];

		ll val = Arr[i] % Arr[i - 1];
		while (Arr[0] < val) {
			ll ind = upper_bound(Arr, Arr + n, val) - Arr - 1;

			num[ind] += val / Arr[ind] * num[i];
			val %= Arr[ind];
		}

		cnt[val] += num[i];
	}

	cnt[Arr[0]] += num[0];
	for (ll i = Arr[0]; ~i; i--)
		psum[i] = psum[i + 1] + cnt[i];

	for (ll i = 1; i <= Arr[0]; i++)
		cout << psum[i] << "\n";
	for (ll i = Arr[0] + 1; i <= N; i++)
		cout << "0\n";
	return 0;
}


Measured memory_bytes: 5748
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		double num=0d;
		while(sc.hasNext()) {
			num=Double.parseDouble(sc.next());
			num=num*633/81;
			System.out.println(num);
		}
	}
}


Measured memory_bytes: 26156
N, M, K = map(int, input().split())

class UnionFind:
	def __init__(self, n):
		self.groups = [g for g in range(n)]

	def get_root(self, i):
		parent = self.groups[i]
		if parent == i:
			return parent
		else:
			root = parent
			while True:
				tmp = self.groups[root]
				if tmp == root:
					break
				root = tmp
			
			while i != root:
				tmp = self.groups[i]
				self.groups[i] = root
				i = tmp
			
			return root
	
	def set_root(self, i, root):
		parent = self.groups[i]
		while parent != root:
			self.groups[i] = root
			i = parent
			parent = self.groups[i]
	
	def combine(self, i1, i2):
		self.set_root(i2, self.get_root(i1))
	
	def in_same_group(self, i1, i2):
		return self.get_root(i1) == self.get_root(i2)
	
	def counts(self):
		table = [None] * len(self.groups)
		for i in range(len(self.groups)):
			g = self.get_root(i)
			if table[g] != None:
				table[g] += 1
			else:
				table[g] = 1
		
		ret = [0] * len(self.groups)
		
		for i in range(len(self.groups)):
			ret[i] = table[self.get_root(i)]
		
		return ret
	
	def to_list(self):
		table = self.to_dic()
		return [table[g] for g in table]


groups = UnionFind(N)
minus_list = [0] * N

for _ in range(M):
	a, b = map(lambda x: int(x) - 1, input().split())
	groups.combine(a, b)
	minus_list[a] -= 1
	minus_list[b] -= 1

for _ in range(K):
	c, d = map(lambda x: int(x) - 1, input().split())
	if groups.in_same_group(c, d):
		minus_list[c] -= 1
		minus_list[d] -= 1

counts = groups.counts()

print(" ".join((str(counts[i] + minus_list[i] - 1) for i in range(N))))




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

int main() {

    int n,k;
    int h[n_max];
    cin>>n>>k;
    int count=0;
    rep(i,n)    cin>>h[i];
    rep(i,n) {
        if(h[i]>=k) {
            count++;
        }
    }
    cout<<count<<endl;


  
 return 0;
}

Measured memory_bytes: 640
n = input()
a = map(int, raw_input().split())
min = a[0]
max = a[0]
sum = 0
for i in range(n):
    if min > a[i]:
        min = a[i]
    if max < a[i]:
        max = a[i]
    sum += a[i]
print min, max, sum

Measured memory_bytes: 7084
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

//#include<bits/stdc++.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define _USE_MATH_DEFINES
#define ll long long
#define ins Not Needed Thing
#define ull unsigned long long
#define ld long double
#define Accepted 0
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define SORRY FUL Accepted 
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
#define Toktama Kazakhstan 

using namespace std;

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e5 + 123;                                          
const int PRI = 555557;
const int pri = 997;

int tests = 1;

int cnt[N], n, m;

inline void Solve () {
	//easy

	cin >> n >> m;
	for (int i = 1; i <= m; i ++) {
		int l, r;
		cin >> l >> r;
		++ cnt[l];
		cnt[r] ++;
	}

	for (int i = 1; i <= n; i ++) {
		if(cnt[i] & 1) {
			cout << "NO";
			exit(0);
		}
	}

	cout << "YES";
		
}

int main () {
	SpeedForce;
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);	
	// cin >> tests;
	while(tests --) {
		Solve ();
		// Ee Zadrot
	}

	return Accepted; 
}

Measured memory_bytes: 640
using System;
namespace ABC148
{
    public class D
    {
        private static int Solve(int n, int[] a)
        {
            var counter = 1;
            foreach (var i in a)
            {
                if (i == counter)
                {
                    ++counter;
                }
            }
            if (counter == 1) return -1;
            return n - counter + 1;
        }

        static void Main(string[] args)
        {
            var line = Console.ReadLine();
            var n = Convert.ToInt32(line);
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32);

            Console.WriteLine(Solve(n, a));
        }
    }
}


Measured memory_bytes: 31580
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 20;
const int MAXM = 32770;
const int mod = 1e9 + 7;

int n, m, bin[MAXN * MAXN], e[MAXM], f[MAXM];

inline int F(int x, int y)
{
	return e[x | y] - e[x] - e[y];
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), m = Read(), bin[0] = 1;
	for (int i = 1; i <= m; i ++)
		bin[i] = 1LL * bin[i - 1] * (mod + 1) / 2 % mod;
	for (int i = 1; i <= m; i ++)
		for (int j = 0, x = Read() - 1, y = Read() - 1; j < 1 << n; j ++)
			if ((j >> x & 1) && (j >> y & 1))
				e[j] ++;
	for (int i = 0; i < 1 << n; i ++)
		if ((i & 1) && !(i & 2))
		{
			f[i] = 1;
			for (int j = i - 1; j; j = j - 1 & i)
				if (j & 1)
					f[i] = (f[i] - 1LL * f[j] * bin[F(j, j ^ i)] % mod + mod) % mod;
		}
		else if ((i & 2) && !(i & 1))
		{
			f[i] = 1;
			for (int j = i - 1; j; j = j - 1 & i)
				if (j & 2)
					f[i] = (f[i] - 1LL * f[j] * bin[F(j, j ^ i)] % mod + mod) % mod;
		}
	for (int i = 0; i < 1 << n; i ++)
		f[i] = 1LL * f[i] * bin[F(i, (1 << n) - 1 ^ i)] % mod;
	int ans = 1;
	for (int i = 0; i < 1 << n; i ++)
		if ((i & 1) && !(i & 2))
			for (int j = (1 << n) - 1 - i; j; j = j - 1 & (1 << n) - 1 - i)
				if ((j & 2) && !(j & 1))
					if (!F(i, j))
						ans = (ans - 1LL * f[i] * f[j] % mod + mod) % mod;
	for (int i = 1; i <= m; i ++)
		ans = (ans << 1) % mod;
	return printf("%d\n", ans), 0;
}


Measured memory_bytes: 512
//ITP1_9 Finding a Word

#include<iostream>
#include<string.h>
using namespace std;

int main(){
	//単語の読み込み
	string W, P;
	cin >> W;
	for(int i = 0; i < W.length(); i++){
		W[i] = tolower(W[i]);
	}
	
	//文章の読み込む+Wと一致するかの判定
	int count = 0;
	while(1){
		cin >> P;
		if(P == "END_OF_TEXT")
			break;
		for(int i = 0; i < P.length(); i++){
			P[i] = tolower(P[i]);
		}
		if(P == W)
			count++;
	}
	cout << count << endl;
	return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n;
    cin >> n;
    int h[n];
    REP(i,n)cin >> h[i];

    int count = 0;
    while(1){
        if(*max_element(h,h+n)==0)break;
        int i = 0;
        while(i<n){
            if(h[i]==0)i++;
            else{
                ++count;
                while(i<n&&h[i]!=0){
                    h[i]--;
                    ++i;
                }
            }
        }
    }
    COUT(count);
    return 0;
} 

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut text = String::new();
    io::stdin().read_line(&mut text).expect("");
    let mut split = text.split_whitespace();
    let n = split.next().unwrap().parse::<u32>().unwrap();
    let k = split.next().unwrap().parse::<u32>().unwrap();
    println!("{}", k * (k - 1).pow(n - 1));
}


Measured memory_bytes: 380
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n;
int a[2][105];
int ruisekiwa[2][105];
int ans = 0;
/**********************************************/

int main(){
    cin >> n;
    REP(i, n) cin >> a[0][i];
    REP(i, n) cin >> a[1][i];
    
    ruisekiwa[0][0] = 0;
    ruisekiwa[1][0] = 0;
    FOR(i, 1, n+1){
        ruisekiwa[0][i] = ruisekiwa[0][i-1] + a[0][i-1]; 
        ruisekiwa[1][i] = ruisekiwa[1][i-1] + a[1][i-1]; 
    }
    REP(i, n){
        ans = max(ruisekiwa[0][i+1] + ruisekiwa[1][n] - ruisekiwa[1][i], ans);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
my $N = <STDIN>;
chomp($N);
my $a = <STDIN>;
chomp($a);
my @A = split(/ /,$a);
my $b = <STDIN>;
chomp($b);
my @B = split(/ /,$b);
my $c = <STDIN>;
chomp($c);
my @C = split(/ /,$c);


my $sum = 0;
my $tmp = -10;
for(0..$N-1){
    $sum += $B[$A[$_]-1];
    if($tmp+1 == $A[$_]){$sum += $C[$tmp-1];}
    $tmp = $A[$_];
}


   print "$sum\n";
1;


Measured memory_bytes: 512
import sys
from collections import Counter

def cmb2(n):
	if n < 2:
		return 0

	return n * (n-1) // 2

if __name__ == "__main__":

	N = int(input())
	A = [int(i) for i in input().split()]
	# A = list(map(int, input().split()))

	c = Counter(A)
	s = 0
	for v in c.values():
		s += cmb2(v)

	for a in A:
		print(s - cmb2(c[a]) + cmb2(c[a] - 1))

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

using namespace std;

int64_t gcd(int64_t a, int64_t b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  else return gcd(a - b, b);
}

int64_t lcm(int64_t a, int64_t b) {
  int64_t d = gcd(a, b);
  return a / d * b;
}

int64_t power2(int64_t n) {
  int cnt = 0;
  for (; n % 2 == 0; n /= 2) {
    ++cnt;
  }
  return cnt;
}

int64_t solve() {
  int64_t n, m;
  cin >> n >> m;
  int64_t mul = 1;
  int64_t p2 = -1;
  for (int64_t i = 0; i < n; ++i) {
    int64_t a;
    cin >> a;
    if (p2 == -1) p2 = power2(a / 2);
    else if (p2 != power2(a / 2)) return 0;
    mul = lcm(mul, a / 2);
    if (mul > m) return 0;
  }
  auto step = mul * 2;
  int64_t cnt = 0;
  for (int64_t x = mul; x <= m; x += step) {
    ++cnt;
  }
  return cnt;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << solve() << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int tax(int rate,int price_without_tax)
{
  int price_after_tax;
  price_after_tax=price_without_tax*(100+rate)/100;
  return price_after_tax;
}

int main()
{
  int maximum;
  int x,y,s;
  while(1)
  {
    maximum=0;
    cin>>x>>y>>s;
    if(x!=0&&y!=0&&s!=0)
    {
      for(int i=1;i<s;i++)
	{
	  for(int j=i;j<s;j++)
	    {
	      if(tax(x,i)+tax(x,j)==s)
		{
		  maximum=max(maximum,tax(y,i)+tax(y,j));
		}
	    }
	}
      cout<<maximum<<endl;
    }
    else
      break;
  }
}

Measured memory_bytes: 2976
#include <stdio.h>

typedef struct { char suit, value; } Card;

void bubble(Card A[], int N) {
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

/* オリジナル関数を追加 */
void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}


Measured memory_bytes: 2148
#include<stdio.h>
#include<stdlib.h>
int main(){
 char ch;
 int i,k;
 int num[26]={0};

 while(scanf("%c",&ch) != EOF){

  if(ch>='a' && ch<='z'){/*?°?????????????*/

  for(k='a';k<='z';k++){
   if(ch==k){
    num[k-'a']+=1;
   }
  }

 }else if(ch>='A' && ch<='Z'){/*??§????????????*/

  for(k='A';k<='Z';k++){
   if(ch==k){
    num[k-'A']+=1;
   }
  }

  }else if(ch=='\0'){
   break;
  }

 }

 
 for(i=0;i<26;i++){
  printf("%c : %d\n",'a'+i,num[i]);
 }




return 0;
}

Measured memory_bytes: 540
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <numeric>
#include <iomanip>

int main(void) {
	long long n, k;

	std::cin >> n >> k;

	std::vector<long long> v(n);
	long long bit[64] = { 0 };
	for (size_t i = 0; i < n; i++) {
		std::cin >> v[i];
		long long tmp = v[i];
		long long j = 0;
		while (tmp != 0) {
			bit[j] += tmp % 2;
			tmp /= 2;
			j++;
		}
	}

	long long a = 1099511627776LL;

	long long aa = 0;
	long long i = 40;
	while (a != 0) {
		if (k >= a) {
			if (bit[i] < (n + 1) / 2) {
				aa += a;
				k -= a;
			}
		}
		i--;
		a /= 2;
	}

	long  long ans = 0LL;

	for (size_t i = 0; i < n; i++) {
		v[i] ^= aa;
		ans += v[i];
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,Pll> a,pair<ll,Pll> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se.fi>b.se.fi;
}
//----------------------------------------------------------------------
ll cnt[100010];
bool red[100010];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //-------------------------------
    ll n,m;cin>>n>>m;
    ll ans=1;
    for(ll i=0;i<n;i++)cnt[i]=1;
    red[0]=1;
    for(ll i=0;i<m;i++){
        ll x,y;cin>>x>>y;
        x--;y--;
        cnt[x]--;
        cnt[y]++;
        if(red[x]){
            if(cnt[x]==0){
                red[x]=0;
                ans--;
            }
            if(red[y]==0)ans++;
            red[y]=1;
        }
    }
    cout<<ans<<endl;
    //-------------------------------  
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------






















































Measured memory_bytes: 1152
#include <iostream>
#include <string.h>
using namespace std;

int howmany(char a, char b, char c){
  int ans=0;
  char res=a;
  if(b==c)
      res = b;
  if(a!=res) ans++;
  if(b!=res) ans++;
  if(c!=res) ans++;
  return ans;
}

int main() {
  int n;
  cin >> n;
  char a[n]; char b[n]; char c[n];
    
  string s;
  cin >> s;
  for(int i=0; i<n; i++){
    a[i] = s[i];
  }
  cin >> s;
  for(int i=0; i<n; i++){
    b[i] = s[i];
  }
  cin >> s;
  for(int i=0; i<n; i++){
    c[i] = s[i];
  }
  
  int res=0;
  for(int i=0; i<n;i++)
      res += howmany(a[i],b[i],c[i]);
    std::cout << res;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <regex>
#include <locale>

#include <iomanip>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_Len=int(b);i<i##_Len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

int main () {
  int x, a, b;
  cin >> x >> a >> b;
  cout << (abs(a-x) < abs(b-x) ? "A" : "B") << endl;
}

Measured memory_bytes: 3048
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <stack>
#include <set>
#include <vector>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INF = 987654321;
const double EPS = 1e-10;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
    return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
    os<<'[';
    rep(i,a.size()) os<<(i?" ":"")<<a[i];
    return os<<']';
}

int G[20][20];
int dp[20][20];
int V;

void warshall_floyd() {
    rep(k, V) rep(i, V) rep(j, V) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
}


int main() {
    int n; cin >> n;
    int m; cin >> m;
    rep(i, 20) rep(j, 20) G[i][j] = INF;
    rep(i, m) {
        int a, b, c, d; scanf("%d,%d,%d,%d", &a, &b, &c, &d);
        G[a - 1][b - 1] = c;
        G[b - 1][a - 1] = d;
    }
    int x1, x2, y1, y2; scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);

    V = n;
    rep(i, n) rep(j, n) dp[i][j] = G[i][j];
    rep(i, n) dp[i][i] = 0;

    warshall_floyd();
    cout << y1 - dp[x1 - 1][x2 - 1] - dp[x2 - 1][x1 - 1] - y2 << endl;

    return 0;
}

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

int main()
{
	int h, w;
	int a[501][501] = {};
	vector<pair<pair<int, int>, pair<int, int>>> ans;
	cin >> h >> w;
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < h; ++i)
	{
		if (i % 2)
		{
			for (int j = w-1; j > 0; --j)
			{
				if(a[i][j] % 2)
				{
					a[i][j] -= 1;
					a[i][j-1] += 1;
					ans.push_back(make_pair(make_pair(i, j), make_pair(i, j-1)));
				}
			}
			if(a[i][0] % 2 && i != h - 1)
			{
				a[i][0] -= 1;
				a[i+1][0] += 1;
				ans.push_back(make_pair(make_pair(i, 0), make_pair(i+1, 0)));
			}
		}
		else
		{
			for (int j = 0; j < w - 1; ++j)
			{
				if(a[i][j] % 2)
				{
					a[i][j] -= 1;
					a[i][j+1] += 1;
					ans.push_back(make_pair(make_pair(i, j), make_pair(i, j+1)));
				}
			}
			if(a[i][w-1] % 2 && i != h - 1)
			{
				a[i][w-1] -= 1;
				a[i+1][w-1] += 1;
				ans.push_back(make_pair(make_pair(i, w-1), make_pair(i+1, w-1)));
			}
		}
	}
	cout << ans.size() << endl;
	for (auto it = ans.begin(); it != ans.end(); ++it)
	{
		cout << (*it).first.first+1 << " " << (*it).first.second+1 << " " << (*it).second.first+1 << " " << (*it).second.second+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
// const int N = 2005;

const int N = 100005;

int32_t main() {

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

	int n,k;
	cin >> n >> k;

	vector<int> left;
	vector<int> right;

	int x;
	rep(i,n) {
		cin >> x;
		if(x > 0) right.pb(x);
		else left.pb(-x);
	}

	sort(all(left));

	int ans = inf, l = sz(left), r = sz(right);
	rep(i,k+1) {
		int temp = inf, fi = i-1, sec = k-i-1;
		if(fi >= l || sec >= r)
			continue;

		if(fi < 0) {
			temp = right[sec];
		}
		else if(sec < 0) {
			temp = left[fi];
		}
		else {
			temp = 2*left[fi] + right[sec];
			temp = min(temp, 2*right[sec] + left[fi]);
		}

		ans = min(ans, temp);
	}

	cout << ans << '\n';
}

Measured memory_bytes: 1656
A,B,C,D=map(int, list(input()))
L=["+","-"]

for i in L:
    for j in L:
        for k in L:
            now=A
            if i=="+":
                now+=B
            else:
                now-=B
            if j=="+":
                now+=C
            else:
                now-=C
            if k=="+":
                now+=D
            else:
                now-=D
            if now==7:
                print(str(A)+i+str(B)+j+str(C)+k+str(D)+"=7")
                exit()

Measured memory_bytes: 3064
var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  var antena=[];
  for(var i=0;i<lines.length;i++){
    antena.push(Number(lines[i]));
  } 
  if(antena[antena.length-1]<Math.max.apply(null, antena)-Math.min.apply(null,antena)){
  	console.log(":(");
  }else{
  	console.log("Yay!");
  }
});

Measured memory_bytes: 7500
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,m,lot[30];
  for(int i=0; i<30; i++){
    lot[i] = i+1;
  }
  cin >>n>>m;
  for(int i=0,a,b,c; i<m; i++){
    scanf("%d,%d",&a,&b);
    c = lot[a-1];
    lot[a-1] = lot[b-1];
    lot[b-1] = c;
  }
  for(int i=0; i<n; i++){
    cout <<lot[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
using System;

namespace AtCoder0614
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int[] x = new int[5];

            for (var i = 0; i < input.Length; i++) {
                x[i] = int.Parse(input[i]);
            }

            for (var i = 0; i < 5; i++) {
                if (x[i] == 0)
                {
                    Console.WriteLine(i + 1);
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 27564
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int mod=13,wmh=1e9+7;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
char s[maxn];
int n,f[maxn][13];
inline int ksm(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1ll*ans*a%mod;
		a=1ll*a*a%mod;b>>=1;
	}
	return ans;
}
int tmp[10];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	reverse(s+1,s+1+n);
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		if(s[i]=='?'){
			int alfa=ksm(10,i-1);
			for(int k=0;k<=9;k++){
				tmp[k]=k*alfa%mod;
			}
			for(int j=0;j<=12;j++){
				for(int k=0;k<=9;k++){
					int qaq=(tmp[k]+j)%mod;
					f[i][qaq]=(f[i][qaq]+f[i-1][j])%wmh;
				}
			}
		}
		else{
			int alfa=ksm(10,i-1);
			int tmp=(s[i]-'0')*alfa%mod;
			for(int j=0;j<=12;j++){
				int qaq=(tmp+j)%mod;
				f[i][qaq]=(f[i][qaq]+f[i-1][j])%wmh;
			}
		}
	}
	printf("%d\n",f[n][5]);
	return 0;
}


Measured memory_bytes: 5504
import sys
input=sys.stdin.readline

def main():
    n,m=map(int,input().split())
    Cost=[0]*m
    Key=[0]*m
    for i in range(m):
        a,b=map(int,input().split())
        C=tuple(map(int,input().split()))
        Cost[i]=a
        for c in C:
            Key[i]+=1<<(c-1)
    DP=[[float('inf')]*(1<<n) for _ in range(m+1)]
    DP[0][0]=0
    for i,(c,k) in enumerate(zip(Cost,Key)):
        for j in range(1<<n):
            DP[i+1][j]=min(DP[i][j],DP[i+1][j])
            DP[i+1][j|k]=min(DP[i+1][j|k],DP[i][j]+c)
    print(-1 if DP[-1][-1]==float('inf') else DP[-1][-1])

if __name__=='__main__':
    main()

Measured memory_bytes: 141020
def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    cnt = 0
    i = 0
    for i in range(N):
        if P[i] == i+1:
            if i+1 >= N:
                P[i],P[i-1] = P[i-1],P[i]
            else:
                P[i],P[i+1] = P[i+1],P[i]
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 52332
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;

int pop_count(int x){
    int cnt = 0;
    for(int i = 0;i < 20;i++){
        if(((x >> i)&1) == 1)cnt++;
    }
    return cnt;
}
string to_binary(int mask){
    int n = 20;
    string res = "";
    for(int i = 0;i < n;i++){
        res += ( ((mask>>i)&1) ? '1' : '0');
    }
    reverse(res.begin(),res.end());
    return res;
}
int dp[(1 << 18)][18];
bool possible[(1 << 18)][18];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    int n;cin >> n;
    vector<pair<int,int> > a(n);
    for(int i = 0;i < n;i++)cin >> a[i].first;
    for(int i = 0;i < n;i++)cin >> a[i].second;
    
    for(int i = 0;i < (1 << n);i++)for(int j = 0;j < n;j++)dp[i][j] = INT_MAX / 10;
    dp[0][0] = 0;
    for(int mask = 0;mask < (1 << n);mask++){
        if(mask == 0){
            for(int i = 0;i < n;i++){
                possible[mask | (1 << i)][i] = 1;
                dp[mask | (1 << i)][i] = 0;
            }
        }else{
            for(int i = 0;i < n;i++){
                if(!(mask & (1<<i)))continue;
                for(int j = 0;j < n;j++){
                    if(mask & (1 << j))continue;
                    int sz = pop_count(mask);
                    int last,next;
                    if((i - (sz-1))%2==0){
                        last = a[i].first;
                    }else{
                        last = a[i].second;
                    }
                    if((j - sz)%2 ==0){
                        next = a[j].first;
                    }else{
                        next = a[j].second;
                    }
                    if(last > next or !possible[mask][i])continue;
                    else{
                        int cnt = 0;
                        for(int k = j+1;k < n;k++){
                            if(mask & (1 << k))cnt++;
                        }
                        possible[mask | (1 << j)][j] = 1;
                        dp[mask | (1 << j)][j] = min(dp[mask | (1 << j)][j],dp[mask][i] + cnt);
                    }
                }
            }
        }
    }
    int ans = INT_MAX;
    for(int i = 0;i < n;i++){
        if(possible[(1 << n)-1][i]){
//            cout << i << ' ' << dp[(1 << n)-1][i] << '\n';
            ans = min(ans,dp[(1<<n)-1][i]);
        }
    }
    if(ans == INT_MAX)cout << -1 << '\n';
    else cout << ans << '\n';
    return 0;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;
ll comb(ll a, ll b);
int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    ll n;
    ll a, b;
    cin >> n >> a >> b;
    ll blue = n / (a + b) * a;
    n = n % (a + b);
    
    if (n > a)
    {
        blue += a;
    }
    else
    {
        blue += n;
    }
    c(blue);

    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int e = a+b;
    int f = c +d;
    if(e>f) cout << "Left" << endl;
    else if(e<f) cout << "Right" << endl;
    else cout << "Balanced" << endl;
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll n;
	cin>>n;
	vector<ll> a(n);
	rep(i, n) cin>>a[i];
	ll s = 0;
	rep(i, n) s += a[i];
	ll r = n*(n+1)/2;
	ll t = s/r;
	bool res = true;
	if(t*r!=s) res = false;
	rep(i, n) if((a[i]+t-a[(i+1)%n])%n) res = false;
	rep(i, n) if(a[i]+t<a[(i+1)%n]) res = false;
	cout<<(res?"YES":"NO")<<endl;
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<ll,pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    vector<int> c(n), ans(q), p(n, -1);
    vector<tuple<int, int, int>> r(q);
    rep(i, n){
        cin >> c[i];
        c[i]--;
    }
    rep(i, q){
        cin >> get<1>(r[i]) >> get<0>(r[i]);
        get<2>(r[i]) = i;
    }
    int j = 0;
    sort(all(r));
    BIT<int> bit(n);
    rep(i, q){
        while(j < get<0>(r[i])){
            if(p[c[j]] != -1)bit.add(p[c[j]]+1, p[c[j]]+2, -1);
            bit.add(j+1, j+2, 1);
            p[c[j]] = j;
            j++;
        }
        ans[get<2>(r[i])] = bit.sum(get<1>(r[i]), get<0>(r[i])+1);
    }
    rep(i, q)cout << ans[i] << endl;
}

Measured memory_bytes: 19360
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;


namespace abc95_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            int a = input[0];
            int b = input[1];
            int c = input[2];
            double x = input[3];
            double y = input[4];

            var tmp1 = a*x+b*y;
            var tmp2 = c*2*x;
            if(y - x > 0) tmp2 += (y-x)*b;
            var tmp3 = c*2*y;
            if(x - y > 0) tmp3 += (x-y)*a;
            WriteLine(Min(tmp1, Min(tmp2, tmp3)));

            //if(c*2 <= a && c*2 <= b)
            //{
            //    var max = Max(x,y);
            //    WriteLine(c*2*max);
            //}
            //else if(c*2 >= a+b)
            //{
            //    WriteLine(a*x+b*y);
            //}
            //else if(c <= b && c >= a)
            //{
            //    if(x-y<0)
            //    {
            //        WriteLine(c*2*x+(y-x)*b);
            //    }
            //    else
            //    {
            //        WriteLine(c*2*y+(x-y)*a);
            //    }
            //}
            //else
            //{
            //    if(y-x<0)
            //    {
            //        WriteLine(c*2*y+(x-y)*a);
            //    }
            //    else
            //    {
            //        WriteLine(c*2*x+(y-x)*b);
            //    }
            //}
        }
    }
}

Measured memory_bytes: 13396
n = gets.to_i
X = gets.chomp.split(" ", n).map(&:to_i)

max = X.max
min = X.min
ans = Float::INFINITY

(min..max).each do |i|
  cost = 0
  X.each do |x|
    cost += (x - i) ** 2
  end
  if ans > cost
    ans = cost
  end
end

p ans

Measured memory_bytes: 1788
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int M =nextInt();


		System.out.println(24+24-M);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204