akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}



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




Measured memory_bytes: 256
import sys
 
def LI():
  return [int(s) for s in input().split()]
 
N,M = LI()

check = {}
 
for i in range(M):
  s,c = LI()
  if N >= 2 and s == 1 and c == 0:
    print(-1)
    sys.exit()
  
  if s in check.keys():
    if check[s] != c:
      print(-1)
      sys.exit()
      
  check[s] = c

answer = ['0']*N
if len(answer) > 1:
	answer[0] = '1'

for s,c in check.items():
  answer[s-1] = str(c)

print(int(''.join(answer)))

Measured memory_bytes: 3064
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = str(input())
janken = {"r":"p","s":"r","p":"s"}
point = {"r":P,"s":R,"p":S}
kekka = []
ans = 0

for i in range(K):
    kekka.append(janken[T[i]]) 
    ans += point[T[i]]

for i in range(K,N):
    if janken[T[i]] == kekka[i-K] and kekka[i-K] != T[i-K]: # kekka[i-K]を負けてもアイコでもOKなら次向けに融通聞かせる手がある！
        kekka.append(T[i])
    else:
        kekka.append(janken[T[i]])
        ans += point[T[i]]

print(ans)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, auto& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

struct QU {
  V<> par, rank, _size;

  QU(int n) { 
    par.resize(n);
    iota(par.begin(), par.end(), 0);
    rank.resize(n);
    _size.assign(n, 1);
  }

  int find(int a) {
    if (par[a] == a) return a;
    return par[a] = find(par[a]);
  }

  bool same(int a, int b) { return find(a) == find(b); }

  int size(int a) { return _size[find(a)]; }

  void unite(int a, int b) {
    a = find(a), b = find(b);
    if (a == b) return;
    if (rank[a] < rank[b]) {
      par[a] = b;
      _size[b] += _size[a];
    } else {
      par[b] = a;
      _size[a] += _size[b];
    }
    if (rank[a] == rank[b]) rank[a]++;
  }
};

template<class T> struct edge { int id, from, to; T w; };

template<class T> T kruskal(V< edge<T> >& g, int n, V<bool>& used) {
  T res = 0;
  QU qu(n);
  sort(g.begin(), g.end(), [](auto a, auto b) { return a.w < b.w; });
  for (auto&& e : g) {
    if (!qu.same(e.from, e.to)) {
      qu.unite(e.from, e.to);
      res += e.w;
      used[e.id] = true;
    }
  }
  return res;
}

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V< edge<lint> > es(m);
  for (int i = 0; i < m; i++) {
    int a, b, c; cin >> a >> b >> c, a--, b--;
    es[i] = {i, a, b, c};
  }
  V<bool> used(m);
  lint sm = kruskal<lint>(es, n, used);
  struct edge2 { int to; lint w; };
  VV<edge2> g(n);
  for (int i = 0; i < m; i++) if (used[es[i].id]) {
    g[es[i].from].push_back({es[i].to, es[i].w});
    g[es[i].to].push_back({es[i].from, es[i].w});
  }
  VV<lint> res; assign(res, n, n, -1e18);
  for (int i = 0; i < n; i++) {
    queue<int> q;
    V<bool> vis(n);
    vis[i] = true; q.push(i);
    while (!q.empty()) {
      int v = q.front(); q.pop();
      for (auto&& e : g[v]) if (!vis[e.to]) {
        vis[e.to] = true;
        res[i][e.to] = max(res[i][v], e.w);
        q.push(e.to);
      }
    }
  }
  int q; cin >> q;
  for (int iq = 0; iq < q; iq++) {
    int s, t; cin >> s >> t, s--, t--;
    cout << sm - res[s][t] << '\n';
  }
}

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

typedef long long int ll;

int main(){
	ll n;
	
	scanf("%lld",&n);
	
	ll current = 26;
	ll last = 0;
	ll currentp = 1;
	ll currentsum = 26;
	
	while(n > currentsum){
		last = currentsum;
		current = current * 26;
		currentsum = currentsum + current;
		currentp++;
	}
	ll len = currentp;
	current /= 26;
	
	string res;
	n -= last;
	n--;
	while(len){
		ll last1 = n%26;
		res = (char)(last1+'a') + res;
		n /= 26;
		len--;
	}
	cout << res << endl;
	
}


Measured memory_bytes: 3684
n, k = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]

time = 0
answer = float("inf")

for i in range(n - k + 1):
  x_min = x[i]
  x_max = x[k + i - 1]
  
  if x_min * x_max < 0:  
    time = x_max - x_min + min(x_max, -x_min)
  else:
    time = max(abs(x_max), abs(x_min))
  answer = min(answer, time)
