akhauriyash/Code-Regression huggingface dataset:
{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.List
import Data.Ord
import qualified Data.ByteString.Char8 as B

main = do
    n <- readLn :: IO Int
    print.p'.filter (/=0).foldl' f [0,0,0,0,0] =<< replicateM n B.getLine
    where
        p' x
            | length x < 3 = 0
            | True = sum $ map product $ comb 3 x
        f aa@[m,a,r,c,h] (B.head -> s)
            | s == 'M' = [m+1,a,r,c,h]
            | s == 'A' = [m,a+1,r,c,h]
            | s == 'R' = [m,a,r+1,c,h]
            | s == 'C' = [m,a,r,c+1,h]
            | s == 'H' = [m,a,r,c,h+1]
            | True = aa

comb :: Int -> [Int] -> [[Int]]
comb n xa@(x:xs) =
    case compare (length xa) n of
        LT -> []
        EQ -> [xa]
        GT -> ( map (x:) $ comb (n-1) xs) ++ (comb n xs)
comb 0 _ = [[]]
comb _ [] = []

Measured memory_bytes: 21372
H, W = map(int, input().split())
Ss = ["," * (W+2)]
Ss.extend(["," + input() + "," for _ in range(H)])
Ss.extend(["," * (W+2)])
# print(Ss)

def sweep(x, y):
  count = 0
  
  if Ss[x-1][y-1] == "#":
    count += 1
  if Ss[x-1][y] == "#":
    count += 1
  if Ss[x-1][y+1] == "#":
    count += 1
  if Ss[x][y-1] == "#":
    count += 1
  if Ss[x][y+1] == "#":
    count += 1
  if Ss[x+1][y-1] == "#":
    count += 1
  if Ss[x+1][y] == "#":
    count += 1
  if Ss[x+1][y+1] == "#":
    count += 1
  
  return count
  
  
for i in range(1, H+1):
  for j in range(1, W+1):
    if Ss[i][j] == "#":
      print("#", end="")
    else:
      print(sweep(i, j), end="")
  print("")


Measured memory_bytes: 3444
#!/usr/bin/env python3
import sys


def solve(X: int, N: int, p: "List[int]"):
    for i in range(101):
        if (X - i) not in p:
            print(X-i)
            return
        elif (X + i) not in p:
            print(X+i)
            return

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(X, N, p)

if __name__ == '__main__':
    main()


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

int main() {
  int a, b;
  cin >> a >> b;
  int count = 0;

  for (int i = a; i <= b; i ++) {
    int w = i / 10000;
    int x = i % 10;
    int y = i / 1000 % 10;
    int z = i / 10 % 10;
    if (w == x && y == z) {
      count ++;
    }
  }
  cout << count << endl;
}


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

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;
using namespace chrono;

const ll MOD = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

void print(vector<pair<ll, ll> > v) {
    ll i;
    fo(i, v.size()) {
        cout << v[i].first << " " << v[i].second << "\n";
    }
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t = 1;
//    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;
        cin >> n;
        ll ans = 0;
        ll ct = 1;
        while (n) {
            ans += ct;
            ct *= 2;
            n /= 2;
        }
        cout << ans;

    }
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif

    auto start = high_resolution_clock::now();

    solve();

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
#ifndef ONLINE_JUDGE
    cerr << "Time: " << duration.count() / 1000.0 << endl;
#endif


    return 0;
}




Measured memory_bytes: 3656
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n =scanner.nextInt();
        int principal = 100000;
        int result = principal;

        for (int i = 0; i < n; i++) {
            result *= 1.05;
            int remainder = result % 1000;
            if ( remainder != 0) {
                result += 1000-remainder;
            }
        }
        System.out.println(result);
    }
}

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

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

