akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
int main() {
	string str;
	cin >> str;
	char oldc;
	REP(i, str.size()) {
		if (i != 0 && str[i] == oldc) {
			cout << "Bad" << endl;
			return 0;
		}
		oldc = str[i];
	}
	cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
typedef long long ll;
using namespace std;
#define INFLL (1LL << 60)
#define rep(i, n) for(int i=0; i<(n); ++i)

int main()
{
	int N; ll W; cin >> N >> W;
	ll vs[40], ws[40];
	rep(i, N) cin >> vs[i] >> ws[i];

	auto bitCalc = [&](int D, int offset)
	{
		vector<pair<ll, ll>> items;
		for (int bit = 0; bit < 1 << D; ++bit) {
			pair<ll, ll> sum(0, 0);
			for (int i = 0; i < D; ++i) {
				if (bit & (1 << i)) {
					sum.first += vs[i + offset];
					sum.second += ws[i + offset];
				}
			}
			if (sum.second <= W) items.push_back(sum);
		}
		return items;
	};
	auto A = bitCalc(N / 2, 0);
	auto B = bitCalc((N + 1) / 2, N / 2);

	auto cmpr = [](pair<ll, ll> a, pair<ll, ll> b) {
		if (a.first != b.first) return a.first > b.first;
		return a.second < b.second;
	};

	sort(B.begin(), B.end(), cmpr);
	auto p = B[0];
	for (int i = 0; i < B.size() - 1; ++i) {
		if (B[i + 1].first <= p.first && B[i + 1].second >= p.second) {
			B[i + 1].first = 0;
			B[i + 1].second = INFLL;
		}
		else {
			p = B[i + 1];
		}
	}
	sort(B.begin(), B.end(), cmpr);

	ll ans = 0;
	for (auto a : A) {
		for (auto b : B) {
			if (a.second + b.second <= W) {
				ans = max(ans, a.first + b.first);
				break;
			}
		}
	}
	cout << ans << endl;;
	return 0;
}



Measured memory_bytes: 43656
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(mut a: usize, mut b:usize,k:usize);
    if a < k {
        if b < (k - a) {
            b = 0;
        } else {
            b -= k - a;
        }
        a = 0;
    } else {
        a -= k;
    }
    println!("{} {}", a, b);
}


Measured memory_bytes: 2172
#include<iostream>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>

using namespace std;

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  
  vector<int> x(N);
  vector<int> y(M);
  for (int i=0; i<N; i++) cin >> x[i];
  for (int i=0; i<M; i++) cin >> y[i];

  sort(x.begin(), x.end(), greater<int>());
  sort(y.begin(), y.end());

  X = (X < x[0])? x[0] : X;
  Y = (Y > x[0])? y[0] : Y;

  if (X < Y) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }
}


Measured memory_bytes: 256
fun main(args: Array<String>){
    val(n, q) = readLine()!!.split(" ").map(String::toInt)
    val s = readLine()!!
    val cumSum = mutableListOf(0)
    for(i in 1..(n - 1)){
        if(s.substring(i - 1, i + 1) == "AC") cumSum.add(cumSum[i - 1] + 1)
        else cumSum.add(cumSum[i - 1])
    }
    for(i in 1..q){
        val(l, r) = readLine()!!.split(" ").map(String::toInt)
        println(
            when {
                l == 1 -> cumSum[r - 1]
                s.substring(l - 2, l) == "AC" -> cumSum[r - 1] - cumSum[l - 2] - 1
                else -> cumSum[r - 1] - cumSum[l - 2]
            }
        )
    }
}

Measured memory_bytes: 73104
#include <bits/stdc++.h>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)
#define long long long

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<int, int> ii;
typedef pair<int, long> ill;
typedef pair<long, int> lli;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<pair<long, long>> vll;
typedef vector<ii> vii;
typedef vector<pair<ii, int>> viii;

const double PI = acos(-1.0), EPS = 1e-9;
const int MAXN = 100005, MAXM = 102, Mod = 998244353, MAXLog = 20;


int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout
            << fixed;

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int j = i;
        while (j < n && s[j] == s[i])
            ++j;
        ++ans;
        i = j - 1;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define PII pair<int, int>
#define LL long long
using namespace std;
const LL MOD = (LL) 1e9 + 7;
const int MAXN = 600005;

LL fac[MAXN], inv[MAXN];

LL qpow(LL a, LL pw) {
	LL res = 1;
	while (pw) {
		if (pw & 1) res = res * a % MOD;
		a = a * a % MOD;
		pw >>= 1;
	}
	return res;
}

LL C(int n, int k) {
	return fac[n] * inv[k] % MOD * inv[n - k] % MOD;
}

LL H(int n, int k) {
	return fac[n + k - 1] * inv[k - 1] % MOD * inv[n] % MOD;
}

LL N, M, L, R;

