akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 200 + 100;
const int MAXM = 10000000 + 100;

int pri[MAXM], totp = 0;
bool isp[MAXM];

void init()
{
	memset(isp, true, sizeof(isp));
	isp[0] = isp[1] = false;
	for(int i = 2; i < MAXM; i++)
	{
		if(isp[i])
			pri[++totp] = i;
		for(int j = 1; j <= totp && i * pri[j] < MAXM; j++)
		{
			isp[i * pri[j]] = false;
			if(i % pri[j] == 0) break;
		}
	}
}

struct Edge
{
	int next, to;
}
e[MAXN * MAXN];
int p[MAXN], l = 2;
void addE(int x, int y)
{
	e[l] = (Edge){p[x], y};
	p[x] = l++;
}
int size[2], vis[2][MAXN], match[2][MAXN];

bool dfs(int x)
{
	vis[0][x] = true;
	for(int i = p[x]; i; i = e[i].next)
		if(!vis[1][e[i].to])
		{
			int y = e[i].to;
			vis[1][y] = true;
			if(!match[1][y] || dfs(match[1][y]))
			{
				match[0][x] = y;
				match[1][y] = x;
				return true;
			}
		}
	return false;
}

int hungary()
{
	int ret = 0;
	for(int i = 1; i <= size[0]; i++)
	{
		memset(vis, 0, sizeof(vis));
		if(dfs(i))
			ret++;
	}
	return ret;
}

int n, a[MAXN], b[MAXN], id[MAXN];

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	init();

	int n0;
	cin >> n0;
	for(int i = 1; i <= n0; i++)
		cin >> a[i];
	a[0] = -1, a[n0 + 1] = MAXM + 1;

	for(int i = 1; i <= n0; i++)
	{
		if(a[i - 1] != a[i] - 1)
			b[++n] = a[i];
		if(a[i] + 1 != a[i + 1])
			b[++n] = a[i] + 1;
	}
	// for(int i = 1; i <= n; i++)
	// 	cerr << b[i] << ' ';
	// cerr << endl;

	for(int i = 1; i <= n; i++)
		id[i] = ++size[b[i] % 2];
	// cerr << size[0] << ' '<< size[1] << endl;

	for(int i = 1; i <= n; i++)
		if(b[i] % 2 == 0)
			for(int j = 1; j <= n; j++)
				if(b[j] % 2 == 1)
					if(isp[abs(b[i] - b[j])])
						addE(id[i], id[j]);
	int k = hungary();
	// cerr << k << endl;

	int ans = 1 * k + 2 * ((size[0] - k) / 2 + (size[1] - k) / 2) + 3 * ((size[0] - k) & 1);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 13952