#  print(time)
  
print(answer)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,e,x,i,j,n,t,m,k,y;
    double p,q,r,w,u ;
    string str = "",str1 = "" ;
    ll a1,a2,b1,b2 ;
    cin>>a>>b>>c ;
    if(c*a<=b)
    {
    	cout<<c ;
	}
	else
	{
		cout<<b/a ;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}



template< typename T >
vector< T > slide_min(const vector< T > &v, int k)
{
  deque< int > deq;
  vector< T > ret;
  for(int i = 0; i < v.size(); i++) {
    while(!deq.empty() && v[deq.back()] >= v[i]) {
      deq.pop_back();
    }
    deq.push_back(i);
    if(i - k + 1 >= 0) {
      ret.emplace_back(v[deq.front()]);
      if(deq.front() == i - k + 1) deq.pop_front();
    }
  }
  return ret;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int n,l;
  cin>>n>>l;
  vi a(n);
  rep(i,n){
    cin>>a[i];
  }

  vi v=slide_min(a,l);
  rep(i,n-l+1){
    if(i) cout<<' ';
    cout<<v[i];
  }
  cout<<endl;


}


Measured memory_bytes: 19104
const main = input => {
  const [s, t]=input.trim().split("\n").map(e=>[...e])
  const l=s.length
  let r=0
  for(let i = 0; i < l; i++)if(s[i]!==t[i])r++
  return r
}

console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')))

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int N, W; cin >> N >> W;
    vector<int64_t> best(W + 1, 0);

    for (int i = 0; i < N; ++i) {
        int weight, value; cin >> weight >> value;

        for (int j = W - weight; j >= 0; --j)
            best[j + weight] = max(best[j + weight], best[j] + value);
    }

    cout << best[W] << "\n";
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int ans = 0;
void collatz(int n){
  ans++ ;
  if(n == 4 || n == 1 || n ==2 ){
    cout << ans+3;
    return;
  }
  if(n % 2 == 0)
    collatz( n/2);
  
  else
    collatz(3*n+1);
  
}
    
   
  

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


Measured memory_bytes: 256
// editorial
// 思いつける気がしない
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

vector<int> v[2];
vector<int> g[200000];

void dfs(int x, int p, int k){
    v[k].push_back(x);
    for(int next : g[x]){
        if(next == p)   continue;
        dfs(next, x, 1-k);
    }
}

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0, -1, 0);
    if(v[0].size() > v[1].size())   swap(v[0], v[1]);
    vector<int> ans(n, 0);
    queue<int> q[3];
    for(int i = 1; i <= n; i++) q[i%3].push(i);
    if(v[0].size() >= q[1].size()){
        for(int x : v[0]){
            if(q[1].empty())    ans[x] = q[0].front(), q[0].pop();
            else                ans[x] = q[1].front(), q[1].pop();
        }
        for(int x : v[1]){
            if(q[2].empty())    ans[x] = q[0].front(), q[0].pop();
            else                ans[x] = q[2].front(), q[2].pop();
        }
    }else{
        for(int x : v[0])   ans[x] = q[0].front(), q[0].pop();
        for(int x : v[1]){
            for(int i = 0; i < 3; i++){
                if(q[i].empty())    continue;
                ans[x] = q[i].front();  q[i].pop();
                break;
            }
        }
    }
    for(int i = 0; i < n; i++)  cout << ans[i] << " \n"[i==n-1];
    return 0;
}

Measured memory_bytes: 22004
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
exits = False

for i in range(n-m+1):
    for j in range(n-m+1):
        p = []
        for k in range(m):
            p.append(a[i:i+m][k][j:j+m])
        if p == b:
            exits = True

print('Yes' if exits else 'No')


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

const int N = 600;
typedef long long ll;

int n, m;
char st[N + 5][N + 5];
bool vis[N + 5][N + 5];
int cnt[2][N + 5][N + 5];

int calc(int ty, int x, int l, int r) {
    if(x < 0 || x > n + m) return 0;

    return cnt[ty][x][min(r, n+m)] - cnt[ty][x][max(l-1, 0)];
}