LL solve(LL S) {
	LL n1 = M, n2 = N - M, all = H(S, N + 1), sub = 0;
	for (int i = 1; i * n2 <= S; i++) {
		LL dist = S - i * n2, res1 = 0, res2 = 0;
		for (int j = 0; j <= n1 && j * i <= dist; j++) {
			LL to_add = C(n1, j) * H(dist - j * i, N + 1) % MOD * (j % 2 == 1 ? -1 : 1) % MOD;
			res1 = (res1 + to_add + MOD) % MOD;
		}
		
		if (dist >= n2) {
			dist -= n2;
			for (int j = 0; j <= n1 && j * i <= dist; j++) {
				LL to_add = C(n1, j) * H(dist - j * i, N + 1) % MOD * (j % 2 == 1 ? -1 : 1) % MOD;
				res2 = (res2 + to_add + MOD) % MOD;
			}
		}
		
		LL final = (res1 - res2 + MOD) % MOD * C(N, n1) % MOD;
		sub = (sub + final) % MOD;
	}
	
	return (all - sub + MOD) % MOD;
}

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

	fac[0] = inv[0] = 1;
	for (LL i = 1; i < MAXN; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = qpow(fac[i], MOD - 2);
	}

	cin >> N >> M >> L >> R;
	M = N - M;
	cout << (solve(R) - solve(L - 1) % MOD + MOD) % MOD << '\n';

	return 0;
}

Measured memory_bytes: 9600
n = int(input())

ls = list(map(int,input().split()))
mod = 10**9+7
acc = [0]

for a in ls:
  acc.append(acc[-1]+a)
  
ans = 0

for i in range(len(ls)-1):
  ans += ls[-i-1]*acc[-i-2]
  ans %= mod


print(ans)

Measured memory_bytes: 31548
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stdio.h>
typedef long long ll;
const int INF = 1e9+1;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;

int main() {
	int x, a, b;

	cin >> x >> a >> b;
	if (abs(x - a) > abs(x - b))cout << "B" << endl;
	else cout << "A" << endl;
}

Measured memory_bytes: 3620
import Control.Applicative ((<$>), (<*>))
import Data.List ((\\), intersect)

main :: IO ()
main = solve <$> (getLine >> f) <*> f >>= putStrLn
  where f = map read <$> words <$> getLine

solve :: [Int] -> [Int] -> String
solve ps is = unwords . map show . postOrder $ mkBTree ps is

data BTree a = Leaf | Node a (BTree a) (BTree a) deriving Show

mkBTree :: [Int] -> [Int] -> BTree Int
mkBTree [] [] = Leaf
mkBTree (p:ps) is = Node p (mkBTree lp li) (mkBTree rp ri)
  where (li,(_:ri)) = break (==p) is
        lp = ps `intersect` li
        rp = ps \\ lp

foldPost :: (a -> b -> b) -> b -> BTree a -> b
foldPost f z Leaf = z
foldPost f z (Node x l r) = let y1 = f x z
                                y2 = foldPost f y1 r
                            in foldPost f y2 l

postOrder :: BTree a -> [a]
postOrder = foldPost (:) []



Measured memory_bytes: 4156
#include<cstdio>
#include<iostream>
using namespace std;
int F[110][20];
int P[110][20];
int N;
int ans=-2147483647;
int tmp[20];
int count()
{
	int res=0;
	for(int i=0;i<N;i++)
	{
		int count=0;
		for(int j=0;j<10;j++)if(tmp[j]&&F[i][j])count++;
		res+=P[i][count];
	}
	return res;
}
void work(int time)
{
	if(time==10)
	{
		int cnt=0;
		for(int i=0;i<10;i++)cnt+=tmp[i];
		if(!cnt)return;
		int d=count();
		if(d>ans)ans=d;
		return;
	}
	tmp[time]=1;work(time+1);
	tmp[time]=0;work(time+1);
}
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)
		for(int j=0;j<10;j++)
			scanf("%d",&F[i][j]);
	for(int i=0;i<N;i++)
		for(int j=0;j<11;j++)scanf("%d",&P[i][j]);
	work(0);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
/* HARDWORK IS THE KEY TO SUCCESS.
   RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.!!!*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define T int t = 1; cin>>t; while(t--)
#define ain ll n,k,i; cin>>n; ll a[n]; for(i=0;i<n;i++) cin>>a[i]
#define matin ll m,n; cin >> n >> m; ll a[n + 1][m + 1]; for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) cin>>a[i][j];
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define I insert
#define pb push_back

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;
inline ll add(ll a, ll b) { return (mod + a + b) % mod;}
inline ll sub(ll a, ll b) {return (a - b + mod) % mod;}
inline ll mul(ll a, ll b) {return (1ll * a * b) % mod;}
ll fastpow(ll x, ll y) {
    ll res = 1; x = x % mod; while (y > 0) { if(y & 1) res = (res * x) % mod; y = y >> 1;x = (x * x) % mod;}return res;}
ll inv(ll x) {
    return fastpow(x, mod - 2);
}



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ain;
    ll sum = 0;
    unordered_map<ll,ll>mp;
    for(i = 0;i < n;++i)
    {
        mp[a[i]]++;
        sum += a[i];
    }
   
    ll q;
    cin >> q;
    while(q--)
    {
        ll A,B;
        cin >> A >> B;
        auto it = mp.find(A);
        if(it != mp.end())
        {
            sum -= mp[A] * A;
            sum += mp[A] * B;
           
           
            mp[B]+= mp[A];
             mp[A] = 0;
        }
        
             cout << sum << '\n';
    }
    
    
    
    
}

Measured memory_bytes: 7496
using System;
using System.Linq;

class B
{
	static void Main()
	{
		var s = Console.ReadLine();
		Console.WriteLine(string.Join("", s.Reverse()) == s && s[..(s.Length / 2)] == s[(s.Length / 2 + 1)..] ? "Yes" : "No");
	}
}


Measured memory_bytes: 26656
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

/*
 * (1 2) (1 3) (1 4) (2 4)
 * . . . . . . . 
 * . . . . . . .
 * . . . . . . .
 * . . . . . . .
 */