#include<stdio.h>
int f[44];
int fib(int n){
    if( n==0 || n==1) return f[n] = 1;
    if(f[n]!=NULL) return f[n];
    return f[n] = fib(n-1)+fib(n-2);
}
int main(){
    int n;
    scanf("%d",&n);
    n = fib(n);
    printf("%d\n",n);
    return 0; 
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int k;
    cin>>k;
    long long int sum=0;
    for (int i=1;i<=k;i++) {
        for (int j=1;j<=k;j++) {
            for (int l=1;l<=k;l++) {
                int hoge=gcd(i,j);
                int tmp=gcd(hoge,l);
                sum+=tmp;
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3624
n=int(input())
l=[int(x) for x in input().split()]
d=[0]*n
if n-2>=0:
	d[-2]=abs(l[-2]-l[-1])

for i in range(n-3,-1,-1):
	mn=10**9
	mn=min(abs(l[i+1]-l[i])+d[i+1],mn)
	mn=min(abs(l[i+2]-l[i])+d[i+2],mn)
	d[i]=mn
print(d[0])	


Measured memory_bytes: 52336
N, K = map(int, input().split())
S = list(input())

if S[K-1] == 'A':
    S[K-1] = 'a'
elif S[K-1] == 'B':
    S[K-1] = 'b'
else:
    S[K-1] = 'c'

for s in S:
    print(s, end='')
print()

Measured memory_bytes: 2940
#include<stdio.h>

int main(void){
	int a,b;
	int x,y;
	scanf("%d %d",&a,&b);
	if(1 <= a && b <= 100){
		x = a*b;
		y = a*2+b*2;
		printf("%d %d\n",x,y);
	}
	return 0;
}


Measured memory_bytes: 2072
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    bool f = false;
    while(true){
        if(f){
            a-=d;
        }else{

            c-=b;
        }
        f=!f;
        if(c<=0){
            cout<<"Yes"<<endl;
            break;
        }else if(a<=0){
            cout<<"No"<<endl;
            break;
        }
    }





return 0;
}


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

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	n,a,b,c,d = linput()
	S = "_" + input().rstrip()
	
	res = 1
	#if c<d:
	X = S[a:c].count("##")
	X += S[b:d].count("##")
	if X!=0: res=0
	
	if c>d:
		Y = S[b-1:d+2].count("...")
		if Y==0: res=0
	
	sT = "No Yes".split()
	print(sT[res])

if __name__ == "__main__":
	main()


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


int main() {
   int k, arr[5], x;

 
   x = 0;

   for(int i = 0; i < 5; i++){
       cin >> arr[i];
   }
  
   cin >> k;
   

   for(int i = 1; i < 5; i++){
       for(int j = 0; j < i; j++){
           if((arr[i]-arr[j])>k){
              x++;
           }
       }
   }

   if(x > 0){
       cout << ":(" << endl;
   }
   else{
       cout << "Yay!" << endl;
   }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  string ans;
  cin >> s;
  for(int i = 0; i < s.size(); i++) {
    char a = s[i];
    if(a == 'B') {
      if(ans.size() != 0) { ans.pop_back(); }
    } else {
      ans.push_back(a);
    }
  }

  cout << ans << endl;

  return 0;
}

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

#pragma region template


// -type-
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;


// -const-
const ll MOD = 1000000007;


const ll MAX = (ll)0x3f0000003f000000;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// -define-
#define F first
#define S second

#define reps(i, k, n) for (int i = (k), i##_len = (n); i < i##_len; ++i)
#define rep(i, n) reps(i, 0, n)
#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(x) ;
// #define debug(x) cerr << x << " (L:" << __LINE__ << ")" << '\n'


// -functions-

inline bool in(string s, string c) {
    return (s.find(c) != string::npos);
}
inline bool in(string s, char c) {
    return (s.find(c) != string::npos);
}

template <class T>
void print(T& x) {
    cout << x << '\n';
}

struct setup_main {
    setup_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(15);
    }
} setup_main_;

#pragma endregion

int ans = 0;
bool is_ans_eq_0(int n, string s) {
    rep(i1, n) rep(i2, i1) if (s[i1] == s[i2]) return false;
    return true;
}
void solve(int N, std::string S) {
    if (N < 30 and is_ans_eq_0(N, S)) return;
    int l1 = 0, l2 = 1, len = 1;
    while (l2 + len <= N) {
        while (l2 + len <= N) {
            if (S.substr(l1, len) == S.substr(l2, len)) {
                int m = N - l2 + 2;
                debug(m);
                while (S[l1 + len] == S[l2 + len] and (len < l2 - l1) and
                       (len < m)) {  // len+1 mozi
                    len++;
                    debug(len);
                }
            }
            l2++;
        }
        l1++;
        l2 = l1 + len;
    }
    ans = len;
}

signed main() {
    int N;
    cin >> N;
    std::string S;
    std::cin >> S;

    solve(N, S);

    print(ans);
    return 0;
}


Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    n = int(input())
    s = input()
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    cnt = 0
    for i in range(n-2):
        if s[i]+s[i+1]+s[i+2] == "ABC":
            cnt += 1

    print(cnt)
resolve()

Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    char str[1000];
    int n=0,sto[100],k=0,pow=1;
    while(cin>>str){
        for(int i=0;str[i]!='\0';i++){
            if(str[i]-'0'>=0&&str[i]-'0'<=9){
                k=0;
                for(int j=i;str[j] != '\0' && str[j]-'0'>=0&&str[j]-'0'<=9;j++){
                    sto[k]=str[j]-'0';

                    k++;
                }
               // cout<<k<<" "<<i<<endl;
                for(int j=0;j<k;j++){
                    //cout<<sto[j]<<endl;
                    if(sto[j]!=0){
                        pow = 1;
                        for(int l=1;l<k-j;l++)pow*=10;
                        //cout<<pow<<endl;
                        n+=sto[j]*pow;
                    }
                }
                i+=k-1;

            }
        }
        //cout<<n<<endl;

    }
    cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 1140
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc140/tasks/abc140_a>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    res = N*N*N;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	double a1, b1, c1, a2, b2, c2, A, B, C, X, Y;
	while (cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2) {
		A = a1, B = b1, C = c1;
		if (a1 != a2) {
			double tmp = a2 / a1;
			a1 *= tmp, b1 *= tmp, c1 *= tmp;
		}
		Y = (c2 - c1) / (b2 - b1);
		X = (C - B * Y) / A;
		printf("%.3f %.3f\n", X, Y);
	}
	return 0;
}


Measured memory_bytes: 3184
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);
    printf("%d", ((x-a)%b));
}


