akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;
int main (){
    int N;
    cin >> N;
    int a[N];
    int max,maxidx,second,secondidx;
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    max=0;
    maxidx=0;
    for (int i = 0; i < N; i++){
        if(a[i]>max){
            second=max;
            secondidx=maxidx;
            max=a[i];
            maxidx=i;
        }
        else if(a[i]>second){
            second=a[i];
            secondidx=i;
        }
    }
    for (int i = 0; i < N; i++){
        if(i==maxidx) cout << second << "\n";
        else cout << max << "\n";
    }
}

Measured memory_bytes: 2432
#include<stdio.h>
#include<string.h>
int main(void)
{
	int box[26],flg,len,i;
	char s[100001];
	scanf("%s",s);
	flg=0;
	for(i=0;i<26;i++){
		box[i]=0;
	}
	len=strlen(s);
	for(i=0;i<len;i++){
	    box[s[i]-'a']++;
	}
	for(i=0;i<26;i++){
		if(box[i]==0){
			printf("%c\n",i+'a');
			flg=1;
			break;
		}
	}
	if(flg==0){
		printf("None\n");
	}
	return 0;
}	

Measured memory_bytes: 256
A, B, K = map(int, input().split(' '))
if A < K:
    K = K - A
    A = 0
else:
    A = A - K
    K = 0
if B < K:
    K = K - B
    B = 0
else:
    B = B - K
    K = 0
print(A, B)


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