const int N = 400 * 1000 + 5;
pair <ll, pair<ll, ll>> p[N];
map <ll, ll> id;
int sz = 0;
void add_edge(ll x1, ll y1, ll x2, ll y2) {
	p[sz++] = {min(abs(x1 - x2), abs(y1 - y2)), {x1 * MOD + y1, x2 * MOD + y2}};
}
ll root(ll x) {
	if (x == id[x])
		return x;
	return id[x] = root(id[x]);
}
void union1(ll x, ll y) {
	ll pp = root(x);
	ll qq = root(y);
	id[pp] = qq;
}
int main() {
	int n;
	cin >> n;
	vector <pair<ll, ll>> vx, vy;
	vector <ll> x(n), y(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		vx.push_back({x[i], i});
		vy.push_back({y[i], i});
	}
	sort(all(vx));
	sort(all(vy));
	for (ll i = 0; i < n; i++) {
		auto itx = lower_bound(all(vx), make_pair(x[i], i));
		if (next(itx) != vx.end()) {
			add_edge(x[i], y[i], x[next(itx)->ss], y[next(itx)->ss]);
		}
		if (itx != vx.begin()) {
			add_edge(x[i], y[i], x[prev(itx)->ss], y[prev(itx)->ss]);
		}
		auto ity = lower_bound(all(vy), make_pair(y[i], i));
		if (next(ity) != vy.end()) {
			add_edge(x[i], y[i], x[next(ity)->ss], y[next(ity)->ss]);
		}
		if (ity != vy.begin()) {
			add_edge(x[i], y[i], x[prev(ity)->ss], y[prev(ity)->ss]);
		}
		id[x[i] * MOD + y[i]] = x[i] * MOD + y[i];
	}
	sort(p, p + sz);
	ll ans = 0;
	for (int i = 0; i < sz; i++) {
		ll w = p[i].ff;
		ll u = p[i].ss.ff;
		ll v = p[i].ss.ss;
		if (root(u) != root(v)) {
			union1(u, v);
			ans += w;
		}
	}
	cout << ans;
}	


Measured memory_bytes: 29924
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var nw = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var list = new List<Tuple<int, int>>();
        for (int i = 0; i < nw[0]; i++)
        {
            var line = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            list.Add(new Tuple<int, int>(line[0], line[1]));
        }
        var dp = new long[nw[0] + 1][];
        for (int i = 0; i < nw[0] + 1; i++) dp[i] = Enumerable.Repeat(10000000000, 100001).ToArray();
        dp[0][0] = 0;
        for (int i = 1; i <= nw[0]; i++)
        {
            for (int j = 0; j <= 100000; j++)
            {
                if (j - list[i - 1].Item2 >= 0)
                {
                    dp[i][j] = Math.Min(dp[i - 1][j], dp[i - 1][j - list[i - 1].Item2] + list[i - 1].Item1);
                }
                else dp[i][j] = dp[i - 1][j];
            }
        }
        for (int i = 100000; i >= 0; i--)
        {
            if (dp[nw[0]][i] <= nw[1])
            {
                Console.WriteLine(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 121560
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: Chars,
    }

    let zero = '0' as i32;
    println!(
        "{}",
        if n.iter().map(|c| *c as i32 - zero).sum::<i32>() % 9 == 0 {
            "Yes"
        } else {
            "No"
        }
    );
}


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

int main(){
	int n,k;
	cin >> n >> k;

	int a;
	vector<int>num(n+1,0);
	for(int i = 0; i < n; i++){
		cin >> a;
		num[a]++;
		//cout << "num" << a <<":"<< num[a] << endl;
	}

	sort(num.begin(), num.end(),greater<int>());
	int sum = 0;
	// for(int i = 0; i <=n ; i++){
	// 	cout << num[i] << endl;
	// }
	
	for(int i = k; i <= n; i++){
		sum += num[i];
	}
	cout << sum << endl;


	return 0;	
}

Measured memory_bytes: 1024
import sys

def main():
  input = sys.stdin.readline
  N, S = map(int, input().split())
  C = list(map(int, input().split()))
  C = list(set([abs(c - S) for c in C]))
  min_C = min(C)
  ans = 1
  for i in range(min_C, 1, -1):
    if min_C % i != 0:
      continue
    
    if all([c % i == 0 for c in C]):
      ans = i
      break
  print(ans)


if __name__ == '__main__':
  main()

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

using namespace std;

int main(){
  
  int n;
  string s;
  
  cin >> n ;
  cin >> s;
  
 if(n >= s.size()){
   cout << s << endl;
 }
  
  else{
    string t = " ";
    
    for(int i=0;i<n;i++){
      t += s[i];
    }
    
    t += "...";
    
    cout << t << endl;
  }
  
}
      

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int d;
    cin >> d;

    switch (d) {
    case 25:
        cout << "Christmas" << endl;
        break;

    case 24:
        cout << "Christmas Eve" << endl;
        break;

    case 23:
        cout << "Christmas Eve Eve" << endl;
        break;

    case 22:
        cout << "Christmas Eve Eve Eve" << endl;
        break;

    default:
        break;
    }

    return 0;
}

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