Measured memory_bytes: 3824
/**
	������������ Author : Avi J Patel ������������
	������������ University : DA-IICT ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define N 100000
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 1000005
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
/*
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}*/ 
int main()
{
	string s,cur;
	cin>>s;
	int cnt=1,i=1;
	int n=s.size();
	cur=s[0];
	//cout<<cur<<endl;
	while(i<n)
	{
		string s1="";
		s1+=s[i];
		i++;
		while(i<n && s1==cur)
		{
			s1+=s[i];
			i++;
		}
		cnt++;
		if(i==n && s1==cur)
		cnt--;
		//cout<<s1<<endl;
		cur=s1;
	}
	cout<<cnt;
	return 0;
}







Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
typedef long long LL;
using namespace std;

const LL mod = 1e9 + 7;
const LL MAXN = 1e3 + 10;
LL a[MAXN];

int main() {
	int T, xi = 0, yi = 0, ti = 0; 
	scanf("%d", &T);
	bool flag = true;
	while(T--) {
		int t, x, y;
		scanf("%d %d %d", &t, &x, &y);
		int ans = abs(x - xi) + abs(y - yi);
		if((t - ti - ans) % 2 || t < ans + ti) flag = false; 
		xi = x;
		yi = y;
		ti = t;
	}
	if(flag) printf("Yes\n");
	else puts("No");
	return 0;
}

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

main(){
	int n; cin>>n;
	
	int ans = 0;
	for(int i=1; i<n; i++){
		if(n%i) ans += (n/i);
		else ans += (n/i)-1;
	}
	cout<<ans;
}

Measured memory_bytes: 3644
#include <stdio.h>

int main()
{
    int card[9], n, b, i;

    for(i=0; i<9; i++) scanf("%d", &card[i]);

    scanf("%d", &n);
    for( ; n; n--)
    {
        scanf("%d", &b);
        for(i=0; i<9; i++) if(b==card[i]) card[i]=0;
    }

    (card[0]+card[1]+card[2] && card[3]+card[4]+card[5] && card[6]+card[7]+card[8] && card[0]+card[3]+card[6] && card[1]+card[4]+card[7] && card[2]+card[5]+card[8] && card[0]+card[4]+card[8] && card[2]+card[4]+card[6])? printf("No"): printf("Yes");
    return 0;
}


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

int main() {
    li N, A, B;
    cin >> N >> A >> B;

    li blue = 0;
    blue += A * (N / (A + B));
    blue += min(N % (A + B), A);
    cout << blue << endl;
    return 0;
}

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

ans1 = max(A)
diff = 10 ** 9 
for i in range(N):
  if abs(A[i] - ans1 / 2) <= diff:
    ans2 = A[i]
    diff = abs(A[i] - ans1 / 2)
print(ans1, ans2)

Measured memory_bytes: 14428
main = do
  n <- getLine
  s <- getLine
  putStrLn . show . solve $ s


solve :: String -> Int
solve s = solveHelper (0,0) s (calcEW s)

solveHelper (le, lw) [] (re,rw) = 0
solveHelper (le, lw) (x:[]) (re,rw) = lw
solveHelper (le, lw) (x:xs) (re,rw) = 
  if x == 'E' then 
    min (solveHelper (le+1,lw) xs (re-1,rw)) (lw + re - 1)
  else 
    min (solveHelper (le, lw+1) xs (re, rw-1)) (lw + re)

calcEW [] = (0,0)
calcEW (x:xs) = 
  let (e,w) = calcEW xs
  in if  x == 'E' then (e+1,w) else (e,w+1)

Measured memory_bytes: 55932
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <unordered_set>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
#define ll long long
#define pi (acos(-1))
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
unsigned ll f(unsigned ll x){
	if(x==1){return 1;}
	unsigned ll a=f(x/2);
	return a*2+1;
}
int main()
{
	unsigned ll n,k;cin>>n>>k;
 ll t =n%k ;cout<<min(t,llabs(t-k))<<endl;

    return 0;
}

ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}


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