int main()
{
	int N, K;
	int D[9];
	string str;

	cin >> N >> K;

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

	bool flag = true;

	for (int i = N; ; i++) {
		str = to_string(i);
		flag = true;
		for (int j = 0; j < K; j++) {
			if (str.find(to_string(D[j])) != -1) {
				flag = false;
				break;
			}
		}
		if (flag) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const int MAX_N = 1e5 + 10;

ll dp[2 * MAX_N];

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    fill_n(dp, 2 * MAX_N, mod * mod);
    dp[0] = 0;
    int n, w;
    cin >> n >> w;
    for(int i = 0; i < n; i ++) {
        ll a, b;
        cin >> a >> b;
        for(int j = MAX_N; j >= 0; j --) {
            chkmin(dp[j + b], dp[j] + a);
        }
    }
    int ans = 0;
    for(int i = 0; i < MAX_N; i ++) {
        if(dp[i] <= w) {
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}



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

int main() {
    ll N, M;
    cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> s(M);
    rep(i, M) {
        cin >> k[i];
        rep(j, k[i]) {
            int tmp;
            cin >> tmp;
            --tmp;
            s[i].push_back(tmp);
        }
    }
    vector<int> p(M);
    rep(i, M) cin >> p[i];

    int ans = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {
        bool ok = true;
        rep(i, M) {
            int cnt = 0;
            rep(j, k[i]) {
                if (bit & (1 << s[i][j])) {
                    ++cnt;
                }
            }
            if (cnt % 2 != p[i]) {
                ok = false;
                break;
            }
        }
        if (ok) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=998244353;
int f[405][405][2];
int sz[405],a[405];
void add(int &x,int y){
	x=(x+y)%mod;
}
void dec(int &x,int y){
	x=(x-y+mod)%mod;
}
int ksm(int b,int n){
	int res=1;
	while(n){
		if(n&1) res=res*b%mod;
		b=b*b%mod; n>>=1;
	}
	return res;
}
int solve(int l,int r,int lst){
	if(l>r) return f[0][0][1]=1,0;
	int u=min_element(a+l,a+r+1)-a;
	int ls=solve(l,u-1,a[u]),rs=solve(u+1,r,a[u]);
	for(int i=0;i<=sz[ls];++i)
		for(int j=0;j<=sz[rs];++j){
			int A=f[ls][i][1]*f[rs][j][1]%mod,
				B=f[ls][i][0]*f[rs][j][0]%mod+f[ls][i][1]*f[rs][j][0]%mod+f[ls][i][0]*f[rs][j][1]%mod;
			B%=mod;
			add(f[u][i+j][1],A);
			add(f[u][i+j][0],B);
			dec(f[u][i+j+1][1],A);
			add(f[u][i+j+1][0],A);
		}
	sz[u]=sz[ls]+sz[rs]+1;
	for(int i=0;i<=sz[u];++i)
		f[u][i][0]=f[u][i][0]*ksm(ksm(2,sz[u]-i)-1,a[u]-lst)%mod,
		f[u][i][1]=f[u][i][1]*ksm(ksm(2,sz[u]-i),a[u]-lst)%mod;
	return u;
}
signed main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	int u=solve(1,n,0);
	int ans=0;
	for(int i=0;i<=sz[u];++i)
		add(ans,f[u][i][0]),
		add(ans,f[u][i][1]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6020
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        int N = in.nextInt();
        int count = 0;
        for (int i = 0; i < N; i++) {
            count += in.nextInt() % 2;
        }
        String ans = "YES";
        if (count % 2 == 1) {
            ans = "NO";
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 30312
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
int main(){
    int n; cin >> n;
    cout << (1000-(n%1000))%1000 << '\n';
    return 0;
}

Measured memory_bytes: 3652
/*  HARD WORK FOREVER PAYS  */
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define turbo(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
typedef pair<int,int> PII; 
int main() 
{ 
	turbo();
	string s,s1;
	cin>>s>>s1;
	for(int i=0;i<s.size()&&i<s1.size();i++){
		cout<<s[i]<<s1[i];
	}
	if(s.size()!=s1.size()){
		cout<<s[s.size()-1]<<"\n";
	}
	return 0; 
} 

Measured memory_bytes: 3596
#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 llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
       int a,b,c,d;
       cin>>a>>b>>c>>d;
       int lower = max(a,c);
       int upper = min(b,d);
cout<<max(0,upper-lower)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n;
  cin >> n;
  map<ll, ll> mii;
  rep (i, n) {
    int x;
    cin >> x;
    mii[x]++;
  }

  map<ll, ll> clone = mii;
  rep (i, n) {
    int dis;
    dis = abs(2 * i - (n - 1));
    if (clone[dis] == 0) {
      cout << 0 << endl;
      return 0;
    }
    clone[dis]--;
  }

  ll ans = 1;
  for (auto v : mii) {
    ans *= v.second;
    ans %= MOD;
  }

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


Measured memory_bytes: 11464
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
#include <limits.h>
#include <queue>
#include <unordered_map>
#include <sstream>      // std::ostringstream

#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;

std::vector<std::string> split(const std::string &str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}


// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}

void DebugPrint(const vector<ll>& vec) {
	cout << "{";
	for (auto itr = vec.begin(); itr != vec.end(); ++itr) {
		cout << *itr << ",";
	}
	cout << "}" << endl;
}

// valueが2のx乗以下である計算
ll calc2x(ll value) {
	ll n = 0;
	while (value > 0) {
		value /= 2;
		++n;
	}
	return n;
}



struct Vec2 {
	double x;
	double y;

	void rotate(double rad) {
		double s = sin(rad);
		double c = cos(rad);
		double tmpX = this->x*c - this->y*s;
		double tmpY = this->x*s + this->y*c;
		this->x = tmpX;
		this->y = tmpY;
	}
};

int main(void) {


	ll n;
	cin >> n;

	vector<ll> mins, maxs;
	for (int i = 0; i < n; ++i) {
		ll a, b;
		cin >> a >> b;
		mins.push_back(a);
		maxs.push_back(b);
	}
	sort(mins.begin(), mins.end());
	sort(maxs.begin(), maxs.end());

	ll ansCount = 0;
	if ((n % 2) == 1) {
		ll index = n / 2;
		ansCount = maxs[index] - mins[index] + 1;
	}
	else {
		ll index1 = n / 2;
		ll index2 = index1-1;
		ll minCenter = mins[index1] + mins[index2];
		ll maxCenter = maxs[index1] + maxs[index2];
		ansCount = maxCenter - minCenter + 1;
	}

	cout << ansCount << endl;

	return 0;
}


Measured memory_bytes: 6628
#include <stdio.h>
#define MN 100000

int n,m,ans,fa[MN+5];

int gf(int u){
	return fa[u]==u?u:fa[u]=gf(fa[u]);
}

void unite(int u,int v){
	u = gf(u);
	v = gf(v);
	if(u==v) return;
	ans--;
	fa[v] = u; 
}

int main(){
	scanf("%d%d",&n,&m);
	ans = n-1;
	for(int i=1;i<=n;i++)
		fa[i] = i;
	for(int i=1,u,v;i<=m;i++){	
		scanf("%d%d",&u,&v);
		unite(u,v);
	}
	printf("%d\n",ans);
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    REP(i, n) {
        cin >> h[n - 1 - i];
    }
    int p = h[0];
    FOR(i, 1, n) {
        if (p < h[i]) {
            if (p + 1 == h[i]) {
                p = h[i] - 1;
            } else {
                cout << "No" << endl;
                return 0;
            }
        } else {
            p = h[i];
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

constexpr auto inf = 1e9;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	set<ll> num;
	for (auto& x : a)
	{
		ll tmp;
		cin >> tmp;
		x = tmp;
		num.insert(tmp);
	}

	ll ans = 0;

	sort(a.begin(), a.end());
	list<pair<ll, ll>> counter;

	for (auto x : num)
	{
		auto left = lower_bound(all(a), x);
		auto right = upper_bound(all(a), x);
		ll count = distance(left, right);
		counter.push_back(make_pair(x, count));
	}

	for (auto& x : counter)
	{
		x.first <= x.second ? ans += x.second - x.first : ans += x.second;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9984
K, N = input().split()
K = int(K)
N = int(N)
houses = list(map(int, input().split()))
first = True
distance = 0
for i in range(N):
  firstHouse = houses[i]
  lastHouse = houses[i - 1]
  if lastHouse > firstHouse:
    distance = lastHouse - firstHouse
  else:
    distance = (K - firstHouse) + lastHouse
  if first or distance < minDistance:
    minDistance = distance
    first = False
print(minDistance)

Measured memory_bytes: 26060
#include <stdio.h>
#include <algorithm>
int n;
double a[50];
double ans;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf", a + i);
	}
	std::sort(a, a + n);
	ans = a[0];
	for (int i = 1; i < n; i++) {
		ans = (ans + a[i]) / 2;
	}
	printf("%lf\n", ans);
}

Measured memory_bytes: 128
#include <iostream>
 using namespace std;
 
 int p[11],c[11];
 int d,g;
 int mn = 1000000000;
 
 int dfs(int i, int nocompmx, int nwpoint, int quant){
   if(d+1 == i){
     if(nwpoint >= g){
       mn = min(mn, quant);
     }else if(p[nocompmx]*nocompmx+nwpoint >= g){
       int tmp = ((g-nwpoint)%nocompmx == 0 ? (g-nwpoint)/nocompmx : (g-nwpoint)/nocompmx+1);
       mn = min(mn, quant+tmp);
     }
     return mn;
   }
   int toku =    dfs(i+1, nocompmx, nwpoint + p[i]*i+c[i], quant + p[i]);
   int tokanai = dfs(i+1, i ,       nwpoint              , quant);
   return min(mn, min(toku, tokanai));
 }
 int main(){
   cin >> d >> g;
   g = g / 100;
   for(int i = 1; d >= i; i++){
     cin >> p[i] >> c[i];
     c[i] = c[i] / 100;
   }
   cout << dfs(1,0,0,0) << endl;
 }

Measured memory_bytes: 256
package main

import (
	"bufio"
	"errors"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var scanner = bufio.NewScanner(os.Stdin)
	var n, q = getNAndQ(scanner)
	var queue = Queue{0, 0, make([]Process, n+1)}
	var totalTime int = 0
	for i := 0; i < n; i++ {
		var name, time = getNameAndTime(scanner)
		var p = Process{name, time}
		_ = queue.enqueue(p)
	}
	for !queue.isEmpty() {
		var p, _ = queue.dequeue()
		if p.time <= q {
			totalTime += p.time
			fmt.Println(p.name, totalTime)
		} else {
			p.time = p.time - q
			totalTime += q
			_ = queue.enqueue(p)
		}
	}
}

func getNameAndTime(scanner *bufio.Scanner) (name string, time int) {
	scanner.Scan()
	var line = scanner.Text()
	var nameTime = strings.Split(line, " ")
	name = nameTime[0]
	time, _ = strconv.Atoi(nameTime[1])
	return name, time
}

func (queue *Queue) isFull() bool {
	return queue.head == ((queue.tail + 1) % len(queue.contents))
}

func (queue *Queue) enqueue(p Process) (err error) {
	if queue.isFull() {
		return errors.New("queue is full")
	}
	queue.contents[queue.tail] = p
	queue.tail = (queue.tail + 1) % len(queue.contents)
	return nil
}

func (queue *Queue) isEmpty() bool {
	return queue.tail == queue.head
}

func (queue *Queue) dequeue() (p Process, err error) {
	if queue.isEmpty() {
		return p, errors.New("can't dequeue case empty")
	}
	p = queue.contents[queue.head]
	queue.head = (queue.head + 1) % len(queue.contents)
	return p, nil
}

func getNAndQ(scanner *bufio.Scanner) (n, q int) {
	scanner.Scan()
	var line = scanner.Text()
	var qn = strings.Split(line, " ")
	n, _ = strconv.Atoi(qn[0])
	q, _ = strconv.Atoi(qn[1])
	return n, q
}

type Queue struct {
	head     int
	tail     int
	contents []Process
}

type Process struct {
	name string
	time int
}



Measured memory_bytes: 5272
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	_ = intScanner()
	s := Scanner()
	d := make(map[rune]int)
	for _, i := range s {
		d[i]++
	}
	ans := 1
	for _, v := range d {
		ans *= v + 1
		ans %= mod
	}
	ans -= 1
	if ans < 0 {
		ans += mod
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1024
from itertools import accumulate as ac
o=[]
f=lambda l,r,v:lambda x:v if l<=x<=r else v+(l-x) if 0<=x<=l else v+(x-r)

o.extend([f(0,0,0)])
n=int(input())
*a,=map(int,input().split())
*b,=map(int,input().split())
*c,=ac([0]+a)

for (i,(t,v)) in enumerate(zip(a,b)):
  o.extend([f(c[i],c[i+1],v)])
o.extend([f(c[-1],c[-1],0)])
v=lambda s:min(map(lambda x:x(0.5*s),o))

S=0
for i in range(2*c[-1]):
  S+=0.25*(v(i)+v(i+1))
print(S)


Measured memory_bytes: 45916
#include<stdio.h>

int main(void){
    int i;
    int N,T;
    scanf("%d%d",&N,&T);
    int c[N],t[N];
    for(i = 0;i < N;i++){
        scanf("%d%d",&c[i],&t[i]);
    }

    int tmin = 1001, ans;
    int cmin = 9999;
    for(i = 0;i < N;i++){
        if(c[i] < cmin && t[i] <= T){
            cmin = c[i];
        }
    }

    if(cmin < 9999){
        printf("%d",cmin);
    }else{
        printf("TLE");
    }
    return 0;
}

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

pro_won = list()

for i in range(1, N+1):
    u = i
    z = 0
    cnt = 0
    if K <= u:
        z = 1/N
        pro_won.append(z)
    else:
        while u < K:
            u = 2*u
            cnt +=1
        z = (0.5**cnt)/N
        pro_won.append(z)
print(sum(pro_won))


Measured memory_bytes: 6296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    vector<ll> left(n), right(n);
    left[0] = a[0];
    right[n-1] = a[n-1];
    rep(i, 1, n) {
        left[i] = max(left[i-1], a[i]);
        right[n-1-i] = max(right[n-i], a[n-1-i]);
    }
    rep(i, 0, n) {
        if (i-1 < 0) cout << right[1] << endl;
        else if (i+1 > n-1) cout << left[n-2] << endl;
        else cout << max(left[i-1], right[i+1]) << endl;
    }
}

Measured memory_bytes: 6272
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<algorithm>
#include<unordered_map>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>*/
//#include<ext/rope>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
#define maxn 1005
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
const double PI=acos(-1.0);
const double eps=1e-6;
int a[maxn],sta[maxn],dp[maxn][5000];
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
template<typename T> void debug(T x)
{
    cout<<"value="<<x<<endl;
    return;
}
signed main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n=read(),m=read();
    for(int i=1;i<=m;i++){
        a[i]=read();
        int b=read();
        for(int j=1;j<=b;j++){
            int c=read();
            c=1<<(c-1);
            sta[i]|=c;
        }
    }
    for(int i=0;i<=m;i++) for(int j=1;j<(1<<n);j++) dp[i][j]=100000001;
    for(int i=1;i<=m;i++){
        for(int j=0;j<(1<<n);j++){
            dp[i][j|sta[i]]=min(dp[i][j|sta[i]],dp[i-1][j]+a[i]);
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
        }
    }
    if(dp[m][(1<<n)-1]==100000001) printf("-1\n");
    else printf("%d\n",dp[m][(1<<n)-1]);
	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

void solve(long long N, long long A, long long B) {
  cout << min(A * N, B) << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(N, A, B);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"#%d (%s) = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif

const int iinf = 1e9+10;
const ll inf = 1ll<<60;
const ll mod = 1e9+7 ;


void GG(){cout<<"0\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b,mo) % mo;
}

const int maxn = 1e6+5;



signed main(){
    IOS();
    int x; cin>>x;
    cout<<360/__gcd(x,360)<<endl;


}


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

int main(){
    int ans = 0;
    int n, d, x; cin >> n >> d >> x;
    vector<int> a(n); rep(i,n) cin >> a.at(i);

    for(int i = 0; i < n; i++){
        for(int j = 1; j <= d;j += a.at(i)){ ans++;}
    }
    ans += x;

    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from heapq import heappop,heappush
def resolve():
    n,m=map(int,input().split())
    V=[[] for _ in range(m)]
    for _ in range(n):
        a,b=map(int,input().split())
        if(a>m): continue
        heappush(V[a-1],-b)


    ans=0
    Q=[]
    for d in range(m):
        if(V[d]):
            heappush(Q,(heappop(V[d]),d))
        if(Q):
            b,a=heappop(Q)
            ans+=-b
            if(V[a]):
                heappush(Q,(heappop(V[a]),a))

    print(ans)
resolve()

Measured memory_bytes: 96944
n=int(input())
a=list(map(int,input().split()))
rcnt=c=0
color=[0]*8
for i in range(n):
  if 1<=a[i]<=399:
    color[0]=1
  elif 400<=a[i]<=799:
    color[1]=1
  elif 800<=a[i]<=1199:
    color[2]=1
  elif 1200<=a[i]<=1599:
    color[3]=1
  elif 1600<=a[i]<=1999:
    color[4]=1
  elif 2000<=a[i]<=2399:
    color[5]=1
  elif 2400<=a[i]<=2799:
    color[6]=1
  elif 2800<=a[i]<=3199:
    color[7]=1
  else:
    rcnt+=1
    c=1
if sum(color)==0:
  print(1,rcnt)
else:
  print(sum(color),sum(color)+rcnt)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;


namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            List<int> nums = new List<int>();

            for(int i=1; i<10; i++)
            {
                for(int j = 1; j < 10; j++){
                    nums.Add(i * j);
                }
            }
            if(nums.IndexOf(num) == -1)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }    
    }
}

Measured memory_bytes: 13152
import itertools
import math
import fractions
import functools
import copy
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

sum = 0
for i in range(n):
    if v[i] > c[i]:
        sum += v[i] - c[i]
print(sum)

Measured memory_bytes: 65388
n, q = map(int, input().split())

ct = [0] * (n + 1)
e = [[] for _ in range(n + 1)]

for _ in range(n - 1):
    a, b = map(int, input().split())
    e[a].append(b)

qs = [0] * (n + 1)
for _ in range(q):
    p, q = map(int, input().split())
    qs[p] += q

target = [1]
while len(target):
    t = target.pop()
    ct[t] += qs[t]
    for nt in e[t]:
        target.append(nt)
        ct[nt] += ct[t]

print(*ct[1:])

Measured memory_bytes: 53908
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	// fmt.Println(n, sc.Text())
	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = nextInt()
	}
	var cnt int
	var ans int
	for i := 0; i < n-1; i++ {
		if h[i] >= h[i+1] {
			cnt++
			ans = max(cnt, ans)
		} else {
			cnt = 0
		}
	}
	fmt.Println(ans)
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}


Measured memory_bytes: 3072
H, W = map(int, input().split())

A_map = []
for i in range(H):
    A_str = input()
    A_map.append(A_str)

MOD = 10**9 + 7

dp = [[0] * W for _ in range(H)]
dp[0][0] = 1
dire = [[1,0], [0,1]] #下　右

for i in range(H):
    for j in range(W):
        if A_map[i][j] == '#':
            continue
        for k in dire:
            if 0 <= i+k[0] <= H-1 and  0 <= j+k[1] <= W-1:
                if A_map[i+k[0]][j+k[1]] == '.':
                    dp[i+k[0]][j+k[1]] +=  dp[i][j]%MOD
                    dp[i+k[0]][j+k[1]] %= MOD
#print(dp)
print(dp[H-1][W-1]%MOD)

Measured memory_bytes: 77676
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int f(int n,int d){
  return n/d;
}

int main(){
  int n; cin >>n;
  int f=1,cnt=0;
  rep(i,n){
    int a; cin >>a;
    if(f and (a%2)){
      cnt++;
    }
    f^=1;
  }
  print(cnt);
}


Measured memory_bytes: 3632
import Data.List
main=do
 [a,b]<-map read.words<$>getLine
 let x=gcd a b
 print$(1+)$length$nub$f 2 x
f p x
 |x==1=[]
 |p*p>x=[x]
 |x`mod`p==0=p:f p(div x p)
 |otherwise=f(p+1)x

Measured memory_bytes: 892
n=int(input())
L=list(map(int,input().split()))
L.sort()
tmp=0
cnt=0
min_c=0
max_c=0

for i in range(n):
	if L[i] <= 399:
		cnt+=1
		tmp=i
		break

for i in range(tmp,n):
	if L[i] >= 400 and L[i] <= 799:
		cnt+=1
		tmp=i
		break

for i in range(tmp,n):
	if L[i] >= 800 and L[i] <= 1199:
		cnt+=1
		tmp=i
		break
		
for i in range(tmp,n):
	if L[i] >= 1200 and L[i] <= 1599:
		cnt+=1
		tmp=i
		break
		
for i in range(tmp,n):
	if L[i] >= 1600 and L[i] <= 1999:
		cnt+=1
		tmp=i
		break

for i in range(tmp,n):
	if L[i] >= 2000 and L[i] <= 2399:
		cnt+=1
		tmp=i
		break
		
for i in range(tmp,n):
	if L[i] >= 2400 and L[i] <= 2799:
		cnt+=1
		tmp=i
		break

for i in range(tmp,n):
	if L[i] >= 2800 and L[i] <= 3199:
		cnt+=1
		tmp=i
		break
		
min_c=cnt
max_c=cnt

for i in range(tmp,n):
	if L[i] >= 3200:
		max_c=cnt+len(L[i:])
		if min_c==0:
			min_c+=1
		break
		
print(min_c,max_c)



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

long g1(long n, int p) {
  if (n == 0) return 0;
  return n / p + g1(n / p, p);
}

long g2(long n, int p) {
  if (n % 2 == 1) {
    return g1(n, p) - g2(n - 1, p);
  }
  long res = g1(n / 2, p);
  if (p == 2) res += n / 2;
  return res;
}

int main() {
  long N;
  cin >> N;
  if (N & 1) return cout << 0 << "\n", 0;
  cout << g2(N, 5) << "\n";
}

Measured memory_bytes: 256
fun main() {
    var (a, b, c) = readInts()
    val k = readInt()

    var used = 0
    while (b <= a) {
        b *= 2
        used++
    }
    while (c <= b) {
        c *= 2
        used++
    }
    println(if (used <= k) "Yes" else "No")
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 36468
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int n; cin >> n;
    rep(i, 11){
        if (n <= i * 1000){
            cout << 1000 * i - n << endl;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 3592
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll x;
    cin >> x;
    cout << (10 - (x / 200)) << endl;
    return 0;
}


Measured memory_bytes: 3192
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = INT_MAX;
const long long MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------

ll K, N;
ll A[201010];
ll cntneg;

int main() {
  cin >> N >> K;
  rep(i, 0, N) {
    cin >> A[i];
    if (A[i] < 0) ++cntneg;
  }

  if (N == K) {
    ll ans = 1;
    rep(i, 0, N) {
      ans *= A[i];
      ans += MOD * MOD;
      ans %= MOD;
    }
    cout << ans;
    return 0;
  }

  if (K % 2 == 1 && cntneg == N) {
    sort(A, A + N, greater<ll>());
    ll ans = 1;
    rep(i, 0, K) {
      ans *= A[i];
      ans += MOD * MOD;
      ans %= MOD;
    }
    cout << ans;
    return 0;
  }

  sort(A, A + N, [](ll a, ll b) { return abs(a) > abs(b); });
  vector<ll> pos, neg;
  rep(i, 0, N) {
    ll a = A[i];
    if (a < 0) {
      neg.push_back(a);
    } else {
      pos.push_back(a);
    }
  }

  ll poscnt = 0, negcnt = 0;
  ll possize = pos.size(), negsize = neg.size();
  ll ans = 1;
  while (K > 1) {
    if (poscnt + 1 >= possize) {
      ans *= neg[negcnt];
      ans += MOD * MOD;
      ans %= MOD;
      ++negcnt;
      --K;

      ans *= neg[negcnt];
      ans += MOD * MOD;
      ans %= MOD;
      ++negcnt;
      --K;
    } else if (negcnt + 1 >= negsize) {
      ans *= pos[poscnt];
      ans += MOD * MOD;
      ans %= MOD;
      ++poscnt;
      --K;
    } else {
      if (pos[poscnt] * pos[poscnt + 1] >= neg[negcnt] * neg[negcnt + 1]) {
        ans *= pos[poscnt];
        ans += MOD * MOD;
        ans %= MOD;
        ++poscnt;
        --K;
      } else {
        ans *= neg[negcnt];
        ans += MOD * MOD;
        ans %= MOD;
        ++negcnt;
        --K;

        ans *= neg[negcnt];
        ans += MOD * MOD;
        ans %= MOD;
        ++negcnt;
        --K;
      }
    }
  }

  if (K == 1) {
    ans *= pos[poscnt];
    ans += MOD * MOD;
    ans %= MOD;
  }

  cout << ans;
}


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

using namespace std;

int main() {
   int d;
   cin >> d;
   if(d==25)
   cout << "Christmas" << endl;
   else if (d==24)
   cout << "Christmas Eve" << endl;
   else if(d==23)
   cout << "Christmas Eve Eve" << endl;
   else 
   cout << "Christmas Eve Eve Eve" << endl; 
}

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

using namespace std;
using ll = long long;

int main()
{

    ll n, m, q;
    ll l, r;

    cin >> n >> m >> q;
    vector<vector<ll>> table_pre(n, vector<ll>(n, 0));
    vector<vector<ll>> table(n, vector<ll>(n, 0));
    vector<ll> ql(q);
    vector<ll> qr(q);

    for (int i = 0; i < m; i++)
    {
        cin >> l >> r;
        table[l - 1][r - 1]++;
    }

    for (int i = 0; i < q; i++)
    {
        cin >> ql[i] >> qr[i];
    }

    ll tmp = 0;

    for (int il = 0; il < n; il++)
    {
        tmp = 0;
        for (int ir = 0; ir < n; ir++)
        {
            tmp += table[il][ir];
            table[il][ir] = tmp;
        }
    }

    for (int ir = 0; ir < n; ir++)
    {
        tmp = 0;
        for (int il = n - 1; il >= 0; il--)
        {
            tmp += table[il][ir];
            table[il][ir] = tmp;
        }
    }

    for (int i = 0; i < q; i++)
    {

        cout << table[ql[i] - 1][qr[i] - 1] << endl;
    }

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  bool dp[30010][4][1000] = {};
  dp[0][0][0] = 1;
  rep(i,n){
    rep(j,4){
      rep(k,1000){
        if(dp[i][j][k]){
          dp[i+1][j][k] = 1;
          dp[i+1][j+1][10*k+s[i]-'0'] = (j < 3);
        }
      }
    }
  }
  int ans = 0;
  rep(i,1000) if(dp[n][3][i]) ans ++;
  cout << ans << endl;
}


Measured memory_bytes: 120892
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ctoi(x) x-'0'
#define pshb(a) cin >> x;a.push_back(x)
#define fr(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);
using namespace std;
int main()
{
    vector<ll>a ;
    ll n , k , cnt =0 ;
    cin>>n>>k ;
    for (int i =0 ; i< n ; i++)
    {
        ll x ; cin>>x ;
        a.push_back(x) ;
    }
    sort(a.begin(),a.end()) ;
    for (int i =0 ; i<n-k; i++)
        cnt+=a[i] ;
    cout<<cnt ;
}




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

using namespace std;
#define int int64_t
#define rep(i,a,n) for(int i=(a); i<(n); ++i)
#define reps(i,a,n) for(int i=(a); i<(n); --i)
#define all(x) (x).begin(),(x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed(n) fixed << setprecision(n)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

signed main()
{
	cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n,cnt=0,ans=0;
    cin>>n;

    rep(i,1,n+1){
        rep(j,1,n+1){
            rep(k,1,n+1){
                ans = __gcd(i,j);
                ans = __gcd(ans,k);
                cnt += ans;
            }
        }
    }

    cout<<cnt<<'\n';
    return 0;
}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    string s;
    cin >> s;
    string ans = "";
    ans += s[0] + to_string(s.size()-2) +s.back();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

def calcOperation(base):
  sum = 0
  ans = 0
  sign = base
  for i in range(n):
    sum += a[i]
    if sum * sign >= 0:
      ans += abs(sum) + 1
      sum = -sign
    sign *= -1
  return ans

posi = calcOperation(1)
nega = calcOperation(-1)
print(min(posi, nega))

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

int main(){

    int N;

    cin >> N;

    for(int i=0;i<N;i++){
      int x,y,b,p,tmp,maxans;
      cin >> x >> y >> b >> p;
      if(b>=5&&p>=2){
        x *= 0.8;
        y *= 0.8;
        maxans = x*b + y*p;
      }
      else if(b>=5&&p<2){
        tmp = x*b + y*p;
        x *= 0.8;
        y *= 0.8;
        maxans = min((x*b + y*2),tmp);
      }
      else if(b<5&&p>=2){
        tmp = x*b + y*p;
        x *= 0.8;
        y *= 0.8;
        maxans = min((x*5 + y*p),tmp);
      }
      else{
        tmp = x*b + y*p;
        x *= 0.8;
        y *= 0.8;
        maxans = min((x*5 + y*2),tmp);
      }
      cout << maxans << endl;;
    }


    return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <vector>
using namespace std;
int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    int N, W;
    cin >> N >> W;
    vector<int> ws(N), vs(N);
    for (int i = 0; i < N; ++i) {
        cin >> ws[i] >> vs[i];
    }
    vector<int64_t> dp(W + 1, 0);
    vector<int64_t> dp2(W + 1, 0);
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < W + 1; ++j) {
            dp2[j] = max(dp[j], j >= ws[i] ? dp[j - ws[i]] + vs[i] : 0);
        }
        swap(dp, dp2);
    }
    cout << dp[W] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    while(cin >> n >> m, n){
        vector<char> v(n+2);
        for (int _ = 0; _ < m; ++_) {
            char c;
            cin >> c;
            if(c == 'A'){
                for (int j = 1; j <= n; ++j) {
                    if(!v[j]){
                        v[j] = c;
                        break;
                    }
                }
            }else if(c == 'B'){
                int ok = 0;
                for (int j = n; j >= 1; --j) {
                    if(!v[j] && v[j-1] != 'A' && v[j+1] != 'A'){
                        v[j] = c;
                        ok = 1;
                        break;
                    }
                }
                if(!ok){
                    for (int j = 1; j <= n; ++j) {
                        if(!v[j]){
                            v[j] = c;
                            break;
                        }
                    }
                }
            }else if(c == 'C'){
                int ok = 0;
                for (int j = 1; j <= n; ++j) {
                    if(!v[j]) continue;;
                    if(j != n && !v[j+1]){
                        v[j+1] = c;
                        ok = 1;
                        break;
                    }
                    if(j != 1 && !v[j-1]){
                        v[j-1] = c;
                        ok = 1;
                        break;
                    }
                }
                if(!ok){
                    v[(n+2)/2] = c;
                }
            }else if(c == 'D'){
                int cur = 1, dist = 0;
                for (int j = 1; j <= n; ++j) {
                    if(v[j]) continue;
                    int d = INF<int>;
                    for (int k = 1; k <= n; ++k) {
                        if(v[k]){
                            d = min(d, abs(j-k));
                        }
                    }
                    if(d > dist){
                        dist = d;
                        cur = j;
                    }
                }
                v[cur] = c;
            }
        }
        for (int i = 1; i <= n; ++i) {
            if(v[i]) cout << v[i];
            else cout << "#";
        }
        puts("");
    }
    return 0;
}


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


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

  int n;
  cin >> n;
  int ans = 0;
  rep(i,n){
    int a; cin >> a;
    if(i%2==1) continue;
    else{
      if(a%2==1) ans++;
    }
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n],b[n],c[n],i,j;
  int dp[n][3]={0};
  for(i=0;i<n;i++)
  {
  	cin>>a[i]>>b[i]>>c[i];
  }
  for(i=0;i<n;i++)
  {
  	for(j=0;j<3;j++)
  	{
  		if(i==0)
  		{
  			if(j==0)dp[i][j]=a[i];
  			if(j==1)dp[i][j]=b[i];
  			if(j==2)dp[i][j]=c[i];
  		}
  		else
  		{
  			for(int k=0;k<3;k++)
  			{
  				if(j!=k)
  				{
  					if(j==0)dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i]);
  		           	if(j==1)dp[i][j]=max(dp[i][j],dp[i-1][k]+b[i]);
  			        if(j==2)dp[i][j]=max(dp[i][j],dp[i-1][k]+c[i]);
  				}
  			}
  		}
  	}
  }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n, k, ans = 0;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    rep(i, n)
    {
        if (k <= h[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
lis=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(lis[k-1])

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

#define fo(i,s,t) for(int i =s; i<=t;++i)
const int maxn = 51;

long long f[maxn*100];
int n,a[maxn],p;
long long ans;

int main()
{
	scanf("%d%d",&n,&p);
	fo(i,1,n) scanf("%d",&a[i]);
	f[0] = 1;
	fo(i,1,n) for(int j = 5000; j>=a[i]; -- j) f[j] += f[j-a[i]];
	fo(i,0,5000) if(i%2==p) ans+=f[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 764
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
#include<iomanip>
#include <list>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(a, b) make_pair(a, b)
#define mt(a,b,c) make_tuple(a,b,c)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
#define pb push_back
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int mod = (int)1e9 + 7;
const int mod1 = (int)1e9 + 9;
const int mod2 = 998244353;
const int mod3 = (int)1e6+3;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
ll max(ll a,ll b){
    return (a<b)? b:a;
}
ll min(ll a,ll b){
    return (a>b)? b:a;
}

vector<int> q;
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);<<" "
    //ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    int a[n];
    int i;
    int p[n];
    rep(i,0,n){
        cin>>a[i];
        p[a[i]-1]=i;
    }
    if(n==1){
        cout<<0;
        return 0;
    }
    int ans=200007;
    int nao=0;
    for(i=0;i<n-1;i++){
        nao=0;
        while(i<n-1&&p[i]<p[i+1]){
            nao++;
            i++;
        }
        nao++;
        if(ans>n-nao){
            ans=n-nao;
        }
    }
    cout<<ans;
    return 0;
             
    
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main()
{
	int r,g,b;

	cin >> r >> g >> b;

	if( (g*10 + b)%4==0 )
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define PII pair<int,int>
#define fi first
#define se second
using namespace std;

const int NMAX=205;

int n,a[NMAX];
int sol;

int main()
{
    int i;
  //  freopen("date.in","r",stdin);
  //  freopen("date.out","w",stdout);
    cin.sync_with_stdio(false);
    cin>>n;n<<=1;
    for (i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for (i=n-1;i>=1;i-=2) sol+=a[i];
    cout<<sol<<"\n";
    return 0;
}



Measured memory_bytes: 256