#define int long long

using namespace std;

const int INF = 1e18;

priority_queue<int> ql;
priority_queue<int, vector<int>, greater<int>> qr;
int q, suma, sumb;

int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> q;
    ql.push(-INF);
    qr.push(INF);
    while (q--) {
        int tp, a, b;
	cin >> tp;
        if(tp == 1){
	    cin >> a >> b;
            sumb += b;
            if (ql.size() == qr.size()){
                if (ql.top() > a || a > qr.top())
                    suma += min(abs(ql.top() - a), abs(a - qr.top()));
            }
	    else
                suma += abs(ql.top() - a);
            if (qr.top() <= a)
                qr.push(a);
	    else
                ql.push(a);
            if (ql.size() == qr.size() + 2){
                qr.push(ql.top());
                ql.pop();
            }
	    else if (ql.size() == qr.size() - 1){
                ql.push(qr.top());
                qr.pop();
            }
        }
	else
            cout << ql.top() << " " << suma + sumb << endl;
    }
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
string s;
int dp[1001000][2]; 
int main()
{
	cin>>s;
	dp[0][0]=min(s[0]-'0',11-(s[0]-'0'));
	dp[0][1]=min(s[0]-'0'+1,10-(s[0]-'0'));
	for(int i=1;i<=s.size();i++)
	{
		dp[i][0]=min(dp[i-1][0]+(s[i]-'0'),dp[i-1][1]+10-(s[i]-'0'));
		dp[i][1]=min(dp[i-1][0]+(s[i]-'0')+1,dp[i-1][1]+9-(s[i]-'0'));
	}
	cout<<dp[s.size()-1][0]<<endl;
	return 0;
}



Measured memory_bytes: 9220
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }





int main() {
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> g(n);
    REP(i, m){
        ll a, b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    
    bool nibu = true;
    vector<ll> color(n);
    queue<ll> que;
    que.push(0);
    color[0] = 1;
    while(!que.empty() && nibu){
        ll p = que.front(); que.pop();
        for(auto &v : g[p]){
            if(color[v] == 0){
                if(color[p] == 1) color[v] = -1;
                else color[v] = 1;
                que.push(v);
            }
            else if(color[v] == color[p]){
                nibu = false;
                break;
            }
        }
    }
    
    if(nibu){
        ll b = 0, w = 0;
        REP(i, n){
            if(color[i] == 1) b++;
            else w++;
        }
        cout << b * w - m << endl;
    }
    else{
        cout << n * (n - 1) / 2 - m << endl;
    }
}


Measured memory_bytes: 7168
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int N;
  cin>>N;
  cout<<N*800-N/15*200;
return 0;}

Measured memory_bytes: 3504
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long[] h = new long[N+2];
        for(int i=1;i<=N;i++){
            h[i] = Long.parseLong(sc.next());
        }
        long[] ans = new long[N+2];
        for(int i=2;i<=N;i++){
            if(i>2)
                ans[i] = Math.min(
                    ans[i-2]+Math.abs(h[i-2]-h[i]),
                    ans[i-1] + Math.abs(h[i-1]-h[i])
                );
            else
                ans[i] = ans[i-1] + Math.abs(h[i-1]-h[i]);
        }
        System.out.println(ans[N]);
    }
}

Measured memory_bytes: 45860
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
const ll  big =1e3+5;
pair <ll,ll> p1[big],p2[big];
ll a[big][big];
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

string s,t;
cin>>s>>t;
ll ans=0,n=s.size();
for(int i=0;i<n;++i){
    if(s[i]!=t[i])ans++;
}
cout<<ans;
    return 0;
}

Measured memory_bytes: 3876
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
    return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}

long long gcd (long long a, long long b)
{
    if (b > a)
        swap(a, b);
    return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
    ios::sync_with_stdio(false);
    #ifdef ONLINE_JUDGE
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.setstate(ios::failbit);
    #endif

    int x;
    rep(i,0,5)
    {
        cin >> x;
        if(x == 0)
            ret(i+1);
    }
}


Measured memory_bytes: 3140
import java.io.*;