int main() {
    int N, M;

    std::cin >> N >> M;

    std::vector<int> s(M);
    std::vector<int> c(M, -1);
    std::vector<int> ans(N, -1);

    // O(1)
    for (int i = 0; i < M; ++i) {
        std::cin >> s[i] >> c[i];
        ans[s[i]-1] = c[i];
    }

    // O(1): 条件が矛盾していたらだめ
    for (int i = 0; i < M; ++i) {
        if (ans[s[i]-1] != c[i]) {
            std::cout << -1 << std::endl;
            return 0;
        }
    }

    // 以下で条件を満たす数字を求める

    // 1桁の場合
    if (N == 1) {
        // 1桁目が-1だったら0を埋める
        if (ans[0] == -1) {
            ans[0] = 0;
        }
    } else { // 2桁以上の場合
        // 1桁目が0だったらだめ
        if (ans[0] == 0) {
            std::cout << -1 << std::endl;
            return 0;
        }

        // 1桁目が-1だったら1を埋める
        if (ans[0] == -1) {
            ans[0] = 1;
        }

        // 2桁目以降の-1に0を埋める
        for (int i = 1; i < N; ++i) {
            if (ans[i] == -1) {
                ans[i] = 0;
            }
        }
    }


    // // 1桁目に条件が指定されていない場合（-1）は1を埋める
    // if (ans[0] == -1) {
    //     ans[0] = 1;
    // }

    // // O(1): 2桁目以降の条件が指定されていない桁(-1)に0を埋める
    // for (int i = 1; i < N; ++i) {
    //     if (ans[i] == -1) {
    //         ans[i] = 0;
    //     }
    // }

    for (int i = 0; i < N; ++i) {
        std::cout << ans[i];
    }

    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

int n, L;
vector<lint> v;

lint rob() {
	lint ans = v[n-1];
	lint lans = 0;
	int zjed = -1;
	int zmin = -1;
	FOR(i,0,n) {
		if (i+i < n - 1) lans += 2LL * v[i];
		if (i+i == n - 1) {
			lans += v[i];
			zjed = i;
		}
		if (i+i == n) {
			lans -= v[i];
			zmin = i;
		}
		if (i+i > n) lans -= 2LL * v[i];
	}
	lans += (n-1)*1LL*L;
	ans = lans;
	int mam = n;
	int ind = 0;
	while (mam > 1) {
		lans -= L;
		lans -= 2LL * v[ind];
		if (zjed != -1) {
			lans += v[zjed];
			lans += v[zjed+1];
			zmin = zjed+1;
			zjed = -1;
		} else {
			lans += 2LL*v[zmin];
			zjed = zmin;
			zmin = -1;
		}
		mam--;
		ans = max(ans, lans);
		ind++;
	}
	return ans;
}

int main () {
	read2(L, n);
	readv(v, n);
	lint ans = rob();
	FOR(i,0,n) v[i] = L - v[i];
	sort(all(v));
	ans = max(ans, rob());
	printf("%lld\n", ans);
}	




Measured memory_bytes: 2420
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	int N;
	cin>>N;
	std::cout<<std::fixed;
	std::setprecision(8);
	vector<double>arr(N);
	for(int i=0;i<N;i++)
	    cin>>arr[i];
	sort(arr.begin(),arr.end());
	double ans=(arr[0]+arr[1])/2.0;
	for(int i=2;i<N;i++)
	    ans=(ans+arr[i])/2.0;
	cout<<ans;    
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX =100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX][MAX];

int prim(){
  int u,minv;
  int d[MAX],p[MAX],color[MAX];

  for(int i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }

  d[0]=0;
  while(1){
  minv=INFTY;
  u=-1;
  for(int i=0;i<n;i++){
    if(minv>d[i]&&color[i]!=BLACK){
      u=i;minv=d[i];
    }
  }
  if(u==-1)break;
  color[u]=BLACK;
  for(int v=0;v<n;v++){
    if(color[v]!=BLACK && M[u][v]!=INFTY){
      if(d[v]>M[u][v]){
        d[v]=M[u][v];
        p[v]=u;
        color[v]=GRAY;
      }
    }
  }
}
int sum=0;
for(int i=0;i<n;i++){

    if(p[i]!=-1)sum+=M[i][p[i]];
  

}
return sum;
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int e;cin>>e;
      M[i][j]=(e==-1)? INFTY : e;
    }
  }
  cout << prim()<<endl;
  return 0;
}