int main() {

    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; ++i) {
        scanf("%s", st[i] + 1);
        for(int j = 1; j <= m; ++j) if(st[i][j] == '#') {
            vis[i + j][i - j + m + 1] = true;
        }
    }

    for(int i = 1; i <= n + m; ++i) {
        for(int j = 1; j <= n + m; ++j) {
            cnt[0][i][j] = cnt[0][i][j - 1] + vis[i][j];
            cnt[1][i][j] = cnt[1][i][j - 1] + vis[j][i];
        }
    }

    ll ans = 0;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) {
            for(int k = 1; k <= n; ++k) {

                if(i > k && j > k && st[i-k][j] == '#' && st[i][j-k] == '#') {
                    ans += calc(0, i + j + k, i - j - k + m + 1, i + k - j + m + 1);
                }
                if(i > k && j <= m-k && st[i-k][j] == '#' && st[i][j+k] == '#') {
                    ans += calc(1, i + k - j + m + 1, i - k + j, i + j + k);
                }
                if(i <= n-k && j > k && st[i+k][j] == '#' && st[i][j-k] == '#') {
                    ans += calc(1, i - k - j + m + 1, i - k + j, i + j + k);
                }
                if(i <= n-k && j <= m-k && st[i+k][j] == '#' && st[i][j+k] == '#') {
                    ans += calc(0, i - k + j, i - j - k + m + 1, i + k - j + m + 1);
                }

                bool x = (i > k && st[i-k][j] == '#');
                bool y = (j > k && st[i][j-k] == '#');
                bool z = (i <= n-k && st[i+k][j] == '#');
                bool w = (j <= m-k && st[i][j+k] == '#');

                int c = x + y + z + w;

                if(c == 3) ans --;
                if(c == 4) ans -= 4;
            }
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 3584
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Integer[] rodInfo = new Integer[n];
		for(int i =0;i < n;i++) {
			rodInfo[i] = sc.nextInt();
		}
		Arrays.sort(rodInfo,Collections.reverseOrder());

		int longRod = 0;
		int shortRod = 0;
		for(int i =1;i < n;i++) {
			if(rodInfo[i].equals(rodInfo[i-1])) {
				if(longRod ==0) {
					longRod = rodInfo[i];
				}else {
					shortRod = rodInfo[i];
				}
				i++;
			}
			if(longRod != 0 && shortRod !=0) {
				break;
			}
		}
		System.out.println((long)longRod * (long)shortRod);
	}
}

Measured memory_bytes: 66032
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

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

	if(a < b) swap(a, b);
	if(a < c) swap(a, c);

	cout << (b*c) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <memory>
#include <algorithm>
#include <cstring>

#define ll long long
using namespace std;

const int MOD = 1e9+7;
int l, c, a, b;
ll f[200004];

ll powmod(ll base, ll exponent)
{
    if (exponent < 0)
        exponent += MOD - 1;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%MOD;
        base=(base*base)%MOD;
        exponent/=2;
    }
    return ans;
}

void compute_fact(ll x) {
    f[0] = 1;
    f[1] = 1;
    for (ll i = 2; i <= x; ++i)
        f[i] = (f[i - 1] * i) % MOD;
}

ll compute(int x, int y) {
    ll tmp = (f[x + y] * powmod(f[x], -1)) % MOD;
    return (tmp * powmod(f[y], -1)) % MOD;
}

int main() {
    cin >> l >> c >> a >> b;
    ll ans = 0;

    int dm = l - a - 1;
    compute_fact(l + c);
    for (int col = b + 1; col <= c; col++) {
//        cout << "col = " << col << " " << " we add 1st " << compute(dm, col - 1) <<" second "<<  compute(a - 1, max(0, c - col)) << endl;
        ans = (ans + (compute(dm, col - 1) * compute(a - 1, max(0, c - col))) % MOD) % MOD;
    }

    cout << ans;
    return 0;
}


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

#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