public class Main{
    public static void main(String args[]){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line = reader.readLine();
            int n = Integer.parseInt(line);
            int h,m,s;
            h = n / 3600;
            m = (n - h*3600) / 60;
            s = (n - h*3600 - m*60);
            System.out.printf("%d:%d:%d\n", h, m, s);
        } catch(IOException e){
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 24516
#!/usr/bin/env python3
#みんなのプロコン2019 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

k,a,b = LI()
if a >= b-1 or k <= a:
    print(1+k)
else:
    s = k - (a-1)
    if s % 2:
        ans = 1 + b + (s//2 -1)*(b-a)
        print(ans)
    else:
        ans = b + (s//2 -1)*(b-a)
        print(ans)


Measured memory_bytes: 38256
from collections import *
from itertools import *

N = int(input())

A = map(int, input().split())
SA = SB = 0
ABI = sorted(((b:=max(N-i, i-1)*a, SA:=SA+a, SB:=SB+b) and (a, b, i) for i, a in enumerate(A, 1)), reverse=True)

prev = {0:0}
prev_max = 0
for k, (a, b, i) in enumerate(ABI):
  curr = defaultdict(int)
  for l, p in prev.items():
    r = k-l
    if p + SB - max(l,r)*SA < prev_max:
      continue
    curr[l] = max(curr[l], p+abs(N-i-r)*a)
    curr[l+1] = p+abs(i-l-1)*a
  SA -= a
  SB -= b
  prev = curr
  prev_max = max(prev.values())

print(prev_max)


Measured memory_bytes: 9840
#include <iostream>
using namespace std;
#define int long long int
#define mod 1000000007
int h, w;
signed main()
{
    cin >> h >> w;
    char s[h + 2][w + 2];
    int dp[h + 2][w + 2];
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> s[i][j];
            dp[i][j] = 0;
            if (s[i][j] == '.' && i == 0 && j == 0)
                dp[i][j] = 1;
            else
            {
                if (s[i][j] == '#')
                    continue;
                else
                {
                    if (i > 0)
                        dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
                    if (j > 0)
                        dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
                }
            }
        }
    }
    cout << dp[h - 1][w - 1] % mod << endl;
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

ll d = 10000005;

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

  vector<ll> yaku(d,1);
  for(ll i=2; i<d; i++){
    for(ll j=i; j<d; j+=i){
      yaku.at(j)++;
    }
  }

  //cout << yaku.at(16);

  ll ans = 0;
  rep(i, n+1){
    ans += i*yaku.at(i);
  }

  cout << ans;
  
}

Measured memory_bytes: 81412
#include <algorithm>
#include <cstring>
#include <iostream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MAX_N 1024

int W, H, N;
int X1[MAX_N], X2[MAX_N], Y1[MAX_N], Y2[MAX_N];
bool fld[MAX_N * 2][MAX_N * 2];

int dy[4] = {1, 0, -1, 0};
int dx[4] = {0, 1, 0, -1};

int compress(int *x1, int *x2, int w)
{
    vector<int> xs;
    for (int i = 0; i < N; ++i)
    {
        for (int d = -1; d <= 0; ++d)
        {
            int tx1 = x1[i] + d;
            int tx2 = x2[i] + d;
            if (0 <= tx1 && tx1 < w)
            {
                xs.push_back(tx1);
            }
            if (0 <= tx2 && tx2 < w)
            {
                xs.push_back(tx2);
            }
        }
    }
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    for (int i = 0; i < N; ++i)
    {
        x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
        x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
    }
    return xs.size();
}

int dfs()
{
    int result = 0;
    for (int y = 0; y < H; ++y)
    {
        for (int x = 0; x < W; ++x)
        {
            if (fld[y][x])
            {
                continue;
            }
            ++result;
            stack<pair<int, int> > s;
            s.push(make_pair(y, x));
            while (!s.empty())
            {
                int cy = s.top().first;
                int cx = s.top().second;
                s.pop();
                for (int i = 0; i < 4; ++i)
                {
                    int ny = cy + dy[i];
                    int nx = cx + dx[i];
                    if (ny < 0 || H <= ny || nx < 0 || W <= nx)
                    {
                        continue;
                    }
                    if (fld[ny][nx])
                    {
                        continue;
                    }
                    fld[ny][nx] = true;
                    s.push(make_pair(ny, nx));
                }
            }
        }
    }
    return result;
}

int main()
{
    while (cin >> W >> H, W | H)
    {
        cin >> N;
	for (int i = 0; i < N; ++i)
	{
	    cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
	}
	W = compress(X1, X2, W);
	H = compress(Y1, Y2, H);
	memset(fld, false, sizeof fld);
	for (int i = 0; i < N; ++i)
	{
	    for (int y = Y1[i]; y < Y2[i]; ++y)
	    {
	        for (int x = X1[i]; x < X2[i]; ++x)
	        {
		    fld[y][x] = true;
                }
            }
	}
        cout << dfs() << endl;
    }
    return 0;
}

Measured memory_bytes: 8264
#include <iostream>
#include <array>

using namespace std;

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

    int n, pos = 0;
    int p = -1;
    array<int, 100000> a;
    cin >> n;

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

    for (int i = 0; i < n; i++)
    {
        pos = a[pos] - 1;
        if (pos == 1)
        {
            p = i;
            break;
        }
    }

    if (p >= 0)
        cout << p + 1 << endl;
    else
        cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var N, M, a, b int
	fmt.Scan(&N, &M)
	m := map[int]int{}
	r := make([]int, N)
	for i := 0; i < M; i++ {
		fmt.Scan(&a, &b)
		m[a]++
		m[b]++
	}
	for k, v := range m {
		r[k-1] = v
	}
	for i := range r {
		fmt.Println(r[i])
	}
}

Measured memory_bytes: 512
import sys
import numpy as np

n = int(input())

a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))