Measured memory_bytes: 3156
def acinput():
    return list(map(int, input().split(" ")))


def anumber(x):
    return ord(x)-ord("A")


S = input()

cnts = [0]*27

for s in S:
    cnts[anumber(s)] += 1

n2 = 0
for sc in cnts:
    if sc == 2:
        n2 = n2+1

if n2 == 2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import Debug.Trace
import Control.Monad
import qualified Data.Set as S

inputIntList :: IO [Int]
inputIntList = map read . words <$> getLine :: IO[Int]

getAs :: [String] -> [[Int]]
getAs [] = []
getAs (d:as:other) = (map read . words $ as :: [Int]) : (getAs other)


getAs'Set :: [[Int]] -> S.Set Int
getAs'Set as = foldr1 (\ s1 s2 -> S.union s1 s2) $ map (foldr (\x s -> S.insert x s) S.empty) as


getAnsList :: S.Set Int -> [Int] -> [Int]
getAnsList s = filter (flip S.notMember s)

main = do
    [n,k] <- map read . words <$> getLine :: IO[Int]
    co <- getContents
    print $ length (getAnsList (getAs'Set . getAs . lines $ co) [1..n])


Measured memory_bytes: 6576
#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>;

const ll INF = 1e18;
const int MX = 2005;

int main() {
  int n ,k,cnt=0;
  cin >> n >> k;
  vector <bool>A(n,false);
  rep(i,k){
    int d;
    cin >> d;
    rep(j,d){
      int a;
      cin >> a;
      A[a-1] = true;
    }
  }
  rep(i,n){
    if(!A[i]){
      cnt++;
    }
  }
  cout << cnt << endl;
   
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vint march(5,0);
    int n;
    cin >> n;
    REP(i,n){
        string s;
        cin >> s;
        if(s[0]=='M'){
            march[0]++;
        }else if(s[0]=='A'){
            march[1]++;
        }else if(s[0]=='R'){
            march[2]++;
        }else if(s[0]=='C'){
            march[3]++;
        }else if(s[0]=='H'){
            march[4]++;
        }
    }
    ll ans =0;
    for(int i=0;i<=2;i++){
        for(int j=i+1;j<=3;j++){
            for(int k=j+1;k<=4;k++){
                ans += (ll)march[i]*(ll)march[j]*(ll)march[k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = 0;

		while(1+c*(a-1) < b) c++;

		System.out.println(c);
	}
}

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

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

    double a, b, x;
    cin >> a >> b >> x;

    double r;
    if(x >= a * a * b / 2){
        r = atan(2 * (a * a * b - x) / (a * a * a));
    }else{
        r = atan(a * b * b / (2 * x));
    }
    
    double ans = r * 180.0 / M_PI;

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/* count # of paths that uses k edges (edge can repeat) */

const int mod = 1e9+7;
const int maxn = 55;
struct Matrix { int G[maxn][maxn]; };
int n; LL k;

Matrix operator * (const Matrix& a, const Matrix& b)
{
    Matrix c;
    FOR(i,1,n+1) FOR(j,1,n+1)
        c.G[i][j] = 0;
    FOR(k,1,n+1) FOR(i,1,n+1) FOR(j,1,n+1) {
        c.G[i][j] += 1LL * a.G[i][k] * b.G[k][j] % mod;
        c.G[i][j] %= mod;
    }
    return c;
}

Matrix pw(const Matrix& a, const LL k)
{
    if (k == 1)
        return a;
    const Matrix b = pw(a,k/2);
    return k&1 ? b*b*a : b*b;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    while (cin >> n >> k) {
        Matrix a;
        FOR(i,1,n+1) FOR(j,1,n+1)
            cin >> a.G[i][j];
        const Matrix c = pw(a,k);
        int ans = 0;
        FOR(i,1,n+1) FOR(j,1,n+1) {
            ans += c.G[i][j];
            ans %= mod;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
def main():
    a, b, c, d = map(int, input().split())
    answer = "Yes"
    while True:
        if a <= 0:
            answer = "No"
            break
        c -= b
        if c <= 0:
            answer = "Yes"
            break
        a -= d
    print(answer)


if __name__ == '__main__':
    main()



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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 100010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;
ll T,n;

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    vector<ll>a(n);
    map<ll,ll>m;
    for(int i=0;i<n;i++){
        cin >> a[i];
        m[a[i]]++;
    }
    ll ans = 0;
    for(auto it=m.begin();it!=m.end();it++){
        ll d = it->second;
        ans += (d*(d-1))/2;
    }
    for(int i=0;i<n;i++){
        ll d = m[a[i]];
        ll p = ans - (d*(d-1))/2 + ((d-1)*(d-2))/2;
        cout << p << "\n";
    }

    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<P, ll>;
using PP = pair<P ,P>;
constexpr ll MOD = 998244353;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), pa(n), pb(n);
    vector<P> ap(n), bp(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        ap[i] = P(a[i],i);
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
        bp[i] = P(b[i],i);
    }
    SORT(ap);
    SORT(bp);
    bool ok = true, flag = true;
    for(int i=0;i<n;i++){
        if(ap[i].first > bp[i].first) ok = false;
        pa[ap[i].second] = i;
        pb[bp[i].second] = i;
    }
    for(int i=0;i<n-1;i++){
        if(ap[i].first <= bp[i+1].first && ap[i+1].first <= bp[i].first){
            flag = false;
        }
    }
    if(flag){
        int s = bp[0].second, x = s, cnt = 0;
        while(1){
            int y = bp[pa[x]].second;
            if(y == s) break;
            x = y;
            cnt++;
        }
        if(cnt > n-2) ok = false;
    }
    if(!ok){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 4992
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    long double a;
    long double b;
    cin >> a >> b;

    cout << ull(a * b) << endl;

    return 0;
}

Measured memory_bytes: 3748
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	/** 文字列ABC */
	private static final char[] ABC = new char[] { 'A', 'B', 'C' };
	/** 文字? */
	private static final char ALL = '?';
	/** 1_000_000_007 */
	private static final long MOD = 1_000_000_007L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray();
			int n = s.length;
			long[][] dp = new long[n + 1][4];
			dp[n][3] = 1L;
			dp[n][0] = dp[n][1] = dp[n][2] = 0L;
			IntStream.rangeClosed(1, n).map(i -> n - i).forEach(i -> {
				dp[i][3] = ((ALL == s[i]) ? 3 : 1) * dp[i + 1][3] % MOD;
				IntStream.range(0, 3).forEach(j -> dp[i][j] = (((ALL == s[i]) ? 3 : 1) * dp[i + 1][j] % MOD
						+ (((ALL == s[i]) || (ABC[j] == s[i])) ? 1 : 0) * dp[i + 1][j + 1] % MOD) % MOD);
			});
			System.out.println(dp[0][0]);
		}
	}
}


Measured memory_bytes: 60576
var n,i,x,l,res:longint;
    a:array[1..100] of longint;
begin
  readln(n,x);
  for i:=1 to n do
    begin
      read(l);
      a[i]:=a[i-1]+l;
      if a[i] <= x then inc(res)
    end;
  write(res+1)
end.

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  int x; cin>>x;
  ll res = 1;
  for(int i = 2; i <= sqrt(x); i++){
    for(int p = 2; pow(i,p) <= x; p++){
      res = max((ll)pow(i,p),res);
      }

    }
    cout<<res<<endl;

  }



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


typedef long long ll;
struct Apple { ll v; int c; };
int main() {
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> lp(a);
  vector<ll> lq(b);
  vector<ll> lr(c);
  vector<Apple> la;
  for (ll &x : lp) { cin >> x; la.push_back((Apple){x, 0}); }
  for (ll &x : lq) { cin >> x; la.push_back((Apple){x, 1}); }
  for (ll &x : lr) cin >> x;
  sort(la.begin(), la.end(), [&](auto &l, auto &r){
    return l.v > r.v;
  });
  // sort(lp.begin(),lp.end(),greater<ll>());
  // sort(lq.begin(),lq.end(),greater<ll>());
  sort(lr.begin(),lr.end(),greater<ll>());
  vector<ll> vw(max(x+y+1, c+1));
  for (int i = 0; i < c; ++i) {
    vw[i+1] = vw[i]+lr[i];
    // cerr << i << " " << vw[i+1] << endl;
  }
  int r = 0, g = 0;
  int id = 0;
  ll ans = 0;
  ll v = 0;
  for (int i = 0; i < x+y; ++i) {
    Apple &a = la[id];
    while (r >= x && a.c == 0) {
      a = la[++id];
    }
    while (g >= y && a.c == 1) {
      a = la[++id];
    }
    v += a.v;
    if (a.c == 0) ++r;
    else ++g;
    ++id;
    // cerr << i << " " << v << " " << r << " "  << g << endl;
    ans = max(ans, v+vw[x+y-i-1]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 8688
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 998244353;

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n + 1), b(n), c(n + 1), d(n);
    for (Int i = 0; i < n + 1; i++) cin >> a[i];
    for (Int i = 0; i < n; i++) cin >> b[i];
    c = a;
    d = b;
    Int res1 = 0;
    for (Int i = 0; i < n; i++) {
       /*  if (a[i] <= b[i]) {
            b[i] -= a[i];
            res1 += a[i];
        }
        else if (a[i] > b[i]) {
            res1 += b[i];
            b[i] = 0;
        }
        if (a[i + 1] <= b[i]) {
            res1 += a[i + 1];
            a[i + 1] = 0;
        }
        else if (a[i + 1] > b[i]) {
            res1 += b[i];
            b[i] = 0;
        } */
        Int add = min(a[i], b[i]);
        res1 += add;
        a[i] -= add;
        b[i] -= add;
        add = min(a[i + 1], b[i]);
        res1 += add;
        a[i + 1] -= add;
        b[i] -= add;
    }
    dump(res1);
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    if(s.substr(0,4)=="YAKI")cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;

int main(){
    string a, b; cin >> a >> b;
    ll s = 0;
    if(a[0] == b[0]){s++;}
    if(a[1] == b[1]){s++;}
    if(a[2] == b[2]){s++;}
    prt(s);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int ans1,ans2;
int main(void){
    string s; cin>>s;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]!='0'){
                ans1++;
            }
        }else{
            if(s[i]=='0'){
                ans1++;
            }
        }
    }
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]=='0'){
                ans2++;
            }
        }else{
            if(s[i]!='0'){
                ans2++;
            }
        }
    }
    cout<<min(ans1,ans2)<<endl;

}



Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef long long ull;
typedef long double ld;