ll a,b,c,k;
int main() {
	read(a);read(b);read(c);read(k);
	if(k%2){
		cout<<b-a<<endl;
	}else{
		cout<<a-b<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = readline().strip()

    ans = 0
    dp = [[0] * (N + 1) for _ in range(N + 1)]
    for i in range(N - 1, -1, -1):
        for j in range(N - 1, i - 1, -1):
            if S[i] == S[j]:
                dp[i][j] = dp[i + 1][j + 1] + 1
            if ans < min(j - i, dp[i][j]):
                ans = min(j - i, dp[i][j])

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 270144
S = input()

if 1<=int(S[0:2])<=12:
    if 1<=int(S[2:4])<=12:
        print("AMBIGUOUS")
    else:
        print('MMYY')
else:
    if 1<=int(S[2:4])<=12:
        print('YYMM')
    else:
        print('NA')


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#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)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main(void){
    double A,B; cin >> A >> B;
    for(double i=1; i<10000; i++){
        if(floor(i*0.08) == A && floor(i*0.1) == B){
            cout << (int)i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

int main() {
  
  int n;
  long long T;
  cin >> n >> T;
  
  vector<long long> t(n);
  for ( int i = 0; i < n; i++){
    cin >> t[i];
  }
  
  long long goukei = 0;
  
  for ( int i = 0; i < n-1; i++){
    if ( t[i+1] - t[i] >= T ){
      goukei += T;
    }else{
      goukei += t[i+1] - t[i];
    }
  }
  
  goukei += T;
  
  cout << goukei << endl;  
  
}

Measured memory_bytes: 4732
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>

using namespace std;

typedef long long ll;

void solve() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({ a * c, b * c, a * d, b * d });
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		//cout << endl;
	}
}

Measured memory_bytes: 3684
#include<cstdio>
int main(){
	int n;
	while(~scanf("%d",&n))
	{
		int jin=0;
		int ti[100050]={0};
		int xi[100050]={0};
		int yi[100050]={0};
		int i;
		for(i=1;i<=n;i++)
		{
			scanf("%d%d%d",&ti[i],&xi[i],&yi[i]);
			int sum=xi[i]+yi[i]-xi[i-1]-yi[i-1];
			if(jin!=0)continue;
			if(sum<0){
				sum=-sum;
			}
			if(ti[i]>=sum){
				int l1=(ti[i]-ti[i-1])%2;
				int l2=sum%2;
				if(l1!=l2){
					jin=5;
				}
			}else {
				jin=5;
			}
		}
		if(jin){
			printf("No\n");
		}else {
			printf("Yes\n");
		}
		
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
const ll INF = 1e18;

VV<> dp(301, V<>(301, INF));
ll res = INF;

int main(){
    INT(n, k); 
    VEC(int, h, n); h.pb(0);
    dp[0][n] = 0;
    REP(i, n) REP(j, i + 1) REP(k, n + 1) if(i != k)
    chmin(dp[j + 1][i], dp[j][k] + max(h[i] - h[k], 0));
    REP(j, n + 1) chmin(res, dp[n - k][j]);
    print(res);
}

Measured memory_bytes: 4300
MOD = int(1e9) + 7

def f(n):
    ans = 1

    for i in range(2, n + 1):
        ans = (ans * i) % MOD

    return ans

n, m = map(int, input().split())

if abs(n - m) > 1:
    print(0)

    exit()

ans = (f(n) * f(m)) % MOD

if n == m:
    ans = (ans * 2) % MOD

print(ans)


Measured memory_bytes: 62868
#include"bits/stdc++.h"
using namespace std;
int f[10001][101][2];
int d,n;
char a[10001];
int main()
{
	cin>>a;
	cin>>d;
	n=strlen(a);
	f[0][0][1]=1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<d;j++)
		{
			for(int k=0;k<=9;k++)
				f[i+1][(j+k)%d][0]=((long long)f[i+1][(j+k)%d][0]+f[i][j][0])%1000000007;
			for(int k=0;k<=a[i]-'0';k++)
			{
				if(k==(a[i]-'0'))
					f[i+1][(j+k)%d][1]=((long long)f[i+1][(j+k)%d][1]+f[i][j][1])%1000000007;
				else
					f[i+1][(j+k)%d][0]=((long long)f[i+1][(j+k)%d][0]+f[i][j][1])%1000000007;
			}
		}
	}
	printf("%d",(int)((((long long)f[n][0][0]+f[n][0][1])-1+1000000007)%1000000007));
}

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

int main() {
	long long n, B[2*100000], b, ans = 0;

	cin >> n;

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

	sort(B, B + n);

	b = B[n / 2];

	for (int i = 0; i < n; ++i) 
		ans += abs(B[i] - b);

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)


int main() {
	string S;
  	cin>>S;
  	int count=0;
  	int max=0;
  	rep(i,3){
      	if(S[i]=='S'){
			count=0;
	    }
     	if(S[i]=='R'){
         	count++;
        }
      	if(max<count){
			max=count;
        }
    }
  
  	cout<<max<<endl;
}

Measured memory_bytes: 3620
string = input()
q = int(input())
for _ in range(q):
    command = input().split()
    a, b = int(command[1]), int(command[2])
    if command[0] == "replace":
        string = string[:a] + command[3] + string[b+1:]
    elif command[0] == "reverse":
        string = string[:a] + string[a:b+1][::-1] + string[b+1:]
    elif command[0] == "print":
        print(string[a:b+1])


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

d=[]
for i in range(1,n):
  if n%i==0:
    d.append(i)
    if i*i!=n:
      d.append(n//i)
  if i*i>=n:
    break

ans=0
for i in d:
  a=i-1
  if a>0:
    if n//a==n%a:
      ans+=a

print(ans)

Measured memory_bytes: 3264
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {
	public static void main(String[] args) throws Exception {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String str = br.readLine();

		int x = Integer.parseInt(SubStringStart(str));
		int y = Integer.parseInt(SubStringEnd(str));
		BigDecimal k = new BigDecimal(SubStringStart(str));
		BigDecimal l = new BigDecimal(SubStringEnd(str));

		int d, r;
		String f;

		d = x / y;
		r = x % y;
		f=k.divide(l,8,BigDecimal.ROUND_HALF_UP).toPlainString();

		System.out.println(d + " " + r + " " + f);
	}

	//?¬¬????????°???????????????????????????
	public static String SubStringStart(String str) {
		int index = str.indexOf(" ");
		return (str.substring(0, index));
	}

	//	?¬¬????????°???????????????????????????
	public static String SubStringEnd(String str) {
		int index = str.lastIndexOf(" ");
		return (str.substring(index + 1));
	}
}

Measured memory_bytes: 24524
import sys
input = sys.stdin.readline
from itertools import accumulate
MOD = 10**9+7

def main():
  n, k = map(int, input().split())
  S = set()
  i = 1
  while i * i <= n:
    S.add(i)
    S.add(n//i)
    i += 1
  L = [0] + sorted(S)
  l = len(L) - 1
  num = [0]*l
  for i in range(l):
    num[i] = L[i+1] - L[i]
  dp = [0]*l
  dp[0] = 1
  for _ in range(k):
    A = list(accumulate(dp))
    for i in range(l):
      dp[i] = A[l-1-i] * num[i]
      dp[i] %= MOD
  ans = sum(dp) % MOD
  print(ans)

if __name__ == "__main__":
  main()

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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    ll n, y;
    cin >> n>> y;
    ll ansi = -1, ansj = -1, ansk = -1;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j+i <= n; j++){
            if(i*10000 + j*5000 + (n-i-j)*1000 == y){
                ansi = i;
                ansj = j;
                ansk = n-i-j;
                break;
            }
        }
    }
    cout << ansi <<' '<< ansj <<' '<< ansk << '\n';
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int f(int n) {
  if(n % 2) return 3 * n + 1;
  else return n / 2;
}

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

  int n; cin >> n;
  double ans = 0;
  for(int i=0;i<n;++i) {
    double x; cin >> x;
    string s; cin >> s;
    if(s == "BTC") {
      x *= 380000;
    }
    ans += x;
  }
  cout << ans << endl;
}


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

int main(){
  int N;
  cin >> N;
  
  int ans = 0;
  for(int i = 1; i <= N; i++){
    if(i >= 1 && i <=9) ans++;
    if(i >= 100 && i <= 999) ans++;
    if(i >= 10000 && i <= 99999) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import math

A, B = map(int, input().split())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

A_prime = set(prime_factorize(A))
B_prime = set(prime_factorize(B))

res = A_prime & B_prime

print(len(res)+1)

Measured memory_bytes: 63024
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const pairint& firstElof, const pairint& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
string s;
std::vector<int> v;
std::cin >> x>>s;
if(x>=3200)std::cout << s << '\n';
else std::cout << "red" << '\n';
}



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

int main(){
	int x, y;
	std::cin >> x >> y;
	int z = 0;
	z += std::max(4-x, 0);
	z += std::max(4-y, 0);
	if(x==1 and y==1) z+=4;
	std::cout << z*100000 <<std::endl;
	return 0;
}


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

int main(){
  int n,i;
  char s[10000];
  scanf("%d",&n);
  scanf("%s",s);
  for(i=0;i<strlen(s);i++){
    if(s[i]+n <= 90)printf("%c",s[i]+n);
    else printf("%c",s[i]+n-26);
  }
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>


int H[251];

int main(){
  int n,i;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&H[i]);
  }

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,H[i]);

    if( !(i / 2 == 0) ){
      printf("parent key = %d, ",H[i/2]);
    }
    if( !(2*i > n) ){
      printf("left key = %d, ",H[2*i]);
    }
    if( !(2*i+1 > n) ){
      printf("right key = %d, ",H[2*i+1]);
    }
    printf("\n");
  }
  return 0;
}



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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node *nodepointer;
nodepointer set;