# 総和が足りなければ合格できない
if a.sum() < b.sum():
    print(-1)
    sys.exit()

diff = a - b

# 初めから条件を満たしている場合
if np.where(diff < 0)[0].shape[0] == 0:
    print(0)
    sys.exit()

# プラス要素とマイナス要素に分離する。0はいじらなくてよい
minus = diff[np.where(diff < 0)]
plus = diff[np.where(diff > 0)]

# マイナスの要素をプラスの成分が大きい方から消化していく
ans = minus.shape[0]
sum_minus = np.abs(minus).sum()
plus.sort()
plus = plus[::-1]
plus = plus.cumsum()

# 何個目のプラスまでで消化しきれるか
ans += np.where(plus >= sum_minus)[0].min() + 1

print(ans)

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

int main() {
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;main(){int n,i,j,p[9];char c;for(cin>>n;n;n--){int h[32]={0};for(i=0;i<9;cin>>p[i++]);for(i=0;i<9;i++){cin>>c;if(c==71)p[i]+=10;if(c==66)p[i]+=20;}for(i=0;i<9;h[p[i++]]++);for(i=0;i<30;i++)while(h[i]%3)for(j=0;j<3;j++)h[i+j]--;for(i=0;i<30&&h[i]>=0;i++);cout<<(i-30?0:1)<<endl;}}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>
#include <set>

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

using namespace std;

int N, W;
int w[101];
int v[101];

int main()
{
    scanf("%d %d", &N, &W);
    REP(i, N)
        scanf("%d %d", &w[i], &v[i]);
    vector <vector <long long int>> dp(N+1, vector <long long int>(W+1, 0));
    REP(i, W)
        dp[0][i] = 0;
    FOR(i, 1, N+1) {
        //cout << i << endl;
        REP(j, W+1) {
            if (w[i-1]<=j)
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]]+v[i-1]);
            else
                dp[i][j] = dp[i-1][j];
        }
        //REP(j, W+1)
        //    cout << dp[i][j] << " ";
    }
    printf("%lld\n", dp[N][W]);

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  if (a == b) ans = 2 * a;
  else
    ans = max(a, b) * 2 - 1;

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


Measured memory_bytes: 256
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

//最大公約数
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main(){
   ll n, a, b;
   cin >> n >> b >> a;
   ll ans = (n/(a+b))*b;
   if(n%(a+b)>b) ans+=b;
   else ans+=n%(a+b);
   cout << ans << endl;
}

Measured memory_bytes: 3616
#include <stdio.h>