int main(){

    int fir,sec;
    fir = sec = 0;
    int a;
    cin >> a;
    vector<int>base;
    for(int i = 1;i<=a;i++)
        base.push_back(i);
    vector<int>firs(a);
    vector<int>seco(a);
    for(int i = 0;i<a;i++)
        cin >> firs[i];
    for(int i = 0;i<a ;i++)
        cin >> seco[i];
    int i = 1;
    do{
       if(firs==base)
                fir = i;
       if(seco==base)
            sec = i;
        if(fir!=0&&sec!=0)
            break;
       i++;
    }while(next_permutation(base.begin(),base.end()));
    cout << abs(sec-fir);
    return 0;
}








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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a+b < c+d) {
    cout << "Right" << endl;
  }
  else if (a+b == c+d)
    cout << "Balanced" << endl;
  else
    cout << "Left" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf LLONG_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define f first
#define s second

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


	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	ll ans=1;
	ll mn=a[0];
	for(ll i=1;i<n;i++)
	{
		if(a[i]<mn)
		{
			mn=a[i];
			ans++;
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <utility>

using namespace std;


//#define REP(i,n)	for(int i=0;i<(n);++i)
#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)


#define INF 		2000000007
#define MOD			998244353

#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;


int main(){
	//int N;cin >> N;
	int A,B;cin >> A>>B;

	if(A>=13)cout << B << endl;
	else if(A<=5) cout << 0 << endl;
	else cout << (B/2) << endl;



	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c;
	y = 0;
	for (int x = a; x <= b; x = x + 1) {
		if (0 == c % x) {
			y += 1;
		}
	}
	cout << y << endl;

	return 0;
}


Measured memory_bytes: 3116
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

int main() {

	const int N = read_item();
	const int Q = read_item();
	vector<pair<int,int>> queries(Q);
	for(auto i : range(Q)) {
		scanf("%d%d", &queries[i].first, &queries[i].second);
	}

	vector<int> beams[2];
	beams[0].push_back(-(N - 1));
	beams[1].push_back(-(N - 1));

	i64 black = (i64)(N - 2) * (N - 2);
	int last_dir = 1;

	for(auto q_i : range(Q)) {

		int dir = queries[q_i].first - 1;
		int op_dir = 1 - dir;
		int pos = queries[q_i].second - 1;

		int beam_idx = lower_bound(beams[dir].begin(), beams[dir].end(), -pos) - beams[dir].begin();

		if(beam_idx == beams[dir].size()) {
			int op_beam = -(*beams[op_dir].rbegin());
			int length = op_beam - 0;
			black -= (length - 1);
			dbg(length);
			if(last_dir == dir) {
				(*beams[dir].rbegin()) = -pos;
			} else {
				beams[dir].push_back(-pos);
				last_dir = dir;
			}
		} else {
			int op_beam_idx = (dir == 0) ? beam_idx - 1 : beam_idx;
			int op_beam = -(beams[op_dir][op_beam_idx]);
			int length = op_beam - 0;
			black -= (length - 1);
			dbg(length);
		}
	}

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

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 5380
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(void){
	string a,b;
	vector<int> ans;
	int n,num,ai,bi,c=0;
	bool flag;

	cin >> n;

	if(n>0&&n<=100){
		for(int i=0;i<n;i++){
			cin >> a >> b;
			flag=false;	

			for(int j=0;j<100;j++){
				num=0;
				ai=a.size()-j-1;
				bi=b.size()-j-1;
				if(ai<0&&bi<0&&c==0) break;
				if(ai>=0) num+=a[ai]-48;
				if(bi>=0) num+=b[bi]-48;
				ans.push_back((num+c)%10);
				if(num+c>=10) c=1;
				else c=0;
			}
			if(ans.size()>80){
				flag=true;
			}
			if(flag){
				cout << "overflow";
			}else{
				for(int j=ans.size()-1;j>=0;--j){
					cout << ans[j];
				}
			}
			cout << endl;
			ans.clear();
		}
	}
	return 0;
}

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

int main() {
	int H, W;
	while (true) {
		cin >> H >> W;
		if ((H == 0) && (W == 0)) break;
		for (int i = 1; i <= H; i++) {
			if (i % 2 == 1) {
				for (int j = 1; j <= W; j++) {
					if (j % 2 == 1)cout << "#";
					else cout << ".";
				}
				cout << endl;
			}
			else {
				for (int j = 1; j <= W; j++) {
					if (j % 2 == 0)cout << "#";
					else cout << ".";
				}
				cout << endl;
			}
		}
		cout << endl;
	}
}
	



Measured memory_bytes: 3088
#include <algorithm>
#include <iostream>

using namespace std;

int hoge[124], n;

int main()
{
    hoge[0] = 1;
    for (int i = 1; i <= 30; i++) {
        hoge[i] = hoge[i - 1];
        if (i > 1)
            hoge[i] += hoge[i - 2];
        if (i > 2)
            hoge[i] += hoge[i - 3];
    }
    while (cin >> n && n) {
        cout << ((hoge[n] / 10) / 365) + 1 << endl;
    }
}


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

int getGcd(int x, int y){
  if(y==0) return x;
  getGcd(y,x%y);
}

int main(){
  int a,b;
  while(scanf("%d%d",&a,&b)!=EOF)
    printf("%d %d\n",getGcd(a,b),a/getGcd(a,b)*b);
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int dx8[8]={1,0,-1,0,1,1,-1,-1};
int dy8[8]={0,1,0,-1,1,-1,1,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin>>n;
        vl A(n);
        rep(i,n){
            cin>>A[i];
            A[i]-=i+1;
        }
        sort(all(A));
        ll s=Size(A);
        ll m=s/2;
        ll sum=0;
        if(s%2==1){
            m=A[m];
            rep(i,n){
                sum+=abs(A[i]-m);
            }
        }else{
            m=A[m-1]+A[m];
            m/=2;
            rep(i,n){
                sum+=abs(A[i]-m);
            }
        }
        cout<<sum<<endl;
    }

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


int main() {
  string s; cin >> s;
  if(s == "Sunny")cout << "Cloudy" << endl;
  else if(s == "Cloudy")cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
}


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

int main(){
    long long N, A, B;
    cin >> N >> A >> B;
    
    long long ans;
    if(A == B)ans = 1;
    else if(N == 1 || A > B)ans = 0;
    else if(N == 2)ans = 1;
    else ans = (B * (N - 1) + A) - (A * (N - 1) + B) + 1;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256