akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();

    string tmp = s;

    int ans1 = 0;
    int ans2 = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if (tmp[i] == tmp[i + 1])
        {
            if (tmp[i] == '0')
            {
                tmp[i + 1] = '1';
            }
            else
            {
                tmp[i + 1] = '0';
            }
            ans1++;
        }
    }

    tmp = s;

    for (int i = n - 1; i > 0; i--)
    {
        if (tmp[i] == tmp[i - 1])
        {
            if (tmp[i] == '0')
            {
                tmp[i - 1] = '1';
            }
            else
            {
                tmp[i - 1] = '0';
            }
            ans2++;
        }
    }

    cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 512
m,n = [int(x) for x in input().split()]
a = []
b = []
for _ in range(m):
  a.append(input())
m = 0
for i in range(n):
  b.append(input())
  if b[i] in a[i]:
    m += 1
print('Yes') if m == n else print('No')


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

using namespace std;

const int N = 5003;
long long dp[N][N];
int a[N];
int sz[N];
long long can[N];
int num[N];

struct graph {
	int n;
	vector<vector<int>> edge;
	graph(int n) : n(n) {
		edge.resize(n + 1);
	}
	void add(int u,int v) {
		edge[u].emplace_back(v);
		edge[v].emplace_back(u);
	}
	void dfs(int u,int p = 0) {
		sz[u] = 1;
		dp[u][0] = a[u];
		for (auto&v : edge[u]) {
			if (v == p) continue;
			dfs(v,u);
			for (int i = 0;i < sz[u] + sz[v];++i) can[i] = 1e16;
			if (a[u] > 0) {
				int pos ;
				if (a[v] > 0) pos = num[v];
				else pos = n;
				for (int i = 0;i < sz[v];++i) if (dp[v][i] < 0) {
					pos =min(pos,i+1);
					break;
				} 
				num[u] += pos ;
			}
			for (int i = 0;i < sz[u];++i) {
				for (int j = 0;j < sz[v];++j) {
					can[i+j] = min(can[i+j],dp[u][i] + dp[v][j]);
					if (dp[v][j] < 0) can[i+j+1] = min(can[i+j+1],dp[u][i]);
				}
				if (a[v] > 0) {
					can[i + num[v] + 1] = min(can[i+num[v]+1],dp[u][i]);
				}
			}
			sz[u] += sz[v];
			for (int i = 0;i < sz[u];++i) dp[u][i] = can[i];
		}
	}
};

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	graph g(n);
	for (int i = 1;i <= n;++i) cin >> a[i];
	for (int i = 1;i < n;++i) {
		int u,v;
		cin >> u >> v;
		g.add(u,v);
	}
	g.dfs(1);
	int pos = n;
	if (a[1] > 0) pos = num[1];
	for (int i = 0;i < n;++i) if (dp[1][i] < 0) return cout << min(pos,i),0;
	assert(pos != n);
	cout << pos;
}

Measured memory_bytes: 194944
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(void)
{
string day;

cin>>day;

if(day=="SUN") cout<<7<<endl;
if(day=="MON") cout<<6<<endl;
if(day=="TUE") cout<<5<<endl;
if(day=="WED") cout<<4<<endl;
if(day=="THU") cout<<3<<endl;
if(day=="FRI") cout<<2<<endl;
if(day=="SAT") cout<<1<<endl;

} 
 

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

ll A, B, C;
bool S[100] = {false};