int main(void){
  int a, b;
  scanf("%d %d", &a, &b);
  if (a > b) {
    puts("a > b");
  } else if (a < b){
    puts("a < b");
  } else {
    puts("a == b");
  }
  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
long long pn[100050],nn[100050],N,K,temp,k,flag,mid,ans=LONG_MAX,poslim,neglim,PP,NN;
int main ()
{

                PP=NN=1;
                cin>>N>>K;
                for(int i=1;i<=N;i++)
                {
                        scanf("%lld",&temp);
                        if(temp>=0)
                        {
                                pn[PP++]=temp;
                        }
                        else
                        {
                                nn[NN++]=-1*temp;
                        }

                }
                sort(nn+1,nn+NN);


               // cout<<ans<<endl;
               poslim = PP-1;
               neglim = NN-1;
                if(PP-1>=K)//正数个数
                {
                        ans=min(ans,pn[K]);
                        //cout<<ans<<endl;
                }
                for(int i=1;i<=poslim;i++) //先去正数
                {
                        if(neglim<K-i)
                                continue;
                        if(i>=K)
                                break;
                        temp = 2*pn[i]+ nn[K-i];
                        //cout<<temp<<" ";
                        ans=min(ans,temp);
                }
                if(NN-1 >=K)//负数个数
                {
                        ans=min(ans,nn[K]);
                        //neglim = K;
                        //cout<<ans<<endl;
                }
                for(int i=1;i<=neglim;i++) //先去负数
                {
                        if(poslim<K-i)
                                continue;
                        if(i>=K)
                                break;
                        temp = 2*nn[i] + pn[K-i];
                        // cout<<temp<<" "<<endl;
                        ans=min(ans,temp);
                }
                cout<<ans<<endl;



}

Measured memory_bytes: 1024
package main

import (
        "fmt"
)

const MOD = 1e9 + 7

func solution(n int) int {
        ans := 1
        for i := 1; i <= n; i++ {
                ans = ans * i % MOD
        }
        return ans
}

func main() {
        var n int
        fmt.Scan(&n)
        fmt.Println(solution(n))
}

Measured memory_bytes: 1768
roman = "abcdefghijklmnopqrstuvwxyz"
num_to_roman = {}
for i in range(26):
  num_to_roman[i] = roman[i]

n = int(input())
ans = []
while(n):
  n-=1
  ans.insert(0,num_to_roman[n%26])
  n = n//26
  
ans_str = ''.join(ans)
print(ans_str)

Measured memory_bytes: 61856
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int N=2e5+100,inf=1e9;
string s;
vi cnt(26,0);
int n,cut[N];
vector<vi> first(N,vi(26,inf)),last(N,vi(26,-inf));
set<int> pos[N];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s;
	n=sz(s);
	int ans=1,cur=0;	
	rep(i,0,n) {
		if(cnt[s[i]-'a']==0) cur++;
		cnt[s[i]-'a']++;
		if(cur==26) {
			cut[ans]=i;
			ans++;
			rep(i,0,26) cnt[i]=0;
			cur=0;
		}
	}
	// rep(i,1,ans) cout<<cut[i]<<' ';
	// cout<<endl;
	rep(i,0,26) {
		if(cnt[i]==0) {
	//		cout<<i<<endl;
			pos[ans].insert(i);
		}
	}
	per(i,1,ans) {
		int l,r;
		if(i==1) l=0;
		else l=cut[i-1]+1;
		r=cut[i];
		rep(j,l,r+1) {
			first[i][s[j]-'a']=min(first[i][s[j]-'a'],j);
			last[i][s[j]-'a']=max(last[i][s[j]-'a'],j);
		}
		int boundary=inf;
		for(auto x:pos[i+1]) {
			boundary=min(boundary,last[i][x]);
		}
		rep(j,0,26) {
			if(first[i][j]>=boundary) {
				pos[i].insert(j);
			}
		}
	}
	// rep(i,1,ans+1) {
	// 	for(auto x:pos[i]) cout<<x<<' ';
	// 	cout<<endl;
	// }
	set<int> curpos;
	string ansstring="";
	for(auto x:pos[1]) curpos.insert(x);	
	rep(i,1,ans) {
		// for(auto x:curpos) cout<<x<<' ';
		// cout<<endl;
		int picked=*curpos.begin();
		ansstring+=(char)('a'+*curpos.begin());
		curpos.clear();
		for(auto x:pos[i+1]) {
			if(last[i][x]<=first[i][picked]) {
				curpos.insert(x);
			}
		}
	}
	//cout<<ansstring<<endl;
	// for(auto x:curpos) cout<<x<<' ';
	// cout<<endl;
	ansstring+=(char)('a'+*curpos.begin());
	cout<<ansstring<<endl;
	return 0;
}

Measured memory_bytes: 75260
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define Get(x,y) scanf("%I64d%I64d",&x,&y);
#define get(x) scanf("%I64d",&x);
#define Gett(x,y) scanf("%d%d",&x,&y);
#define gett(x) scanf("%d",&x);																																														
#define f(i,a,b) for(int i=a;i<b;i++)
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define print(v,r) f(i,0,r) cout<<v[i]<<" "; cout<<endl;
#define ll long long
#define pb push_back
#define maxm(a,b) a=max(a,b);
#define minm(a,b) a=min(a,b);
#define S second
#define F first
const int N=3e5+20;
int n,m,ans=1e8,mark[12],a[12],k;
string mp[12];
int calc(int x){
	int ans=0,cx=x;
	f(i,1,n){
		mark[i]=mark[i-1];
		if(x%2) mark[i]++,ans++;
		x/=2;
	}
	f(i,0,n) a[i]=0;
	f(i,0,m){
		f(j,0,n){
			if(mp[j][i]=='1')
				a[mark[j]]++;
		}
		f(j,0,n){
			if(a[j]>k){
				ans++;
				f(l,0,n) a[l]=0;
				f(l,0,n){
					a[mark[l]]+=(mp[l][i]=='1');
					if(a[mark[l]]>k) return 1e8;
				}
				break;
			}
		}
	}
	return ans;
}
int main(){
	cin>>n>>m>>k;
	f(i,0,n)
		cin>>mp[i];
	f(i,0,(1<<(n-1)))
		ans=minm(ans,calc(i));
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int a[105][3],n;
int main(){
	cin>>n;
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++)
			cin>>a[j][i];
	for(int i=1;i<=n;i++){
		a[i][1]+=a[i-1][1];
		a[i][2]+=max(a[i-1][2],a[i][1]);
	}
	cout<<a[n][2];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=20;
// https://www.geeksforgeeks.org/find-number-of-triangles-possible/
// int comp(const void* a, const void* b)  
// { return *(int*)a > *(int*)b ; } 
int findNumberOfTriangles(int arr[], int n)  
{  
    // Sort the array elements in non-decreasing order  
    sort(arr, arr+n);
     // reverse(arr,arr+n); 
  
    // Initialize count of triangles  
    int count = 0;  
  
    // Fix the first element. We need to run till n-3  
    // as the other two elements are selected from  
    // arr[i+1...n-1]  
    for (int i = 0; i < n - 2; ++i)  
    {  
        // Initialize index of the rightmost third  
        // element  
        int k = i + 2;  
  
        // Fix the second element  
        for (int j = i + 1; j < n; ++j)  
        {  
            // Find the rightmost element which is  
            // smaller than the sum of two fixed elements  
            // The important thing to note here is, we  
            // use the previous value of k. If value of  
            // arr[i] + arr[j-1] was greater than arr[k],  
            // then arr[i] + arr[j] must be greater than k,  
            // because the array is sorted.  
            while (k < n && arr[i] + arr[j] > arr[k])  
            ++k;  
  
            // Total number of possible triangles that can  
            // be formed with the two fixed elements is  
            // k - j - 1. The two fixed elements are arr[i]  
            // and arr[j]. All elements between arr[j+1]/ to  
            // arr[k-1] can form a triangle with arr[i] and arr[j].  
            // One is subtracted from k because k is incremented  
            // one extra in above while loop.  
            // k will always be greater than j. If j becomes equal  
            // to k, then above loop will increment k, because arr[k]  
            // + arr[i] is always greater than arr[k]  
            if(k > j)  
            count += k - j - 1;  
        }  
    }  
  
    return count;  
}  
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      int n;
      cin>>n;
      int a[n];
      for(int i=0;i<n;i++) cin>>a[i];
        cout<<findNumberOfTriangles(a,n);
}
// I never lose. I either win or I learn

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
using namespace std;
using ll = long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;







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

        c -=b;
        if(c<=0){
            cout <<"Yes";
            break;
        }
        
        a-=d;
        if (a<=0){
            cout << "No";
            break;
        }
    }


}