void insert(int);
void delete(int);
nodepointer nodesearch(int);
void deleteFirst(void);
void deleteLast(void);
void nodedelete(nodepointer);
void initialize(void);
void nodeprint(void);
int main(){

  int count; //命令回数
  char command[20];//命令
  int number;//数字
  int i=0;//ループカウンタ
  int j=1;
  nodepointer setup;

  
  
  scanf("%d",&count);
  initialize();
  while(i < count){
    scanf("%s%d",command,&number);
    i++;
    //命令の識別
    if(command[0]=='i') insert(number);
    else if(command[0]=='d'){
      if(strlen(command) > 6){
	if(command[6]=='F') deleteFirst();
	else if(command[6]=='L') deleteLast();
      }	
      else delete(number);
    }
  }
  nodeprint();
  return 0;
}

void nodeprint(){
  nodepointer setup = set->next;
  int count=1;
  while(1){
    if(setup==set)break;
    if(count==0)printf(" ");
    printf("%d",setup->key);
    setup = setup->next;
    count = 0;
  }
  printf("\n");
}
void initialize(){
  set = malloc(sizeof(struct node));
  set->next = set;
  set->prev = set;
}

void insert(int num){//格納
  nodepointer setup;
  setup = malloc(sizeof(struct node));
  setup->key = num;
  //setとnextの間にsetupを入れる
  setup->next = set->next;
  set->next->prev = setup;
  set->next = setup;
  setup->prev = set;
}
void delete(int num){
  nodepointer setup;
  setup = nodesearch(num);//検索

  if(setup != NULL){//nodeの中に発見
    nodedelete(setup);
    }
}