int main(void){
    
    cin >> A >> B >> C;
    
    for(int i = 0; !S[A * i % B]; ++i) S[A * i % B] = true;
    if(S[C]) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  ll n; cin >> n;
  vll a(50, n/50);
  rep(i, 50) a[i]+=i;
  int rest = n%50;
  // if (n<50) rest = 0;
  // printf("%d rest\n", rest);
  rep(i,rest) {
    a[i]+=50;
    rep(j,50) {
      if (j==i)continue;
      a[j]--;
    }
  }
  cout << 50 << endl;
  rep(i, 50) {
    printf("%lld%c", a[i], i==49?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 3672
#include <stdio.h>
#define mod 1000000007
int main(int argc, char *argv[])
{
	long long n,nn,i,ans,ten,nine,eight;
	scanf("%lld",&n);
	ten=nine=eight=1;
	for(i=1;i<=n;i++){
		ten*=10;
		ten%=mod;
		nine*=9;
		nine%=mod;
		eight*=8;
		eight%=mod;
	}
	ans=(ten-2*nine+eight)%mod;
	printf("%lld\n",(ans+mod)%mod);
}

Measured memory_bytes: 1732
#include <iostream>
#include <stdio.h>

using namespace std;

int main(void) {
  long long H, W, x, y;
  
  cin >> W >> H >> x >> y;
  
  printf("%lf %d\n", (double)(H * W) / 2.0, ((x + x == W) && (y + y == H)) ? 1 : 0);
  return 0;
}

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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>;

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())
#define END cout<<"\n"

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//


signed main(){
    CIN(N,K);
    vector<double> p(N,0);
    double ans=0;
    rep(i,N){
        double P;cin>>P;
        p[i]=(1+P)/2;
    }
    rep(i,K)ans+=p[i];
    double cur=ans;
    Rep(i,1,N-K+1){
        cur=cur+p[i+K-1]-p[i-1];
        chmax(ans,cur);
    }

    printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    def gen():
        counter = 0
        q = deque(range(1, 10))
        while counter < 100001:
            n = q.popleft()
            yield n
            counter += 1
            t = n % 10
            if t > 0:
                q.append(n*10 + (t - 1))
            q.append(n*10 + t)
            if t < 9:
                q.append(n*10 + (t + 1))
    g = gen()
    for _ in range(ii() - 1):
        next(g)
    print(next(g))

main()







Measured memory_bytes: 14132
import java.util.*

fun main(args: Array<String>) {
    Main().start()
}

class Main {
    lateinit var colors: IntArray
    lateinit var depth: IntArray
    lateinit var G: Array<MutableList<Int>>

    fun start() {
        val sc = Scanner(System.`in`)
        val N = sc.nextInt()
        val M = sc.nextInt()
        colors = IntArray(N)
        depth = IntArray(N) { -1 }
        G = Array<MutableList<Int>>(N) { mutableListOf() }
        repeat(M) {
            val a = sc.nextInt() - 1
            val b = sc.nextInt() - 1
            G[a].add(b)
            G[b].add(a)
        }
        val Q = sc.nextInt()
        val v = IntArray(Q)
        val d = IntArray(Q)
        val c = IntArray(Q)
        repeat(Q) {
            v[it] = sc.nextInt() - 1
            d[it] = sc.nextInt()
            c[it] = sc.nextInt()
        }
        for (i in Q - 1 downTo 0) {
            dfs(v[i], d[i], c[i])
        }
        colors.forEach(::println)
    }

    fun dfs(v: Int, d: Int, c: Int) {
        if (depth[v] >= d || d < 0) {
            return
        }
        depth[v] = d
        if (colors[v] == 0) {
            colors[v] = c
        }
        if (d > 0) {
            G[v].forEach { v -> dfs(v, d - 1, c) }
        }
    }
}


Measured memory_bytes: 124460
#include <algorithm>
#include <stdio.h>
using namespace std;
using ll = long long;

int n, x, l[110];
int main() {
	scanf("%d %d", &n, &x);
	int p = 0, c = 1;
	for (int i = 0; i < n; i++) {
		scanf("%d", l + i);
		p += l[i];
		c += p <= x;
	}
	printf("%d\n", c);
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scanner.nextInt();
        String rb = scanner.next();
        int red = 0;
        for(int i = 0; i < rb.length(); i++){
            if(rb.charAt(i) == 'R'){
                red++;
            }
        }
        if(red > rb.length()/2){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 24020
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
c = [0]*(n-1)
s = [0]*(n-1)
f = [0]*(n-1)

for i in range(n-1):
    c[i], s[i], f[i] = map(int, input().split())

def dfs(eki,t):
    if eki == n-1:
        return t

    cc = c[eki]
    ss = s[eki]
    ff = f[eki]

    m = max(0,-(-t+ss)//ff)
    if t < ss:
        return dfs(eki+1, ss+cc)
    elif t%ff==0:
        return dfs(eki+1, t+cc)
    else:
        return dfs(eki+1, -(-t//ff)*ff+cc)

for i in range(n):
    print(dfs(i,0))


Measured memory_bytes: 3444
n,a,b = map(int, input().split())
mod = 10**9+7

akai=1
nakai=n
bkai=1
nbkai=n
for i in range(2,a+1):
  akai=(akai%mod)*(i%mod)
  nakai=(nakai%mod)*((n-i+1)%mod)
for i in range(2,b+1):
  bkai=(bkai%mod)*(i%mod)
  nbkai=(nbkai%mod)*((n-i+1)%mod)
akai=akai%mod
bkai=bkai%mod
nakai=nakai%mod
nbkai=nbkai%mod
nakai=nakai*pow(akai,mod-2,mod)
nbkai=nbkai*pow(bkai,mod-2,mod)
print((pow(2,n,mod)-nakai-nbkai-1)%mod)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
typedef long long ll;
typedef unsigned long long int llt;
const int N = 3e5 + 10;


int main()
{
    int n;
    cin>>n;
    double ans = 0.0;
    for(int i=0;i<n;i++)
    {
        double a;
        cin>>a;
        ans += (1 / a);
    }
    ans = 1 / ans;
    cout<<setprecision(10)<<ans<<endl;
    return 0;
}


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

using namespace std;
using ulli = unsigned long long int;

int main(void){
	vector<array<ulli, 3> > rec(1);
	
	// input
	for(int j = 0; j < 3; ++j){
		cin >> rec[0][j];
		
		if(rec[0][j] % 2 == 1){
			cout << "0" << endl;
			return 0;
		}
	}
	
	// loop	
	ulli i = 0;
	while(true){
		array<ulli, 3> t;
		for(int j = 0; j < 3; ++j){
			int j1 = (j + 1) % 3;
			int j2 = (j + 2) % 3;
			t[j] = rec[i][j1] + rec[i][j2];
			t[j] /= 2;
			
			if(t[j] % 2 == 1){
				cout << i + 1 << endl;
				return 0;
			}
			// cout << t[j] << ' ';
		}
		// cout << endl;
		for(auto & i : rec){
			bool flag = true;
			for(int j = 0; j < 3; ++j){
				flag &= i[j] == t[j];
			}
			if(flag){
				cout << "-1" << endl;
				return 0;
			}
		}
		rec.push_back(t);
		++i;
	}
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
re = 0
for i in range(1000):
    ans = [0]*3
    for j in range(3):
        ans[j] = str(i % 10)
        i = i // 10
    ans.reverse()
    flag = False
    idx_left = S.find(ans[0])
    idx_right = S.rfind(ans[2])
    if idx_left != -1 and idx_right != -1 and idx_left < idx_right:
        if ans[1] in S[idx_left+1:idx_right]:
            flag = True
    if flag:
        re += 1
print(re)

Measured memory_bytes: 3064
<?php
list($a, $b) = ints();
for ($i = 0; $i <= 11; ++$i) $s[$i + 2] = $i;
$s[1] = $i;
if ($s[$a] > $s[$b]) $ans = 'Alice';
elseif ($s[$a] < $s[$b]) $ans = 'Bob';
else $ans = 'Draw';
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4604
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		int ans = 0;
		if (a + b < c) {
			ans += a + b + 1;
		} else {
			ans += c;
		}
		ans += b;
		System.out.println(ans);
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ALLR(v) v.rbegin(), v.rend()
#define ZERO(a) memset(a,0,sizeof(a))
#define RESULT(b) if (b) cout << "first" << endl; else cout << "second" << endl;

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 1e5+10;

int N;
vi A;

int main() {

  cin >> N;
  A = vi(N);
  REP(i, N) cin >> A[i];
  sort(ALL(A));
  REP (i, N) {
    if (A[i] % 2 == 1) {
      RESULT(true);
      return 0;
    }
  }
  RESULT(false);
  return 0;

}

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

using namespace std;

//#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vector<int> a(n);
  
  REP(i, n) {
    cin >> a[i];
  }

  vector<int> odd, even;
  REP(i, n) {
    if(i % 2 == 1) {
      even.pb(a[i]);
    } else {
      odd.pb(a[i]);
    }
  }

  if(n % 2 == 1) {
    reverse(odd.begin(), odd.end());
    REP(i, odd.size()) {
      cout << odd[i] << " ";
    }
    REP(i, even.size()) {
      cout << even[i] << " ";
    }
    cout << endl;
  } else {
    reverse(even.begin(), even.end());
    REP(i, even.size()) {
      cout << even[i] << " ";
    }
    REP(i, odd.size()) {
      cout << odd[i] << " ";
    }
    cout << endl;
  }
  
}


Measured memory_bytes: 3956
a = []
for i in range(6):
    a.append(int(input()))
f = 1
amax = max(a)
amin = min(a)
for i in range(5):
    if abs(amax - a[i]) <= a[-1] and abs(amin - a[i]) <= a[-1]:
        continue
    else:
        f = 0
if f:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3060
defmodule Main do
  def main do
    k =
      IO.read(:line)
      |> String.trim()
      |> String.to_integer()

    [a, b] =
      IO.read(:line)
      |> String.trim()
      |> String.split()
      |> Enum.map(&String.to_integer/1)

    s =
      if(Enum.any?(a..b, fn x -> rem(x, k) === 0 end)) do
        "OK"
      else
        "NG"
      end

    IO.puts(s)
  end
end


Measured memory_bytes: 30856
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	LL N;
	cin >> N;
	LL ans = 0;
	ans += N/11;
	N -= ans*11;
	ans*=2;
	if( N == 0){
	}else if( 1 <= N && N <= 6 ){
		ans += 1;
	}else{
		ans += 2;
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int d, g;cin >> d >> g;
  int p[d+10], c[d+10];
  rep(i,d)cin >> p[i] >> c[i];

  ll ans = 1e9;
  for(int mask = 0; mask < (1 << d); ++mask){
      ll s = 0, num = 0, rest_max = -1;
      for(int i = 0; i < d; ++i){
          if(mask >> i&1){
              s += 100 * (i+1) * p[i] + c[i];
              num += p[i];
          }else{
              rest_max = i;
          }
      }
      if(s < g){
          int s1 = 100 * (rest_max + 1);
          int need = (g - s + s1 - 99) / s1;

          if(need >= p[rest_max])continue;

          num += need;
      }
      ans = min(ans, num);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
vector<int> v[2000];
signed main(){
	int n;
	cin>>n;
	vector<int> a;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
		for(int j=0;j<=i;j++){
			v[j].pb(x);
		}
	}
	for(int i=0;i<n;i++){
		sort(v[i].begin(),v[i].end());
	}
	int ans = 0;
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			int mi = abs(a[i]-a[j])+1;
			int ma = a[i]+a[j]-1;
			ans += upper_bound(v[j+1].begin(),v[j+1].end(),ma)-lower_bound(v[j+1].begin(),v[j+1].end(),mi);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<ll,int> P;

const ll MAX_N=131072;
int bit[MAX_N*2-1];
ll n;
int main(){
  int N,M;cin>>N;
  int T[N+1];
  int sum=0;
  rep(i,N){
    cin>>T[i];
    sum+=T[i];
  }
  cin>>M;
  rep(i,M){
    int P,X;
    cin>>P>>X;
    P-=1;
    cout<<sum-T[P]+X<<endl;
  }
}


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

const int mod=1e9+7;

void U(int &x,int y){
    x=(x+y)%mod;
}

int n, m, a[202000];
char s[202000];

int main(){
    cin>>n>>m>>s+1;
    for (int i=1;i<=m;++i)
        a[i]= s[i]==s[1];
    if (*min_element(a+1,a+m+1)==1){
        static int f[202000][2][2];
        f[1][0][0]=f[1][1][1]=1;
        for (int i=1;i<n;++i){
            for (int s=0;s<=1;++s)
                for (int t=0;t<=1;++t)
                    for (int tt=0;tt<=1;++tt){
                        if (t==0&&tt==0) continue;
                        U(f[i+1][s][tt],f[i][s][t]);
                    }
        }
        int ans=(1ll*f[n][0][1]+f[n][1][0]+f[n][1][1])%mod;
        cout<<ans<<endl;
        return 0;
    }
    int las=0, mx=1e9; vector<int>vec;
    for (int i=1;i<=m;++i)
        if (a[i]){
            ++las;
        }else{
            vec.push_back(las);
            las=0;
        }
    {
        int t=vec.front(); vec.erase(vec.begin());
        mx=min(mx,(t&1? t: t+1));
    }
    for (auto t:vec){
        if (t&1) mx=min(mx,t);
    }


    static int ans=0, f[202000], sum[202000];
    f[1]=sum[1]=1;
    for (int i=1;i<=n;++i){
        if (i!=1){
            f[i]=(sum[i-2]-sum[max(0,i-mx-3)]+mod)%mod;
            sum[i]=(sum[i-2]+f[i])%mod;
        }
        if ((n-i&1)&&n-i<=mx){
            ans=(ans+(ll)f[i]*(n-i+1))%mod;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4864
x, y = list(map(int, input().split()))
g0, g1, g2 = [1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2, ]
def num_group(a):
    if a in g0: return 0
    if a in g1: return 1
    if a in g2: return 2
if num_group(x) == num_group(y):
    print('Yes')
else:
    print('No')   

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

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define TRAV(a, x) for(const auto& a : x)
#define ALL(x) x.begin(), x.end()
#define NEXT_PERM(x) while(next_permutation(ALL(x))) // 순열 알고리즘(오름)
#define PREV_PERM(x) while(prev_permutation(ALL(x))) // 순열 알고리즘(내림)
#define PRINT(x) cout << x
#define PRINT_LN(x) cout << x << endl;
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

typedef long long int ll;
typedef double db;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<char> vc;

void solve() {
  ll k;
  cin >> k;
  ll start = 100;
  db value = start;
  ll cnt = 1;
  while(true) {
    value += floor(value * 0.01);
    if (value >= k) {
      PRINT(cnt);
      break;
    }
    cnt++;
  }
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <map>
#include <vector>
#include <stack>
using namespace std;
int main(int argc, char *argv[]) {
	int a, b;
	scanf("%d %d", &a, &b);
	if (a%2 == 0 || b %2 == 0) printf("No");
	else printf("Yes");
	return 0;
}

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int H,W,T;
string s[10];

int main(){
  string s,t;
  cin>>s>>t;
  if(int(s.size()) != int(t.size()) - 1){
    cout << "No" << endl;
    return 0;
  }
  for(int i(0);i<int(s.size());i++){
    if(s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}



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

#define ll  long long int
#define ld  long double
#define MAX 1000001
#define MOD 1000000007
#define pi  3.14159265358979323846264338
#define mp  make_pair
#define pb  push_back
#define pll pair<ll,ll>
#define vl  vector<ll>
#define vi  vector<int>
#define vs  vector<string>
#define vc  vector<char>
#define fst first
#define sec second
#define foi(i, a, b)   for(ll i = a; i<b;i++)
#define fod(i, a, b)   for(ll i = a;i>=b;i--)
#define all(v)         (v).begin(), (v).end()
#define max3(a, b, c)  max(max(a,b), c)
#define min3(a, b, c)  min(min(a,b), c)
#define ump  unordered_map<ll,ll>
#define us   unordered_set<ll>
#define nl  "\n"
#define INF  (ll)1e18
#define s(v) (ll)(v).size()
#define e(v) (v).empty

using namespace std;

ll gcd(ll a,ll b) { if (a==0) return b; return gcd(b%a,a);}


void solve(){
    int n;
    cin>>n;

    
    int prev[3]={0};
    int next[3];
    for(int i=0;i<n;i++){
        cin>>next[0]>>next[1]>>next[2];
        next[0] += max(prev[1],prev[2]);
        next[1] += max(prev[0],prev[2]);
        next[2] += max(prev[0],prev[1]);
        for(int i=0;i<3;i++){
            prev[i] = next[i];
        }
    }
    cout<<max(max(prev[0],prev[1]),prev[2])<<"\n";
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

#define R (long long)(1e9 + 7)
#define INF (long long)(1e16L + 5)
#define ll long long
#define grid vector<vector<ll>>

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
  

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int n = s.length();
    long long sum = 0;
    for(auto x : s)
    {
        sum = sum + (x - '0');
    }
    if(sum % 9 == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

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

int main() {
  int n,ans=0,m;
  cin >> n;
  m=10*n;
  for(int i=0;i<3;i++){
    m=m/10;
    if((m-7)%10==0){
      ans=1;
      break;
    }
  }
    if(ans==0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

int main() {
	string s;
	cin >> s;
	s.at(5) = ' ';
	s.at(13) = ' ';
	cout << s << endl;

}

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

long long M;
long long N;
vector<long long> B(100001);
vector<long long> A(100001);
stack<long long> st[100001];
vector<long long> dep(100001);
vector<long long> res(100001);

long long depth(long long n) {
	if (dep[n] != -1) return dep[n];

	if (st[n].empty()) {
		res[n] = 0;
		return dep[n] = 0;
	} else {

		while (!st[n].empty()) {
			long long ntop = st[n].top();
			if (depth(ntop) > dep[n]-1) {
				res[n] = ntop;
				dep[n] = depth(ntop)+1;
			}
			st[n].pop();
		}
		return dep[n];
	}
}

int main(){
	scanf("%lld",&N);
	scanf("%lld",&M);
	for(int i = 0 ; i <= ((N-1)+M)-1 ; i++){
		scanf("%lld",&A[i]);
		scanf("%lld",&B[i]);
	}

	for(int i = 0 ; i <= ((N-1)+M)-1 ; i++){
		st[B[i]].push(A[i]);
	}

	for (int i = 1 ; i <= N ; i++) {
		dep[i] = -1;
	}

	for (int i = 1 ; i <= N ; i++) {
		depth(i);
	}

	for (int i = 1 ; i <= N ; i++) {
		cout << res[i] << "\n";
	}

	return 0;
}


Measured memory_bytes: 75136
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll a,b,c,d,e,f,g,h,i,j,k,sum=0;
    vector<ll> v;
cin>>a>>b;
for(i=0;i<b;i++)
    {
        cin>>c;
        v.push_back(c);
    }
    sum=v[b-1]-v[0];
    for(i=b-1;i>=1;i--)
    {
      c=a-v[i]+v[i-1];
if(sum>c) sum=c;
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 2420
N,M = (int(x) for x in input().split())
list = [int(x) for x in input().split()]

sum = 0
result = 0

for i in range(N):
    sum = sum + list[i] 

for i in range(N):
    #print(list[i])
    if list[i] >= sum/4/M:
        result = result + 1
#print(result)
#print(sum/4)
if result >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
(let* ((n (read))
       (k (read))
       (flag (make-array (+ n 1) :initial-element 0)))
  (loop repeat k
        for d = (read)
        do (loop repeat d
                 for a = (read)
                 do (incf (aref flag a))))
  (format t "~a~%" (loop for i from 1 to n
                         counting (zerop (aref flag i)))))


Measured memory_bytes: 29700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define err(x) debug() << "[" << #x << ": " << x << "]\n"
template<class c> auto try_out(c a) -> decltype(cerr << a, 0);
char try_out(...);
struct debug {
#ifdef LOCAL
template<class c, class d> debug& operator<<(pair<c,d> e){
    return *this << "(" << e.first << ", " << e.second << ")";
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) != 1, debug&>::type operator<<(c a){
    cerr << boolalpha << a;
    return *this;
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) == 1, debug&>::type operator<<(c a){
    *this << "{";
    for (auto it = a.begin(); it != a.end(); it++)
        *this << ","[1 - (it != a.begin())] << *it;
    return *this << "}";
}
#else
template<class c>debug& operator<<(c){
    return *this;
}
#endif
};







int main() 
{
    int n, m;
    cin >> n >> m;
    
    int mx = INT_MIN;
    int mn = INT_MAX;
    
    for (int i = 0; i < m; ++i)
    {
        int l, r;
        scanf("%d %d", &l, &r);
        
        mx = max(mx, l);
        mn = min(mn, r);
    }
    
    err(mx);
    err(mn);
    
    cout << max(0, mn + 1 - mx) << endl;
    
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    REP(i, n)cin >> p[i];

    map<int, int> Pinv;
    REP(i, n)Pinv[p[i]] = i;
    multiset<int> shown;
    shown.insert(-1);
    shown.insert(-1);
    shown.insert(n);
    shown.insert(n);
    LL ans = 0;
    for(LL i = n;i >= 1;--i){
        int now = Pinv[i];
        LL r = *shown.lower_bound(now);
        LL rr = *next(shown.lower_bound(now));
        LL l = *prev(shown.lower_bound(now));
        LL ll = *prev(shown.lower_bound(now), 2);
        ans += ((rr - r) * (now - l) + (l - ll) * (r - now)) * i;
        shown.insert(now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	string s;
	cin >> s;
	stack<int> S1;
	stack<pair<int,int>> S2;
	int sum = 0;
	vector<int> ans;
	int n = s.size();
	for(int i = 0;i<n;i++)
	{
		if(s[i]=='\\')
		{
			S1.push(i);
			
		}
		else if(s[i]=='/'&&!S1.empty())
		{
			//S2.push(make_pair(S1.top(),S1.top()-i));
			int sum2 = 0;
			while(!S2.empty()&&!S1.empty()&&S2.top().first>S1.top())
			{
				
				sum2 += S2.top().second;
				S2.pop();
			}
			sum += i-S1.top();
			S2.push(make_pair(S1.top(),sum2+i-S1.top()));
			S1.pop();
			
		}
	}
	cout<<sum<<endl;
	cout<<S2.size();
	if(S2.size()!=0)cout<<' ';
	
	while (!S2.empty())
	{
		ans.push_back(S2.top().second);
		S2.pop();
	}
	for(int i = ans.size()-1;i>=0;i--)
	{
		if(i<ans.size()-1)cout<<' ';
		cout<<ans[i];
	}
	cout<<endl;
	
	return 0;
}


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


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


#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

int main() {
	
	int n, a, b;
	string s;

	cin >> n >> a >> b >> s;


	int passa = 0;
	int passb = 0;
	rep(i, 0, n) {
		if (s[i] == 'c') {
			cout << "No" << endl;
		}
		else if (s[i] == 'a') {
			if (passa + passb < a + b) {
				cout << "Yes" << endl;
				passa += 1;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (s[i] == 'b') {
			if ((passa + passb < a + b) &&
				(passb < b)) {
				cout << "Yes" << endl;
				passb += 1;
			}
			else {
				cout << "No" << endl;
			}
		}

		
	}


	return 0;
}



Measured memory_bytes: 896
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;


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

	vector<int> odd = vector<int>(100000,0);
	vector<int> even = vector<int>(100000,0);
	for(int i=0;i<n;i++){
		int tmp;
		cin >> tmp;
		if(i % 2 != 0){
			odd[tmp]++;
		}else{
			even[tmp]++;
		}
	}

	std::vector<int>::iterator oddIt = max_element(odd.begin(), odd.end());
	std::vector<int>::iterator evenIt = max_element(even.begin(), even.end());
	int maxOddNum = distance(odd.begin(), oddIt);
	int maxEvenNum = distance(even.begin(), evenIt);

	int result;
	if(maxOddNum == maxEvenNum && odd[maxOddNum] + even[maxEvenNum] == n){
		result = n/2;
	}else{
		if(maxOddNum != maxEvenNum){
			result = n - odd[maxOddNum] - even[maxEvenNum];
		}else{

			int odd1 = odd[maxOddNum];
			int even1 = even[maxEvenNum];
			odd.erase(odd.begin() + maxOddNum);
			even.erase(even.begin() + maxEvenNum);

			oddIt = max_element(odd.begin(), odd.end());
			evenIt = max_element(even.begin(), even.end());
			maxOddNum = distance(odd.begin(), oddIt);
			maxEvenNum = distance(even.begin(), evenIt);

			int odd2 = odd[maxOddNum];
			int even2 = even[maxEvenNum];
			if(odd1 + even2 > even1 + odd2){
				result = n - odd1 - even2;
			}else{
				result = n - even1 - odd2;
			}
		}
	}

	cout << result << "\n";
	return 0;
}

/*
int tmp_odd_max = 0;
int next_tmp_odd_max = 0;
for(int i=0;i<n/2;i++){
	if(tmp_odd_max < odd[2*i+1]){
		next_tmp_odd_max = tmp_odd_max;
		tmp_odd_max = odd[2*i+1];
	}
}

int tmp_even_max = 0;
int next_tmp_even_max = 0;
for(int i=0;i<n/2+1;i++){
	if(tmp_even_max < odd[2*i]){
		next_tmp_even_max = tmp_even_max;
		tmp_even_max = even[2*i+1];
	}
}
*/


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//-----CODE------//

void solve(void)
{
  int N,K; cin>>N; cin>>K;
  vector<int> vec(N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];

  }
  int ANS = 0;
  for (int l = 0; l <= N; l++)
  {
    for (int r = 0; r <= N; r++)
    {
      priority_queue<int, vector<int>, greater<int> > que;
      int SUM = 0;
      if(l + r > min(N,K))continue;
      for (int i = 0; i < l; i++)
      {
        SUM += vec[i];
        que.push(vec[i]);
      }
      for (int i = 0; i < r; i++)
      {
        SUM += vec[N-1-i];
        que.push(vec[N-1-i]);
      }
      int cnt =  K - l -r;
      while(!que.empty() &&cnt > 0)
      {
        if(que.top() > 0)break;
        cnt--;
        SUM -= que.top();
        que.pop();
      }
      chmax(ANS,SUM);
      
    }
    
  }
  cout<<ANS<<endl;
  
  
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}

Measured memory_bytes: 256
#define ll     long long int
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    ll n,sum=0,ans=0,i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
        {
            sum+=i;
        }
        else
            ans+=i;
    }
   cout<<ans<<endl;
   return 0;


}



Measured memory_bytes: 3632
fun main(args: Array<String>) = println(run {
    val n = readLine()!!.toInt()
    val a = (1..n).map { readLine()!!.toInt() }

    val max1 = a.sortedDescending()[0]
    val max2 = a.sortedDescending()[1]
    a.map { if (it==max1) max2 else max1 }.joinToString("\n") { it.toString() }
})

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

#define Max 200000
#define Sentinel 2000000000
typedef long long llong;
int L[Max/2+2],R[Max/2+2];

llong merge(int A[],int n,int left,int mid, int right){
  int i,j,k;
  llong cnt=0;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=R[n2]=Sentinel;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
      cnt+=n1-i;
    }
  }
  return cnt;
}

llong mergeSort(int A[],int n,int left,int right){
  int mid;
  llong v1,v2,v3;

  if(left+1<right){
    mid=(left+right)/2;
    v1=mergeSort(A,n,left,mid);
    v2=mergeSort(A,n,mid,right);
    v3=merge(A,n,left,mid,right);
    return v1+v2+v3;
  }
  else return 0;
}

int main(){
  int A[Max],n,i;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>A[i];
  }
 llong ans=mergeSort(A,n,0,n);

  cout<<ans<<endl;
  return 0;

}



Measured memory_bytes: 4612
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		List<Integer> ls = new ArrayList<Integer>();

		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {
			if (!sc.hasNextInt()) {
				break;
			}
			int n = sc.nextInt();
			ls.add(Integer.valueOf(n));
		}

		Collections.sort(ls);
		Collections.reverse(ls);

		for (int height : ls.subList(0, Math.min(ls.size(), 3))) {
			System.out.println(height);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  


vector<pair<char,int>> runLength(string s) {
  int n = sz(s);
  vector<pair<char,int>> res;
  rep(i,n) {
    int cnt = 1;
    while(i < n-1 && s[i] == s[i+1]) {
      cnt++;
      i++;
    }
    res.push_back(pair<char,int>(s[i],cnt));
  }
  return res;
}

int main() {
  string s;
  cin >> s;
  vector<pair<char,int>> rl = runLength(s);
  ll ans = 0;
  int flag;
  if(s[0] == '<') {
    flag = 0;
  } else {
    flag = 1;
  }
  rep(i,sz(rl)) {
    ll num = rl[i].second+1;
    if(i % 2 == flag) {
      if(i+1 < sz(rl) && rl[i].second < rl[i+1].second) {
        num--;
      }
    } else {
      if(i-1 >= 0 && rl[i-1].second > rl[i].second) {
        num--;
      } else if(i-1>= 0 && rl[i-1].second == rl[i].second) {
        num--;
      }
    }
    ans += (num*(num-1ll))/2ll;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
//A
#include<stdio.h>
int main(void){
  int K;
  int A,B;
  int i;
  scanf("%d",&K);
  scanf("%d%d",&A,&B);
  for(i=A;i<=B;i++){
    if((i%K)==0){
      printf("OK");
      return 0;
    }
  }
  printf("NG");
  return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn =2e3+5;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n=s.size();
	if(n>k)
    {
        cout<<s.substr(0,k)<<"..."<<'\n';
    }
    else
    {
        cout<<s<<'\n';
    }




}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    long long num,z;
    set<long long> list;
    cin >> num;
    for (long long i=0; i<num; i++) {
        cin >> z;
        if (list.count(z)<1) {list.insert(z);}
        else {list.erase(z);}}
    cout << list.size();}

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

const ll MX = 1e18;
const long double PI = acos(-1);

int main()
{
    int a; cin >> a;
    if (a)
        pri(0);
    else
        pri(1);
    
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include<math.h>

int main(void){
    int n,sum=0,i;
    double ave,a,t[1001];
    while(1){
        ave=0;
        a=0;
        scanf("%d", &n);
        if(n == 0)
        break;
    
        for(i=0;i<n;i++){
            scanf("%lf", &t[i]);
            ave+=t[i];
        }
        ave=ave/n;
        for(i=0;i<n;i++){
            a+=((t[i]-ave)*(t[i]-ave));
        }
        a=a/n;
        printf("%.111f\n",sqrt(a));
    }
    return 0;
    
}




Measured memory_bytes: 2048
#include<iostream>
using namespace std;
int main() {
  int a,b,ans=0;
  cin >> a >> b;
  for(int i=0;i<2;i++){
    if(a>=b){
      ans += a;
      a--;
    }else{
      ans += b;
      b--;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256