Measured memory_bytes: 3636
import Glibc
extension String: CollectionType {}

var cookie = readLine()!.split(" ").map { Int($0)! }
if cookie[0] % 3 == 0 || cookie[1] % 3 == 0 || (cookie.reduce(0){ $0 + $1 }) % 3 == 0 {
  print("Possible")
} else {
  print("Impossible")
}


Measured memory_bytes: 768
N = int(input())
X = [int(i) for i in input().split(' ')]
M = int(input())
A = [int(i) for i in input().split(' ')]

GOAL = 2019


for a in A:
    if len(X) > a and (X[a-1] + 1) == X[a]:
        continue
    if X[a-1] == GOAL:
        continue
    X[a-1] = X[a-1] + 1
    
for x in X:
    print(x)


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    deque<int> A[N];
    rep(i, N) {
        deque<int> a(N-1);
        rep(j, N-1) cin >> a[j];
        rep(k, N-1) a[k]--; 
        A[i] = a;
    }
    ll ans = 0;
    ll match = 0;
    while (match < N * (N-1) / 2) {
        ans++;
        bool flag = false;
        vector<bool> used(N);
        for (int i = 0; i < N; i++) {
            if (used[i] || A[i].empty()) continue;
            used[i] = true;
            int op = A[i].front();
            if (used[op]) continue;
            if (A[op].front() == i) {
                match++;
                used[op] = true;
                A[i].pop_front(); A[op].pop_front();
                flag = true;
            }
        }
        if (!flag) {
            cout << -1 << '\n';
            return 0;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 8600
N = int(input())
S = list(map(int, list(input())))

def f(a):
    i = 0
    for j in range(N):
        if S[j] == a[i]:
            i += 1
            if i > 2:
                return True
    return False

res = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            if f((i, j, k)):
                res += 1

print(res)

Measured memory_bytes: 41584
n = input()
t = [map(int, raw_input().split()) for _ in xrange(n-1)]

for i in xrange(n-1):
    s = t[i][1]
    for j in xrange(i, n-1):
        if s >= t[j][1]:
            if not ((s - t[j][1]) % t[j][2]) == 0:
                s += t[j][2] - ((s - t[j][1]) % t[j][2])
            s += t[j][0]
        else:
            s = t[j][0] + t[j][1]
    print s
print 0


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

int main(){
    int p, q;
    long long n;
    char c;
    long long right=0, left=0;
    cin >> q;
    for(int i=0;i<q;++i){
        cin >> p >> c >> n;
        if(c=='(') left += n;
        else right += n;
        if(left==right) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1160
H, W, M = map(int, input().split())
hallline = [0 for i in range(H)]
wallline = [0 for i in range(W)]
b = {}

for i in range(M):
    tmp = list(map(lambda x: int(x) - 1, input().split()))
    hallline[tmp[0]] += 1
    wallline[tmp[1]] += 1
    b[(tmp[0], tmp[1])] = True

t = max(hallline)
s = max(wallline)

a = [i for i in range(H) if hallline[i] == t]
c = [i for i in range(W) if wallline[i] == s]

tmp = False

for i in a:
    for j in c:
        if (i, j) not in b.keys():
            print(t + s)
            tmp = True
            break
    if tmp:
        break
if not tmp:
    print(t + s - 1)


Measured memory_bytes: 200216