nodepointer nodesearch(int num){
  nodepointer setup = set->next;
  //検索
  while(setup != set && num != setup->key){
    setup = setup->next;
  }
  if(setup == set) return NULL;
  return setup;
}

void deleteFirst(){
  nodepointer setup = set->next;
  if(setup == set) return;
  nodedelete(setup);
}

void deleteLast(){
  nodepointer setup = set->prev;
  if(setup == set) return;
  nodedelete(setup);
}

void nodedelete(nodepointer setup){
  setup->next->prev = setup->prev;//間を削除
  setup->prev->next = setup->next;
  free(setup);
}

Measured memory_bytes: 31788
#include<bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int>b(n-1);
    for(int i=0; i<n-1; ++i)
        cin>>b[i];
    int sum = b[0] + b[n-2];
    for(int i=0; i<n-2; ++i) {
        sum += min(b[i], b[i+1]);
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,LL>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define SE second
#define PI acos(-1.00)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define edl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v,w,zz;
map<LL,LL>ww,u,st;
V<LL>uuu[500005];
V<pair<LL,LL> >uu;
map<pair<LL,LL>,LL> vo,vu,uh,ve;
set<LL>uo;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    char ch;
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
//    cin>>tt;
    while(tt--)
    {
      cin>>n>>m>>p>>q>>o;
      k=p-n;
      k*=60;
      k-=m;
      k+=q;
      k-=o;
      cout<<max((LL)0,k)<<endl;
    }
    return 0;
}


Measured memory_bytes: 15336
N, L = (int(a) for a in input().split())
if N + L -1 < 0:
    x = N + L -1
elif L < 0 and N + L -1 >= 0:
    x = 0
else:
    x = L
sum = 0
for i in range(1,N+1):
    if x == L + i - 1:
        continue
    sum += L + i - 1
print(sum)

Measured memory_bytes: 3060
<?php
list($n, $m) = array_map("intval", explode(" ", trim(fgets(STDIN))));
$di = new Di($n);
for($i = 0; $i < $m; $i++){
  list($from, $to, $d) = array_map("intval", explode(" ", trim(fgets(STDIN))));
  $di->connect($from, $to, $d);
}
for($i = 2; $i <= $n; $i++){
  $di->connect($i, $i - 1, 0);
}
$di->solve(1);
$distance = $di->distance[$n];
if($distance == $di->inf){
  echo -1;
}else{
  echo $distance;
}

/**
 * Dijkstra
 * Attention: 1-origin
 **/
class Di{
  public $pq;
  public $distance;
  public $graph;
  public $from;
  public $inf = 10**18;
  function __construct($n) {
    $this->pq = new SplPriorityQueue();
    for($i = 1; $i <= $n; $i++){
      $this->distance[$i] = $this->inf;
      $this->from[$i] = 0;
    }
  }
  function connect($from, $to, $cost){
    $this->graph[$from][] = [$to, $cost];
  }
  function solve($from){
    $this->pq->insert($from, 0);
    $this->distance[$from] = 0;
    while($this->pq->count()){
      $f = $this->pq->extract();
      if(!isset($this->graph[$f]))continue;
      foreach($this->graph[$f] as list($t, $dist)){
        $new = $this->distance[$f] + $dist;
        if($this->distance[$t] > $new){
          $this->distance[$t] = $new;
          $this->from[$t] = $f;
          $this->pq->insert($t, -$new);
        }
      }
    }
  }
}