int main()
{
    ll N, P;
    string S;
    cin >> N >> P >> S;

    ll res = 0;
    if (P == 2) {
        rep(i, N)if ((S[i] - '0') % 2 == 0)res += i + 1;
    }
    else if (P == 5) {
        rep(i, N)if ((S[i] - '0') % 5 == 0)res += i + 1;
    }
    else {
        map<ll, ll> cnt;
        ll acc = 0;
        cnt[acc]++;
        reverse(S.begin(), S.end());
        rep(i, N) {
            char c = S[i];
            acc += (c - '0')*mod_pow(10, i, P);
            acc %= P;
            //acc = (10 * acc + c - '0') % P;
            cnt[acc]++;
        }
        for (auto itr : cnt)res += itr.second*(itr.second - 1) / 2;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define For(i, s, e) for(int i = s;i <= e;i++)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



int main() {
    ll k,a,b;
    cin >> k >> a >>b;
    if(b-a<=2) {
        cout << k+1;
    } else {
        k -=a -1;
        cout <<(b-a)*(k/2)+a+k%2;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

// 素集合データ構造
struct UnionFind
{
    // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
    vector<int> par;
    // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
    vector<int> sizes;

    UnionFind(int n) : par(n), sizes(n, 1)
    {
        // 最初は全てのデータiがグループiに存在するものとして初期化
        for (int i = 0; i < n; i++)
        {
            par[i] = i;
        }
    }

    // データxが属する木の根を得る
    int find(int x)
    {
        if (x == par[x])
            return x;
        return par[x] = find(par[x]); // 根を張り替えながら再帰的に根ノードを探す
    }

    // 2つのデータx, yが属する木をマージする
    void unite(int x, int y)
    {
        // データの根ノードを得る
        x = find(x);
        y = find(y);

        // 既に同じ木に属しているならマージしない
        if (x == y)
            return;

        // xの木がyの木より大きくなるようにする
        if (sizes[x] < sizes[y])
            swap(x, y);

        // xがyの親になるように連結する
        par[y] = x;
        sizes[x] += sizes[y];
        // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
    }

    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }

    // データxが含まれる木の大きさを返す
    int size(int x)
    {
        return sizes[find(x)];
    }
};
int main()
{
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; i++)
    {
        int x, y, z;
        cin >> x >> y >> z;
        x--;
        y--;
        uf.unite(x, y);
    }
    set<int> a;
    for (int i = 0; i < n; i++)
    {
        a.insert(uf.find(i));
    }
    cout << a.size() << endl;
}

Measured memory_bytes: 5760
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    println!("{}", 24 - n + 24);
}


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

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

  long long res = 0;
  int sum = 0;
  int right = 0;
  for(int left = 0;left < n;++left)
  {
    while(right < n && (sum ^ a[right]) == (sum+a[right]))
    {
      sum += a[right];
      ++right;
    }
    res += right - left;
    if(left == right) ++right;
    else
    {
      sum -= a[left];
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;
int n,m;


signed main(){

    cin >> n >> m;
    vector<pair<int,int>> p[n]; //
    rep(i,m){
        int t,y;
        cin >> t >> y;
        p[t-1].pb(MP(y,i));
    }

    rep(i,n){
        SORT(p[i]);
    }

    vector<pair<int,int>> ans(100010);
 
    rep(i,n){
        if(p[i].size() != 0){
            int j = 1;
            for(auto x:p[i]){
                ans[x.se] = MP(i+1,j);
                j++;
                //cerr << x.fi << " " <<  x.se <<endl;
            }
        }
    }
    // s[x.se] = "000000000000";
    //             s[x.se][0] = ((i+1)/100000)%10;
    //             s[x.se][1] = ((i+1)/10000)%10;
    //             s[x.se][2] = ((i+1)/1000)%10;
    //             s[x.se][3] = ((i+1)/100)%10;
    //             s[x.se][4] = ((i+1)/10)%10;
    //             s[x.se][5] = (i+1)%10;

    //             s[x.se][6] = ((j)/100000)%10;
    //             s[x.se][7] = ((j)/10000)%10;
    //             s[x.se][8] = ((j)/1000)%10;
    //             s[x.se][9] = ((j)/100)%10;
    //             s[x.se][10] = ((j)/10)%10;
    //             s[x.se][11] = (j)%10;

    rep(i,m){
        cout << ((ans[i].fi)/100000)%10;
        cout << ((ans[i].fi)/10000)%10;
        cout << ((ans[i].fi)/1000)%10;
        cout << ((ans[i].fi)/100)%10;
        cout << ((ans[i].fi)/10)%10;
        cout << (ans[i].fi)%10;

        cout << ((ans[i].se)/100000)%10;
        cout << ((ans[i].se)/10000)%10;
        cout << ((ans[i].se)/1000)%10;
        cout << ((ans[i].se)/100)%10;
        cout << ((ans[i].se)/10)%10;
        cout << (ans[i].se)%10;
        cout << endl;
    }
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 8576
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  string S;
  i64 i;
  getline(cin, S);
  if(sz(S) % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  REP(0, sz(S), i) {
    if(i % 2 == 0 && S[i] != 'h') {
      cout << "No" << endl;
      return 0;
    }
    else if(i % 2 == 1 && S[i] != 'i')  {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
odd_fleq_step_pattern = ['R','U','D']
even_fleq_step_pattern = ['L','U','D']

steps = gets.chomp.split('')

ans = []
steps.each.with_index(1) do |step, i|
  if i.odd?
    ans << odd_fleq_step_pattern.include?(step)
  else
    ans << even_fleq_step_pattern.include?(step)
  end
end

puts ans.all? ? 'Yes' : 'No'



Measured memory_bytes: 1916
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int k;
    cin >> k;
    REP(i, s.size()){
        if(s[i] != s[k-1]) s[i] = '*';
    }
    pr(s);
}

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

ans = 0

for i in range(N):
  ans += B[A[i]-1]
  
for i in range(N-1):
  if A[i] + 1 == A[i+1]:
    ans += C[A[i]-1]
    
print(ans)

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

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const int MOD = 1000000007;
const int LOG = 21;
const int INF = 1000000010;
const int delta = 11353;

int n, a[N], dp[(1 << LOG) + 10], R[N][LOG], L[N][LOG], V[LOG], DP[(1 << LOG) + 10], ps[N];

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> V[LOG - 1];
	for (int i = LOG - 2; i >= 0; i--) V[i] = V[i + 1] / 2;
	for (int i = 1; i <= n; i++) cin >> a[i];
	a[0] = -INF * 2, a[n + 1] = INF * 2;
	for (int i = 0; i < LOG; i++) R[n + 1][i] = n + 1;
	for (int i = 1; i <= n; i++){
		for (int j = 0; j < LOG; j++){
			if (abs(a[i] - a[i - 1]) <= V[j]) L[i][j] = L[i - 1][j];
			else L[i][j] = i;
		//	if (j >= 15) cout << i << ' ' << j << ' ' << L[i][j] << '\n';
		}
	}
	for (int i = n; i >= 1; i--){
		for (int j = 0; j < LOG; j++){
			if (abs(a[i] - a[i + 1]) <= V[j]) R[i][j] = R[i + 1][j];
			else R[i][j] = i;
			//if (j >= 15) cout << i << ' ' << j << ' ' << R[i][j] << '\n';
		}
	}
	dp[0] = 0;
	for (int mask = 1; mask < (1 << LOG); mask++){
		for (int j = 0; j < LOG; j++){
			if (j != LOG - 1 && V[j + 1] == 0) continue;
			if (mask & (1 << j)) dp[mask] = max(dp[mask], R[dp[mask ^ (1 << j)] + 1][j]);
		}
	}
	DP[0] = n + 1;
	for (int mask = 1; mask < (1 << LOG); mask++){
		DP[mask] = n + 1;
		for (int j = 0; j < LOG; j++){
			if (j != LOG - 1 && V[j + 1] == 0) continue;
			//cout << j << '\n';
			if (mask & (1 << j)) DP[mask] = min(DP[mask], L[DP[mask ^ (1<<j)] - 1][j]);
		}
	}
	for (int mask = 0; mask < (1 << (LOG - 1)); mask++){
		int mask2 = ((1 << (LOG - 1)) - 1) ^ mask;
		if (dp[mask] >= DP[mask2] - 1){
			//cout << "Fuck\n";
			
			ps[1] ++;
		}else{
			if (R[dp[mask] + 1][LOG - 1] >= DP[mask2] - 1){
				ps[L[dp[mask] + 1][LOG - 1]]++;
				ps[R[dp[mask] + 1][LOG - 1] + 1]--;
			}
		}
	}
	for (int i = 1; i <= n; i++){
		ps[i] += ps[i - 1];
		cout << (ps[i] > 0?"Possible\n":"Impossible\n");
	}


	return 0;
}


Measured memory_bytes: 54416
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

vector<int> v;

int main(void){
	int n,i,j,p;
	string s;
	bool f = true;
	cin >> s;
	n = s.l_ength();
	if(s[n-1]=='1'){
		cout << "-1" << endl;
		return 0;
	}else if(s[0]=='0' || s[n-2]=='0'){
		cout << "-1" << endl;
		return 0;
	}
	for(i=1; i<n; ++i){
		if(n-2-i < 0){
			break;
		}
		if(s[i] != s[n-2-i]){
			cout << "-1" << endl;
			return 0;
		}
	}
	for(i=2; i<(n-1); ++i){
		if(s[i-1]=='1'){
			f = false;
			break;
		}
	}
	p = n-1;
	for(i=(n-2); i>=0; --i){
		cout << (p+1) << " " << (i+1) << endl;
		if(s[i]=='1'){
			p = i;
		}
	}
	return 0;
}


Measured memory_bytes: 1664
x, n = map(int, input().split(" "))

p = input()
if p:
    p =list(map(int,p.split(" ")))
    result = 1000
    a = 1000
    for i in range(-1, 102):
        if i in p:
            continue
        else:
            tmp = abs(i - x)
            if tmp < result:
                result = tmp
                a = i
            elif tmp == result:
                if i <= a:
                    a = i
    print(a)

else:
    print(x)



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

void Q();
int E();
int T();
int F();
int N();
int B();

int m;
string s;
size_t cur;
bool failed;

//Q::=E=E
void Q(){
	cur = 0,failed = 0;
	m = s.size();
	int l = E();
	if(s[cur]!='=') failed = 1;
	cur++;
	int r = E();
	if(cur != m or l != r) failed = 1;
}

// E::=T|E+T|E???T
int E(){
	int res = T();

	while(cur < m and s[cur] == '+' or s[cur] == '-'){
		char op = s[cur];
		cur++;
		const int arg = T();
		if(op == '+')
			res += arg;
		else
			res -= arg;
	}

	return res;
}

// T::=F|T???F

int T(){
	int res = F();

	while(cur < m and s[cur] == '*'){
		cur++;
		const int arg = F();
		res *= arg;
	}
	
	return res;

}

// F::=N|???F|(E)
int F(){
	if(cur < m and isdigit(s[cur])){
		return N();
	}else if(cur < m and s[cur]=='-'){
		cur++;
		return -F();
	}else if(cur < m and s[cur]=='('){
		cur++;
		const int res = E();
		if(s[cur]!=')') failed = true;
		cur++;
		return res;
	}else{
		failed = true;
		return 0;
	}
}

// N::=0|1B
int N(){
	if(cur < m and s[cur]=='0'){
		cur++;
		return 0;
	}else if(cur < m and s[cur]=='1'){
		cur++;
		return B();
	}else{
		failed = true;
		return 0;
	}
}

// B::=??|0B|1B
int B(){
	int res = 1;
	while(cur < m and isdigit(s[cur])){
		res = 2 * res + (s[cur] - '0');
		cur++;
	}
	//cerr << res << endl;
	return res;
}

char letter[8] = {'0','1','+','-','*','(',')','='};


int main(void){
	string t;
	cin >> t;

	const int n = t.size();
	vector<char> ary;
	rep(i,n) if(isalpha(t[i])) ary.push_back(t[i]);

	sort(begin(ary),end(ary));
	ary.erase(unique(begin(ary),end(ary)),end(ary));

	const int l = ary.size();

	if(l > 8){
		cout << 0 << endl;
		return 0;
	}

	set<string> eq;

	sort(letter,letter+8);
	do{
		string nt = t;
		rep(i,n){
			if(isalpha(nt[i])){
				rep(j,l) if(nt[i] == ary[j]) nt[i] = letter[j];
			}
		}
		eq.insert(nt);
	}while(next_permutation(letter,letter+8));

	int ans = 0;
	for(auto &it:eq){
		//cerr << it << endl;
		s = it;
		Q();
		ans += (failed == 0);
	}

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

Measured memory_bytes: 7452
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[10000];
	int b[10000];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];

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

	for(int i = 0 ; i < n ; i++)
	{
		if(a[i] > b[i])
		{
			sum -= a[i] - b[i];
		}else
		{
			sum += (b[i] - a[i]) / 2;
		}

	}
	if(sum >= 0)
	{
		cout << "Yes" << endl;

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

Measured memory_bytes: 384
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [x * 2 for x in a]
result = max(a)
left = 1
right = result
med = left + (right - left) // 2
while left <= right:
    counter = sum([(x - 1) // med for x in a])
    if counter <= k:
        result = med
        right = med - 1
    else:
        left = med + 1
    med = left + (right - left) // 2
print((result + 1) // 2)


Measured memory_bytes: 168432
#define taskname "test"

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long lli;
typedef pair<int, int> pii;
const int maxn = 1e5 + 5;
int n, m;
string s;
int a[maxn];

vector<int> g[maxn];
bool vis[maxn];

void read_input()
{
    cin >> s;
    n = s.length() + 1;
    s = "a" + s + "a";
    cin >> m;
    for(int i = 0; i < m; ++i)
    {
        int l, r;
        cin >> l >> r;
        --l;
        g[l].push_back(r);
        g[r].push_back(l);
    }
}

void init()
{
    for(int i = 0; i < n; ++i)
        a[i] = s[i + 1] - s[i];
    for(int i = 0; i < n; ++i)
        g[i].push_back(n - i - 1);
}

void dfs(int u, int&tot)
{
    vis[u] = true;
    tot += a[u];
    for(int v: g[u])
        if(!vis[v]) dfs(v, tot);
}

void solve()
{
    fill(begin(vis), end(vis), false);
    for(int i = 0; i < n; ++i)
        if(!vis[i])
        {
            int tot = 0;
            dfs(i, tot);
            tot = (tot % 26 + 26) % 26;
            if(tot != 0)
            {
                cout << "NO\n";
                return;
            }
        }
    cout << "YES\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    init();
    solve();
}


Measured memory_bytes: 8044
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
using namespace std;
long long n, a, b;
int main() {
	cin >> n >> a >> b;
	long long x = n / (a + b);
	long long y = a * x;
	long long t = n - x * (a + b);
	cout << y + (t > a ? a : t) << endl;
	return 0;
}

Measured memory_bytes: 256
local mod = 1000000007
local mfl = math.floor
local function badd(x, y) return (x + y) % mod end
local function bmul(x, y)
  local x0, y0 = x % 31623, y % 31623
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end
local function lltonumber(str)
  local ret = 0LL
  for i = 1, #str do
    ret = ret * 10LL
    ret = ret + str:sub(i, i):byte() - 48
  end
  return ret
end

local n = io.read("*n", "*l")
local lim = 60
local box = {}
for i = 1, lim do
  box[i] = 0
end
local s = io.read()
local llnum = {}
for z in s:gmatch("%d+") do
  table.insert(llnum, lltonumber(z))
end
local mulcnt = {}
for i = 1, lim do
  mulcnt[i] = 0
end
for i = 1, n do
  local a = llnum[i]
  for j = 1, 20 do
    local p = a % 2LL
    if p == 1LL then
      mulcnt[j] = mulcnt[j] + i - 1 - box[j]
      box[j] = box[j] + 1
    else
      mulcnt[j] = mulcnt[j] + box[j]
    end
    a = a / 2LL
  end
  local str = tostring(a):gsub("LL", "")
  a = tonumber(str)
  for j = 21, lim do
    local p = a % 2
    if p == 1 then
      mulcnt[j] = mulcnt[j] + i - 1 - box[j]
      box[j] = box[j] + 1
    else
      mulcnt[j] = mulcnt[j] + box[j]
    end
    a = mfl(a / 2)
  end
end
local ret = 0
local mul = 1
for i = 1, lim do
  ret = badd(ret, bmul(mul, mulcnt[i]))
  mul = (mul * 2) % mod
end
print(ret)


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
    int n; scanf("%d",&n);
    vector<ll> a(n);
    rep(i,0,n)scanf("%lld",&a[i]);
    bool f=1;
    rep(i,0,n)if(a[i]>=0)f=0;
    if(f){
        ll ma=-inf,idx=-1;
        rep(i,0,n)if(chmax(ma,a[i]))idx=i;
        printf("%lld\n",ma); printf("%d\n",n-1);
        rrep(i,n-1,idx)printf("%d\n",i+1);
        rrep(i,idx-1,-1)printf("%d\n",1);
        return 0;
    }
    ll ans=0,ans2=0; vector<int> used[2];
    rep(i,0,n)if(a[i]>=0){
        if(i&1)ans+=a[i],used[0].push_back(i);
        else ans2+=a[i],used[1].push_back(i);
    } f=(ans<ans2);
    chmax(ans,ans2); printf("%lld\n",ans);
    vector<int> sub;
    rrep(i,n-1,used[f].back())sub.push_back(i);
    rrep(i,used[f].size()-2,-1){
        rep(rot,0,(used[f][i+1]-used[f][i])/2)sub.push_back((used[f][i]+used[f][i+1])/2-rot);
    }
    rep(i,0,used[f].front())sub.push_back(0);
    printf("%d\n",sub.size());
    rep(i,0,sub.size())printf("%d\n",sub[i]+1);
    return 0;
}

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

typedef long long ll;
const int MOD = 1000000007;

ll fib(ll step) {
    ll a=1, b=1, temp;
    if(step==0) return 0;
    if(step == 1 || step == 2) return 1;
    else {
        for(ll i=3; i<=step; i++) {
            temp = a + b;
            temp %= MOD;
            a = b;
            b = temp;
        }
        b %= MOD;
        return b;
    }

}

int main() {
    ll N, M, n=0, count=1;
    cin >> N >> M;
    ll a[M];
    for(ll i=0; i<M; i++) {
        cin >> a[i];
    }

    ll m = 0;
    ll tcnt = 0;
    if(M>0) {
        while(n!=N) {
         if(n != a[m]) {
             tcnt++;
         } else {
            count *= fib(tcnt);
            count %= MOD;
            tcnt = 0;
            if(m < M-1) m++;
         }
        n++;
      }
      count *= fib(++tcnt);
        count %= MOD;
    } else {
        count = fib(N+1);
        count %= MOD;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1024
//ABC 077
#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--)
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };


signed main() {

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

	int n;
	cin >>  n;
	int n2;
	n2 = sqrt(n);
	cout << n2*n2;

	return 0;

}

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

int main(){
    
	int n; cin >> n;
	for (int i = 1; i <= 9; i++) {
		if (n % i == 0 && n / i <= 9 && 1 <= n / i) { 
			cout << "Yes" << endl; return 0; 
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  cin >> W >> a >> b;

  if(a < b){
    if(a+W >= b){
      cout << 0 << endl;
    } else {
      cout << b - (a+W) << endl;
    }
  } else {
    if(b+W >= a){
      cout << 0 << endl;
    } else {
      cout << a - (b+W) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  int r;
  cin >> r;
  cout << 3 * r * r << '\n';
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<map>
#include<cstdlib>
#include<stack>
#include<algorithm>
#include<set>
#include<cmath>
#include<vector>
using namespace std;
int main()
{
	#ifdef local
	freopen("1.txt","r",stdin);
	#endif
	int i,n,a[100005];
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	int ans=0,now=0;
	for(i=0;i<n-1;i++)
	{
		if(a[i]>=a[i+1])now++;
		else
		{
			ans=max(ans,now);
			now=0;
		}
	}
	ans=max(now,ans);
	printf("%d",ans);
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define MOD 1000000007

ll fact[2001], fact_i[2001];

ll power(int x, int y) {
    if (y == 1) return x;
    ll p = power(x, y >> 1);
    if (y & 1) return p * p % MOD * x % MOD;
    else return p * p % MOD;
}

ll inv(ll n) {
    return power(n, MOD - 2);
}

void init(int n) {
    fact[0] = 1;
    REP(i, n) fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_i[n] = inv(fact[n]);
    REP(i, n) fact_i[n - i - 1] = fact_i[n - i] * (n - i) % MOD;
}

ll nCr(ll n, ll r) {
    if (n < r || n < 0 || r < 0) return 0;
    return fact[n] * fact_i[r] % MOD * fact_i[n - r] % MOD;
}

int main() {
    init(2000);
    ll N, K;
    cin >> N >> K;

    FOR(i, 1, K + 1) {
        cout << nCr(N - K + 1, i) * nCr(K - 1, i - 1) % MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from math import pi, cos, sqrt
a, b, h, m = list(map(int, input().split()))

p2 = 2.0 * pi

t1 = p2 / 12 * h + p2 / 12 / 60 * m
t2 = p2 / 60 * m

#t1 = t1 + pi*3/4

t = abs(t1 - t2)
#print(t1)
#print(t2)
#print(t)
cc = a*a + b*b - 2*a*b*cos(t)
c = sqrt(cc)

print("{:.14f}".format(c))


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N,K;
    cin >> N >> K;
    string s;
    cin >> s;

    vector<int> S;
    char current = s[0];
    if(current == '0'){
        S.push_back(0);
    }
    int num = 0;
    REP(i,N){
        if(current == s[i]){
            num++;
        }else{
            S.push_back(num);
            num = 1;
            current = s[i];
        }
    }
    S.push_back(num);
    if(S.size()%2 == 0){
        S.push_back(0);
    }

    if(S.size() <= 2*K+1){
        cout << N << endl;
    }else{
        int ans = 0;
        for(int i=0; i<S.size()-2*K; i+=2){
            int cur = 0;
            FOR(j,i,i+2*K+1){
                cur += S[j];
            }
            ans = max(ans,cur);
        }
        cout << ans << endl;
    }



    return 0;
}

Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,m,t;
typedef long long LL;
struct query{
	int x,y,u,v;
	long long ans;
}Q[N];
vector<int> v[N],b[N];

int cnt,head[N],nxt[N<<1],to[N<<1],col[N<<1],len[N<<1];
void add_edge(int x,int y,int c,int d) {
	nxt[++cnt]=head[x]; to[cnt]=y; col[cnt]=c; len[cnt]=d; head[x]=cnt;
}

int dep[N],f[N][20];
void dfs1(int x,int fa,int d) {
	dep[x]=d;
	for (int i=head[x];i;i=nxt[i]) {
		int y=to[i];
		if (y==fa) continue;
		f[y][0]=x;
		for (int j=1;j<=t;j++) f[y][j]=f[f[y][j-1]][j-1];
		dfs1(y,x,d+1);
	}
}

int LCA(int x,int y) {
	if (dep[x]>dep[y]) swap(x,y);
	for (int i=t;i>=0;i--)
		if (dep[f[y][i]]>=dep[x]) y=f[y][i];
	if (x==y) return x;
	for (int i=t;i>=0;i--)
		if (f[x][i]!=f[y][i]) x=f[x][i],y=f[y][i];
	return f[x][0];		
}

int sumc[N],sumd[N];
void dfs2(int x,int fa,int dis) {
	for (int i=0;i<v[x].size();i++) {
		int id=v[x][i];
		Q[id].ans+=(LL)dis*b[x][i];
		Q[id].ans-=(LL)sumd[Q[id].x]*b[x][i];
		Q[id].ans+=(LL)sumc[Q[id].x]*Q[id].y*b[x][i];
	}
	for (int i=head[x];i;i=nxt[i]) {
		int y=to[i];
		if (y==fa) continue;
		sumc[col[i]]++;
		sumd[col[i]]+=len[i];
		dfs2(y,x,dis+len[i]);
		sumc[col[i]]--;
		sumd[col[i]]-=len[i];
	}
}

int main()
{
	cin>>n>>m;
	t=log2(n)+1;
	for (int i=1;i<n;i++) {
		int x,y,c,d;
		scanf("%d%d%d%d",&x,&y,&c,&d);
		add_edge(x,y,c,d);
		add_edge(y,x,c,d);
	}
	dfs1(1,0,1);
	for (int i=1;i<=m;i++) {
		scanf("%d%d%d%d",&Q[i].x,&Q[i].y,&Q[i].u,&Q[i].v);
		v[Q[i].u].push_back(i); b[Q[i].u].push_back(1);
		v[Q[i].v].push_back(i); b[Q[i].v].push_back(1);
		int lca=LCA(Q[i].u,Q[i].v);
		v[lca].push_back(i); b[lca].push_back(-2);
	}
	dfs2(1,0,0);
	for (int i=1;i<=m;i++) printf("%lld\n",Q[i].ans);
	return 0;	
} 

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    vector<ll> x(N);
    rep(i, N){
        cin >> x.at(i);
    }
    sort(x.begin(), x.end());
    ll ans = 1;
    rep(i, N){
        if (x.at(i) == 0){ans = 0; break;}
        if ((INF / ans) < x.at(i)){ans = -1; break;}
        ans *= x.at(i);
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3988
use std::io::*;
use std::cmp;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn read_vec_char() -> Vec<char> {
    read::<String>().chars().collect()
}

fn read_mat<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_mat_char(n: usize) -> Vec<Vec<char>> {
    (0..n).map(|_| read_vec_char()).collect()
}

fn main() {
    let n = read::<usize>();
    let mut ls: Vec<i64> = Vec::new();
    let mut rs: Vec<i64> = Vec::new();
    for i in 0.. n {
        let v = read_vec::<i64>();
        ls.push(v[0]);
        rs.push(v[1]);
    }
    ls.sort_by(|a,b| b.cmp(a));
    rs.sort();
    let mut li = 0;
    let mut ri = 0;
    let mut x = 0;
    let mut ans1 = 0;
    loop {
        if x < ls[li] {
            ans1 += ls[li] - x;
            x = ls[li];
            li += 1;
        } else {
            ans1 += x.abs();
            break;
        }
        if x > rs[ri] {
            ans1 += x - rs[ri];
            x = rs[ri];
            ri += 1;
        } else {
            ans1 += x.abs();
            break;
        }
    }
    li = 0;
    ri = 0;
    x = 0;
    let mut ans2 = 0;
    loop {
        if x > rs[ri] {
            ans2 += x - rs[ri];
            x = rs[ri];
            ri += 1;
        } else {
            ans2 += x.abs();
            break;
        }
        if x < ls[li] {
            ans2 += ls[li] - x;
            x = ls[li];
            li += 1;
        } else {
            ans2 += x.abs();
            break;
        }
    }
    let ans = cmp::max(ans1,ans2);
    println!("{}",ans);
}


Measured memory_bytes: 6396
#include <cstdio>
int et[2][4] = {0};

void etest(int eangle,float epower){
	if(epower >= 1.1){
		et[eangle][0]++;
	}
	else if(epower >= 0.6 && epower < 1.1){
		et[eangle][1]++;
	}
	else if(epower >= 0.2 && epower < 0.6){
		et[eangle][2]++;
	}
	else{
		et[eangle][3]++;
	}
	return ;
}

int main(){
	float l,r;
	while(~scanf("%f%f",&l,&r)){
		etest(0,l),etest(1,r);
	}
	for(int i=0;i<4;i++){
		printf("%d %d\n",et[0][i],et[1][i]);
	}
	return 0;
}

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

using ll=long long;

int main(){
    int N,M; cin >> N >> M;
    vector<int> s(M), c(M);
    for(int i=0; i<M; i++){
        cin >> s[i] >> c[i];
    }
    int num;
    bool ans;
    if(N == 1) num=0;
    else num=pow(10,N-1);
    for(num ; num<pow(10,N); num++){
        ans=true;
        vector<int> d(3, 10);
        if(0<=num && num<10) d[0]=num%10;
        else if(10<=num && num<100){
            d[0]=num/10%10;
            d[1]=num%10;
        }
        else{
            d[0]=num/100%10;
            d[1]=num/10%10;
            d[2]=num%10;
        }
        for(int i=0; i<M; i++){
            if(d[s[i]-1] != c[i]) ans=false;
        }
        if(ans) break;
    }  
    if(ans) cout << num << endl;
    else cout << -1 << endl;
    return 0;
}

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

const int INF = 1e9;
int N, A, B, C;

int dfs(vector<int> l, int count, int sum_A, int sum_B, int sum_C){

  if(count == N){
    if(sum_A == 0 || sum_B == 0 || sum_C == 0)
      return INF;
    else
      return abs(A-sum_A)+abs(B-sum_B)+abs(C-sum_C);
  }
  
  int value_A = dfs(l, count+1, sum_A + l.at(count), sum_B, sum_C);
  int value_B = dfs(l, count+1, sum_A, sum_B + l.at(count), sum_C);
  int value_C = dfs(l, count+1, sum_A, sum_B, sum_C + l.at(count));
  int value_not = dfs(l, count+1, sum_A, sum_B, sum_C);
  
  if(sum_A != 0) value_A += 10;
  if(sum_B != 0) value_B += 10;
  if(sum_C != 0) value_C += 10;

  return min({value_A, value_B, value_C, value_not});
}

int main(){

  cin >> N >> A >> B >> C;
  vector<int> l(N);
  for(int i=0; i<N; i++)
    cin >> l.at(i);
  
  cout << dfs(l, 0, 0, 0, 0) << endl;
  
}

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

int main() {
  int n;
  string ans = "No";
  cin >> n;
  for(int i=1; i<=9; i++){
    if(n%i==0 && n/i<= 9) {
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/* 
	بسم الله الرحمن الرحیم
	
	(; طلا یک جهانی
*/

#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 50 + 5;
int n, k, v[MAX_N];

void read_input() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> v[i];
}

void solve() {
	int ans = 0;
	for (int i = 0; i <= n; i++)
		for (int j = i - 1; j < n; j++) {
			int x = k - (i + n - j - 1);
			if (x < 0)
				continue;
			vector<int> vec;
			for (int t = 0; t < i; t++)
				vec.push_back(v[t]);
			for (int t = j + 1; t < n; t++)
				vec.push_back(v[t]);
			sort(vec.begin(), vec.end(), greater<int>());
			while (!vec.empty() && x && vec.back() < 0) {
				x--;
				vec.pop_back();
			}
			int sum = 0;
			for (int t: vec)
				sum += t;
			ans = max(ans, sum);
		}
	cout << ans;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		String s = a+b > c+d ? "Left" : "Right";
		if(a+b==c+d) {
			s = "Balanced";
		}
		System.out.println(s);
	}
}

Measured memory_bytes: 25044
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
d = Counter(readInts())
m = I()
t = Counter(readInts())


print('YES' if all(ti in d and d[ti] >= tc for ti, tc in t.items()) else 'NO')


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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<vector<int> > ivve;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define setp       setprecision
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define spc(x)     cout<<fixed<<setp(x)

const   long long  inf = 1e18;
const   long long  cs =  200005;
const   long long  mod = 1000000007;
const   double     PI =  2 * acos(0.0);
void solve()
{
    ll t,n,m,a,b,c,i,j,k,x,y,cnt=0,cnt1=0;
    bool flag = false;
    
    string s,s1="Sunny",s2="Cloudy",s3="Rainy";
    cin>>s;
    if(s==s1) cout<<s2<<endl;
    if(s==s2) cout<<s3<<endl;
    if(s==s3) cout<<s1<<endl;

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

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

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<math.h>
#include<string.h>
#include<set>
#include<algorithm>
using namespace std;

int main(){
    string a;
    cin>>a;

    int start=0,end=0;
    for(int i=0;i<a.size();++i)if(a[i] == 'A'){
        start=i;break;
    }
    for(int i=a.size()-1;i>=0;--i)if(a[i] == 'Z'){
        end=i;break;
    }
    cout<<end-start+1;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 100000000

using namespace std;

int main() {
   char c;
   cin >> c;
   if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
   cout << "vowel" << endl;
   else
   cout << "consonant" << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){
  char O[51],E[51],ans[102];
  int i,len1,len2;
  scanf("%s",O);
  scanf("%s",E);
  len1 = strlen(O);
  len2 = strlen(E);
  for(i=0;i<len2;i++){
    printf("%c",O[i]);
    printf("%c",E[i]);
  }
  if(len1 > len2) printf("%c",O[len1-1]);
  putchar('\n');
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
	char input[10];
	char *tate;
	char *yoko;
	char kugiri[] = " ";
	int x, y;
 
	fgets(input, sizeof(input), stdin);
	tate = strtok(input, kugiri);
	yoko = strtok(NULL, kugiri);
	x = atoi(tate);
	y = atoi(yoko);
	printf("%d %d\n", x * y, 2 * (x + y));
 
	return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for(int i=0; i<N; i++){
    cin >> l.at(i);
  }
  sort(l.begin(), l.end(), greater<int>());
  int ans=0;
  for(int i=0; i<K; i++){
    ans += l.at(i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include <vector>

using namespace std;

int gcd(int a, int b){
  if(a<b){
    int tmp=a;
    a=b;
    b=tmp;
  }
  int r = a%b;
  if(r==0){
    return b;
  }else{
    return gcd(b,r);
  }
}
    

int main(){
  int n;cin>>n;
  
  int sum=0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
       int g=gcd(i,j);
      for(int k=1;k<=n;k++){
       sum+=gcd(g,k);
      }
    }
  }
    
  cout<<sum;
  
  return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
#define INF (int)(1e9)
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i = 1;i <= (int)(n); i++)
#define FOR(i,k,n) for(int i = (k); i < (int)(n); i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define pb push_back
#define vec vector<int>


/*--------------------------------------------*/
/*ll factorial(ll);
void list_Prime(ll);
ll divisor(ll);
ll lcm(ll, ll);//AとBの最小公倍数
ll gcd(ll,ll);

int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
*/
/*--------------------------------------------*/
/*--------------------------------------------*/
/*
ll factorial(ll n){
    if(n==1)return 1;
    return n*factorial(n-1);
}
ll lcm(ll A, ll B) {//最小公倍数
    ll a = A;
    ll b = B;
    if (a == 0 || b == 0) { return 0; }
    if (a < 0) { a = -a; }
    if (b < 0) { b = -b; }
    while (b > 0) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return A/a*B;
}

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


void list_Prime(ll n){//n以下の素数を全て見つける
    ll Limit=(int)sqrt((double)n);
    for(ll i=2;i<=n;i++)prime[i]=1;//最初はみんな素数かも
    //素数の整数倍を消していく(ルートnまで)
    for(ll i=2;i<=Limit;i++){
        if(prime[i]){
            for(ll j=2*i;j<=n;j++){
                if(j%i==0){
                    prime[j]=0;                
                }
            }
        }
    }
}

ll divisor(ll n){
    for(ll i=2;i<=n;i++){
        ll d=1;
        ll tmp=i;
        while(tmp>0){
            d++;
            while(tmp%d==0){
                prime[i]++;
                tmp/=i;
            }
        }
    }
    ll sum=1;
    for(ll i=2;;i<=n;i++){
        sum*=(prime[i]+1)/MOD;
    }    
    cout<<"sum="<<sum<<endl;

    return sum%MOD;
}
*/
/*--------------------------------------------*/
int main(){
    int n;cin>>n;
    string ans="";
    while(n!=0){
        if(n%(-2)==0){
            ans='0'+ans;
        }else{
            n--;
            ans='1'+ans;
        }
        n/=-2;
    }if(ans=="")ans='0';
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    string s;
    int a=0;
    while(cin>>s){
        if(s==string(s.rbegin(),s.rend()))a++;
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 3140
import numpy as np

h, w = map(int, input().split())

li = []
for i in range(h):
    a = list(input())
    li.append(a)

count = 0
li_2 = []
for i in range(h):
    for j in range(w):
        if li[i][j] == '#':
            li_2.append(list(li[i][:]))
            count += 1
            break
li_3 = []
li_2 = [list(x) for x in zip(*li_2)]

count2= 0
for j in range(w):
    for k in range(count):
        if li_2[j][k] == '#':
            li_3.append(li_2[j][:])
            count2 += 1
            break


li_3 = [list(y) for y in zip(*li_3)]

for i in range(count):
    for j in range(count2):
        print(li_3[i][j], end='')
        if j == count2-1:
            print('')



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

#ifdef LOCAL_PC
	#define debug(args...) { cout.flush(); fflush(stdout); fprintf(stderr, args); }
#else
	#define debug(args...) ; /*  */
#endif
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class Ty> Ty rnd(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }

template<class num> inline void rd(num &x) {
	char c; while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar()))
		x = (x << 3) + (x << 1) + c - '0';
	if (neg) x = -x;
} template <class T, class... Args> inline void rd(T& x, Args&... args) { rd(x); rd(args...); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

int solve(int i, vector<int> und, int n, int m, int x, vector<vector<int>>& C) {
	if (i == n) {
		 bool ok = true;
		for (int j = 0; j < m; j++) {
			if (und[j] < x) ok = false;
		}
		if (ok) return 0;
		else return INF;
	}
		
	vector<int> nund(m);
	for (int j = 0; j < m; j++) {
		nund[j] = und[j] + C[i][j+1];
	}

	// pego o i ou nao pego
	int ans1 = C[i][0] + solve(i+1, nund, n, m, x, C);
	int ans2 = solve(i+1, und, n, m, x, C);
	return min(ans1, ans2);
}

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

	 int n, m, x; rd(n, m, x);
	 vector<vector<int>> C(n, vector<int>(m+1));

	 for (int i = 0; i < n; i++) {
		for (int j = 0; j <= m; j++) {
			 rd(C[i][j]);
		}
	 }

	int ans = solve(0, vector<int>(m), n, m, x, C);
	printf("%d\n", ans < INF ? ans : -1);
}

Measured memory_bytes: 3740