Measured memory_bytes: 142708
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	ll n, k;
	cin >> n >> k;
	vector<ll> vs(n);
	ll tot = 0;
	for(auto &x:vs) 
		cin >> x, tot+=x;
	vector<ll> divs;
	for(ll i=1; i*i<=tot; ++i){
		if(tot%i==0){
			divs.push_back(i);
			if(tot/i != i) divs.push_back(tot/i);
		}
	}
	sort(all(divs));
	ll ans = 1;
	for(auto d:divs){
		ll res = 0;
		vector<int> vx(n);
		for(int i=0; i<n; ++i)
		       if(vs[i]%d)
			       vx.push_back(vs[i]%d);
		sort(all(vx));
		while(not vx.empty()){
			int x = (d-vx.back())%d; vx.pop_back();
			res += x;
			for(auto &y:vx){
				if(x==0) break;
				if(x>y)
					x-=y, y=0;
				else
					y-=x, x = 0;
			}
		}
		// todo
		if(res<=k) 
			ans = d;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <math.h>
#include<algorithm>
using namespace std;
#define MAX 25

struct node{
  int key;
  node *p,*l,*r;
};

node *NIL,*root;

void insert(node * z){
  node * y=NIL;
  node * x=root;
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->l;
    }else{
      x=x->r;
    }
  }
  z->p=y;

  if(y==NIL){
    root=z;
  }else if(z->key < y->key){
    y->l=z;
  }else{
    y->r=z;
  }
}

void Preorder(node * x){
  if(x==NIL) return;
  cout<<" "<<x->key;
  Preorder(x->l);
  Preorder(x->r);
}

void Inorder(node * x){
  if(x==NIL) return;
  Inorder(x->l);
  cout<<" "<<x->key;
  Inorder(x->r);
}

int find(int k){
  node *x=root;
  while(x!=NIL && k!=x->key){
    if(x->key < k){
      x=x->r;
    }else{
      x=x->l;
    }
  }
  return x!=NIL;
}


int main(){
  int n,x;
  cin>>n;
  string s;
  for(int i=0;i<n;i++){
    cin>>s;
    if(s=="insert"){
      cin>>x;
      node * a=(node *)malloc(sizeof(node));
      a->key=x;
      a->l=a->r=NIL;
      insert(a);
    }else if(s=="print"){
      Inorder(root);
      cout<<endl;
      Preorder(root);
      cout<<endl;
    }else{
      cin>>x;
      if(find(x)) cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 21972
import numpy as np

n,c = map(int,input().split())

li = np.zeros(10**5+1,int)
ch = [[] for _ in range(10**5+1)]
lin = []

for _ in range(n):
    s,t,c = map(int,input().split())
    lin.append((s,t,c))

lin.sort()

for i,j,k in lin:
    if k in ch[i-1]:
        li[i:j] += 1
        ch[j-1].append(k)
    else:
        li[i-1:j] += 1
        ch[j-1].append(k)

print(np.max(li))

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

int main(void)
{
  int c = 0;
  const char *cf = "CODEFESTIVAL2016";
  char wr[20] = "";
  cin >> wr;
  for ( int i=0; cf[i]!='\0'; i++ ) {
    if ( cf[i] != wr[i] ) { c++; }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
import scala.io.Source.stdin

object Main extends App {
  val b = new StringBuilder

  for(d<-stdin.getLines.map(_.toInt)) {
    var i = 0
    var s = 0
    while(i*d < 600) {
      s += i*i
      i += 1
    }
    b.append(s*d*d*d+"\n")
  }
  print(b.result)
}

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

int main(){
    int R,G,B,N;

    cin >> R >> G >> B >> N;

    int ans = 0;

    for(int i = 0; i*R <= N; i++ ){
        //RによりNの総数が減らされた状態でスタート
        for(int j = 0; j*B <= N-R*i; j++){
            if( (N-R*i - B*j)%G == 0 ){
                ans++;
            }
        }
    }
    cout << ans << endl;

    // G*k = N-R*i - B*j
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

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

int main(){    
  long long A,B,C,D;
  cin >> A >> B >> C >> D;

  int AOKI = C;
  int TAKA = A;

  
  while(1){
    AOKI = AOKI - B;
    if(AOKI<=0){
      cout << "Yes" << endl;
      return 0;
    }
    TAKA = TAKA - D;
    if(TAKA<=0){
      cout << "No" << endl;
      return 0;
    }
  }
}
 


Measured memory_bytes: 3620
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  vector<ll> vab;
  vector<ll> vb;
  rep(i, 0, s.sz) {
    if (s[i] == 'c') {
      cout << "No" << endl;
    }
    else if (s[i] == 'a') {
      if (vab.sz < a + b) {
        cout << "Yes" << endl;
        vab.pb(1);
      }
      else{
        cout << "No" << endl;
      }
    }
    else if (s[i] == 'b') {
      if (vab.sz < a + b && vb.sz<b) {
        cout << "Yes" << endl;
        vab.pb(1);
        vb.pb(1);
      }
      else{
        cout << "No" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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 namespace std;

// 連長圧縮（ランレングス圧縮）：sの連長部分を{文字,個数}の配列で返す
vector<pair<char, long long>> rle(string s){
    vector<pair<char, long long>> ret;
    long long i = 0, n = s.size();
    while(i<n){
        char tmp = s[i];
        long long cnt = 1;
        while(i<n){
            i++;
            if(tmp == s[i]) cnt++;
            else break;
        }
        ret.push_back(make_pair(tmp, cnt));
    }
    return ret;
}

int main(){
    Init();
    string s; cin >> s;   
    auto p = rle(s);
    cout << p.size()-1 << endl;
}

Measured memory_bytes: 2628
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 1e5+5;
const ll mod = 2019;
ll L, R, ans = mod;

int main(int argc, char ** argv) {
	cin >> L >> R;
	for(ll i = L; i <= R; i++) {
		for(ll j = i+1; j <= R; j++) {
			ans = min(ans, (i*j)%mod);
			if(!ans) puts("0"), exit(0);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i;
  int c = 0;
  
  cin >> N;
  vector<int> a(N);
  for(i=0;i<N;i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  for(i = 0; i < N; i++){
	if(i%2==0)c += a.at(i);
    else c -= a.at(i);
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

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

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
int main() {
	int h, w, l[2001][2001], r[2001][2001], u[2001][2001], d[2001][2001], ans = 0,i,j,count;
	cin >> h >> w;
	char s[2001][2001];
	for (i = 0; i < h; i++)
		cin >> s[i];
	for (i = 0; i < h; i++) {
		count = 0;
		for (j = 0; j < w; j++) {
			if (s[i][j] == '.') {
				l[i][j] = count;
				count++;
			}
			else
				count = 0;
		}
	}
	for (i = 0; i < h; i++) {
		count = 0;
		for (j = w-1; j >=0; j--) {
			if (s[i][j] == '.') {
				r[i][j] = count;
				count++;
			}
			else
				count = 0;
		}
	}
	for (j = 0; j < w; j++) {
		count = 0;
		for (i = 0; i < h; i++) {
			if (s[i][j] == '.') {
				u[i][j] = count;
				count++;
			}
			else
				count = 0;
		}
	}
	for (j = 0; j < w; j++) {
		count = 0;
		for (i = h-1; i >=0; i--) {
			if (s[i][j] == '.') {
				d[i][j] = count;
				count++;
			}
			else
				count = 0;
		}
	}
	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			if (s[i][j] == '.')
				ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j]+1);
	cout << ans << endl;
}

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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  char a = toupper(s1.at(0));
  char b = toupper(s2.at(0));
  char c = toupper(s3.at(0));

  cout << a << b << c << endl;
}

Measured memory_bytes: 256
"""
(x+y+z)^2 = (x^2+y^2+z^2) + 2(xy+yz+zx)
"""
def func(x, y, z): return (x + y + z) ** 2 - x * y - y * z - z * x


def main():
    num = int(input())
    counter = [0] * 20000
    # func(41, 41, 41) = 10086
    # func(99, 1, 1) = 10002
    for x in range(1, 100):
        for y in range(1, 100):
            for z in range(1, 123 - x - y + 1):
                tmp = func(x, y, z)
                counter[tmp] += 1
    for key, count in enumerate(counter):
        if key == 0:
            continue
        if key > num:
            break
        print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
#include<iostream>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  int A[N], sum=0, count=0;
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    sum += a;
    A[i] = a;
  }
  for(int i=0; i<N; i++){
    if(A[i]>=sum*((double)1/(4*M))) count++;
  }
  cout << (count>=M?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 256