akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

bool cmp(const pair<pll, ll> &a, const  pair<pll, ll> &b) {
	return a.first.first + a.first.second < b.first.first + b.first.second;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<pair<pll,ll>> v(n);
	REP(i, n)cin >> v[i].first.first >> v[i].first.second >> v[i].second;
	sort(ALL(v),cmp);
	ll m = 0;
	{
		ll tmp = 0;
		REP(i, n)tmp = max(tmp, v[i].first.first);
		m += tmp;
		tmp = 0;
		REP(i, n)tmp = max(tmp, v[i].first.second);
		m += tmp;
	}
	
	vl dp(m + 1, -INF*INF);
	dp[0] = 0;
	REP(i, n) {
		RREP(j, min(m + 1-v[i].first.first,v[i].first.second+1)) {
			dp[j + v[i].first.first] = max(dp[j + v[i].first.first], dp[j] + v[i].second);
		}
	}
	cout << *max_element(ALL(dp)) << endl;
}

Measured memory_bytes: 512
<?php
list($n) = ints();
for ($i = 0; $i < $n; ++$i) list($s[]) = strs();
// A, B が良い盤面 A+1, B+1 ~ A+N-1, B+N-1 も良い盤面
$ans = 0;
for ($i = 0; $i < $n; ++$i) if (check(0, $i)) $ans += $n;
echo $ans;
function check($a, $b)
{
    global $n, $s;
    for ($i = 1; $i < $n; ++$i) {
        for ($j = 0; $j < $i; ++$j) {
            if ($s[($i + $a) % $n][($j + $b) % $n] !== $s[($j + $a) % $n][($i + $b) % $n]) return false;
        }
    }
    return true;
}
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc =  new Scanner(System.in);
		int N =sc.nextInt();
		int M =sc.nextInt();
		
		int X = 0;
	 X = (int) ((int)(1900*M+100*(N-M))*Math.pow(2, M));
		
		
		System.out.println(X);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

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

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

  int count, res = 0;
  for (int i = 1; i <= n; i += 2) {
    count = 1;
    for (int j = 1; j <= i / 2; j += 2) {
      if (i % j == 0) ++count;
    }
    if (count == 8) ++res;
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    long long int a,b,k;

    scanf("%lld",&a);
    scanf("%lld",&b);
    scanf("%lld",&k);

    if(a + b - k <= 0)
    {
        a = 0;
        b = 0;
    }
    else
    {
        if(a > k)
        {
            a -= k;
        }
        else
        {
            k -= a;
            a -= a;
            b -= k;

            if(0 > b)
            {
                b = 0;
            }
        }
    }
    
    
    printf("%lld %lld",a,b);

    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <map>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x[50];
  int y[50];
  for(int i = 0; i < n; ++i)
    cin >> x[i] >> y[i];
  
  map<pair<int, int>, int> d;
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < n; ++j) {
      if(i != j) d[make_pair(x[i] - x[j], y[i] - y[j])] += 1;
      }
  }
  
  int cost = 0;
  for(auto i : d) {
    cost = cost < i.second ? i.second : cost;
  }
  
  cout << n - cost << '\n';
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	int A,B,C;
	cin>>A>>B>>C;
	cout<<A+B+C-max({A,B,C})<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        int W = Integer.parseInt(sc.next());
        int[] value = new int[N+1];
        int[] weight = new int[N+1];
        for(int i = 1; i <= N; i++){
            value[i] = Integer.parseInt(sc.next());
            weight[i] = Integer.parseInt(sc.next());
        }
        
        int[][] dp = new int[N+1][W+1];
        for(int i = 1; i <= N; i++){
            for(int w = 1; w <= W; w++){
                if(weight[i] <= w){
                    dp[i][w] = Math.max(dp[i-1][w - weight[i]] + value[i], dp[i-1][w]);
                }else{
                    dp[i][w] = dp[i-1][w];
                }
            }
        }
        
        System.out.println(dp[N][W]);
    }
}


Measured memory_bytes: 30872
#include<iostream>
using namespace std;
int main(){
int x[101]={};
int i,n;
cin >> n;
for(i=0;i<n;i++){
    cin >> x[i];
}
for(i=n-1;i>=0;i=i-1){
    if(i==n-1) cout << x[i];
    else cout << " "<< x[i];
}
cout << endl;
return 0;
}


Measured memory_bytes: 3084
while gets
  xa, ya, xb, yb, xc, yc, xd, yd = $_.split(',').map(&:to_f)
  vx1 = xb-xa
  vy1 = yb-ya
  vx2 = xc-xa
  vy2 = yc-ya
  vx3 = xd-xa
  vy3 = yd-ya
  t = (vx2*vy3 - vy2*vx3) / (vx1*vy3 - vy1*vx3)
  s = (vx2*vy1 - vy2*vx1) / (vx3*vy1 - vy3*vx1)
  if t > 0 && s > 0 && t+s > 1
    puts"YES"
  else
    puts"NO"
  end
end

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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void milkshake() {
  string s;
  cin >> s;
  if(s[s.size()-1] == 's') {
    cout << s << "es" << '\n';
    return;
  }
  cout << s << 's' << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) milkshake();

  return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

using pii = pair<ll,ll>;

int main(void){
	ll len[2];
	rep(i,2) cin >> len[i];

	vector<pii> ary(len[0]+len[1]);

	rep(i,len[0]){
		cin >> ary[i].first;
		ary[i].second=0;
	}

	rep(i,len[0],len[0]+len[1]){
		cin >> ary[i].first;
		ary[i].second=1;
	}

	sort(_all(ary));

	ll ans=0LL;
	ll used[2]={0LL,0LL};

	rep(i,len[0]+len[1]){
		ll cur=ary[i].first,type=ary[i].second;
		ans+=cur*(len[type^1]+1-used[type^1]);
		used[type]++;
	}

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

Measured memory_bytes: 3328
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;
use std::io;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    let stdin = io::stdin();
    let mut line = String::new();
    stdin.read_line(&mut line).ok();
    let txt: Vec<_> = line.trim().split(' ').collect();
    let n: usize = txt[0].parse().unwrap();
    let m: usize = txt[1].parse().unwrap();

    let mut v = vec![];
    for i in 0..n {
        let stdin = io::stdin();
        let mut line = String::new();
        stdin.read_line(&mut line).ok();
        let txt: Vec<_> = line.trim().split(' ').collect();
        let k: usize = txt[0].parse().unwrap();
        for j in 1..k + 1 {
            let a: u64 = txt[j].parse().unwrap();
            v.push(a);
        }
    }

    let mut dict = HashMap::new();
    for na in v.iter() {
        *(dict.entry(na).or_insert(0)) += 1;
    }

    println!(
        "{}",
        dict.iter().filter(|&(_, va)| va == &(n as u64)).count()
    )
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

static const ull MOD = 1000000007LL;

int main(void){
    char s[100005];
    uint64_t dp[100005][13];
    int ans = 0;
    scanf("%s", s);
    int n = strlen(s);
    dp[0][0] = 1;
    for(int i=0;i<n;i++){
        int c;
        if (s[i] == '?') c = -1;
        else c = s[i] - '0';

        for (int j = 0; j < 10; j++) {
            if (c != -1 && c != j) continue;
            for (int ki = 0; ki < 13; ki++) {
                dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki];
            }
        }
        for (int j = 0; j < 13; j++) dp[i + 1][j] %= MOD;
    }
    ans = dp[n][5];
    printf("%d\n",ans);
    return 0;

}

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

int main()
{
  int r, c;
  cin >> r >> c;
  int table[101][101] = {};
  for(int i = 0; i < r; i++){
    for(int j = 0; j < c; j++){
      cin >> table[i][j];
    }
  }

  for(int i = 0; i < r; i++){
    for(int j = 0; j < c; j++){
      table[r][j] += table[i][j];
      table[i][c] += table[i][j];
      table[r][c] += table[i][j];
    }
  }

  for(int i = 0; i < r+1; i++){
    for(int j = 0; j < c+1; j++){
      if(j == c) cout << table[i][j] << endl;
      else cout << table[i][j] << " ";
    }
  }

  return 0;
}



Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rem(i, s, n) for (int i = (s); i >= (n); --i)
using ll = long long;
const int MOD = 1e9+7;

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

    string ans = "";
    rep(i, 0, s.size()) ans += 'x';

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}


int main(){
    int N,i;

    cin >> N >>i;

    cout << N-i+1 <<endl;

    return 0;

    


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define ll long long
#define re return
#define mp map<int,int>
using namespace std;
int ans=1,cnt=0,n,x;
int main() {
	cin>>n>>x;
	rep(i,1,n){
		int a;
		cin>>a;
		cnt+=a;
    	if(cnt>x) break;
		ans++;
	}
	cout<<ans; 
	re 0;
}


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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

typedef struct node node;
typedef struct edge{
    node* target;
    struct edge* next;
}edge;
typedef struct node{
    int value;
    edge* fst;
    edge* lst;
}node;
void initNodeArray(node* p, int n){
    for(int i=0; i<n; i++){
        (p+i)->value = 0;
        (p+i)->fst = NULL;
        (p+i)->lst = NULL;
    }
}
void addEdge(node* p, node* target){
    if(p->fst == NULL){
        p->fst = (edge*)malloc(sizeof(edge));
        p->lst = p->fst;
    }else{
        p->lst->next = (edge*)malloc(sizeof(edge));
        p->lst = p->lst->next;
    }
    p->lst->target = target;
    p->lst->next = NULL;
}
void rmEdge(node* p, node* q){
    edge* e = p->fst;
    edge* pre = NULL;
    while(e != NULL){
        if(e->target == q){
            if(pre != NULL){
                pre->next = e->next;
            }
            if(e == p->fst){
                p->fst = e->next;
            }
            if(e == p->lst){
                p->lst = pre;
            }
            free(e);
            return;
        }
        pre = e;
        e = e->next;
    }
    return;
}

void func(node* p, node* pre){
    if(p->value){
        return;
    }
    p->value = 1;
    edge* q = p->fst;
    while(q != NULL){
        if(q->target != pre){
            func(q->target, p);
        }
        q = q->next;
    }
    return;
}

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    node a[n+1];
    initNodeArray(a, n+1);
    int x[m], y[m];
    rep(i, 0, m){
        scanf("%d %d", &x[i], &y[i]);
        addEdge(&a[x[i]], &a[y[i]]);
        addEdge(&a[y[i]], &a[x[i]]);
    }
    int ans = 0;
    rep(i, 0, m){
        rmEdge(&a[x[i]], &a[y[i]]);
        rmEdge(&a[y[i]], &a[x[i]]);
        func(&a[1], &a[1]);
        int f = 0;
        rep(j, 1, n+1){
            if(a[j].value != 1){
                f = 1;
            }
        }
        if(f){
            ans++;
        }
        rep(j, 1, n+1){
            a[j].value = 0;
        }
        addEdge(&a[x[i]], &a[y[i]]);
        addEdge(&a[y[i]], &a[x[i]]);
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
N, X = map(int, input().split())
L = list(map(int, input().split()))

x = 0
for i in range(N + 1):
    if i == 0:
        x = 0
    else:
        x += L[i - 1]
        if x > X:
            ans = i
            break
        elif i == N:
            ans = N + 1

print(ans)

Measured memory_bytes: 3060
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools


def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29


def make1d_arr(n, val=INF):
    return [val for i in range(n)]


def make2d_arr(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)


def BFord(n, es):
    v_cost = [INF]*n
    v_cost[0] = 0
    for v in range(n*2):
        for e in es:
            frm = e[0]
            to = e[1]
            if v_cost[to] > v_cost[frm]+e[2]:
                v_cost[to] = v_cost[frm]+e[2]
                if v >= n:
                    v_cost[to] = -INF
        if v == n-1:
            prev = v_cost[:]
    v_cost = [-INF if prev[idx] != v_cost[idx] else v_cost[idx]
              for idx in range(n)]
    return v_cost


def ZAlgo(s):
    l = len(s)
    A = [0]*l
    i = 1
    j = 0
    A[0] = l
    while i < l:
        while i+j < l and s[j] == s[i+j]:
            j += 1
        if j == 0:
            i += 1
            continue
        A[i] = j
        k = 1
        while (i+k < l) and (k+A[k] < j):
            A[i+k] = A[k]
            k += 1
        i += k
        j -= k
    return A


DIV = 998244353


def main():
    N,K = isRaw()
    R,S,P = isRaw()
    T = sRaw()
    Ts = [t for t in T]
    rsp = {"r":P,"s":R,"p":S}
    wPrise = [rsp[c] for c in T]
    ans=0
    for n in range(N):
        if n<K:
            ans += wPrise[n]
        elif Ts[n-K] != Ts[n]:
            ans += wPrise[n]
        else:
            Ts[n]="."
    return ans

    
if __name__ == "__main__":

    print(main())


Measured memory_bytes: 49460
n=int(input())
if n==1:
    print(1)
else:
    oklist=[True for i in range(1000001)]
    l=[int(i) for i in input().split()]
    l.sort()
    res=0
    for i in range(n):
        if oklist[l[i]]:
            if i==n-1 or (i<n-1 and l[i]!=l[i+1]):
                res+=1
            for j in range(1,1000001):
                if l[i]*j<=1000000:
                    oklist[l[i]*j]=False
                else:
                  break
    print(res)



Measured memory_bytes: 164280
let f () = Scanf.scanf " %d" (+) 0
let n = f ()
let a_s = Array.init n @@ fun _ -> f ()
let bs = Array.init n @@ fun _ -> f ()
let cs = Array.init (n - 1) @@ fun _ -> f ()
let ans = ref @@ Array.fold_left (+) 0 bs
let _ = for i = 0 to n - 2 do if a_s.(i + 1) = a_s.(i) + 1 then ans := !ans + cs.(a_s.(i) - 1) done; Printf.printf "%d\n" !ans

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>  
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
const double PI=acos(-1.0);

typedef long long Int;
typedef long long LL;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <double, double> PDD;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 200007;
const int MAX2 = 1000007;
const int LEN = 21;
const int BASE = 1000000000;

const int MOD = 998244353;

int n, m;
vector<PII> X[MAX];
Int R[MAX];
Int T[MAX];

void update(int j, Int d, int i, int l, int r)
{
  if (l == r) T[i] = d;
  else {
    int m = (l+r)/2;
    if (j <= m) update(j, d, i*2, l, m);
    else update(j, d, i*2+1, m+1, r);
    T[i] = min(T[i*2], T[i*2+1]);
  }
}

Int get(int l, int r, int i, int tl, int tr)
{
  if (l > r) return LINF;
  if (l == tl && r == tr) return T[i];

  int m = (tl+tr)/2;
  if (r <= m) return get(l, r, i*2, tl, m);
  if (l > m) return get(l, r, i*2+1, m+1, tr);
  return min(get(l, m, i*2, tl, m), get(m+1, r, i*2+1, m+1, tr));
}

int main()
{
  FOR (i,0,MAX) T[i] = LINF;

  cin >> n >> m;
  FOR (i,0,m)
  {
    int l, r, x;
    scanf("%d %d %d", &l, &r, &x);
    -- l;
    -- r;
    X[r].PB(MP(l, x));
  }

  update(0, 0, 1, 0, n-1);

  FOR (i,1,n)
  {
    R[i] = LINF;
    FOR (j,0,SZ(X[i]))
    {
      int l = X[i][j].first;
      int c = X[i][j].second;

      R[i] = min(R[i], get(l, i-1, 1, 0, n-1) + c);
    }

    update(i, R[i], 1, 0, n-1);
  }


  cout << (R[n-1] >= LINF ? -1 : R[n-1]) << endl;




 
  return 0;
}


Measured memory_bytes: 13712
#include<stdio.h>
#include<string.h>
#include <stdlib.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define SWAP(a,b) {a+=b;b=a-b;a-=b;}
int main(){
	int n,num = 0,v[100000];
	scanf("%d",&n);
	int *a = (int *)malloc(sizeof(int) * n);
	FOR(i,0,n) scanf("%d",&a[i]);
	memset(v,0,sizeof(v));
	FOR(i,0,n){
		if(v[a[i]] == 0){
			v[a[i]] = 1;
			num++;
		}
	}

//	FOR(i,0,n-1) if(a[i] != a[i+1]) num++;

	if(num%2 == 0) printf("%d\n",num-1);
	else printf("%d\n",num);
}

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


signed main() {
	int n, m, x; cin >> n >> m >> x;
	int c1 = 0, c2 = 0;
	rep(i, m) {
		int a; cin >> a;
		if (a < x)c1++;
		else c2++;
	}
	cout << min(c1, c2) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,c;
	int i,j;
	int count=0;
	scanf("%d %d %d",&a,&b,&c);
		for(i=1;i<=c;i++){
			if((c%i==0) && (a<=i) && (i<=b)){
				count++;
			}
		}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num1 = scanner.nextInt();
        int num2 = scanner.nextInt();
        int num3 = scanner.nextInt();

        if((num1 + num2 + num3) >= 22){
        System.out.println("bust");
        }
        else {
                System.out.println("win");
        }
    }
}

Measured memory_bytes: 20692
#include <iostream>

using namespace std;
typedef long long ll;
const int maxn = 2e5 + 100;
int dp[maxn];

int main (){
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++){
        int p;
        cin >> p;
        ans = max (ans, dp[p - 1] + 1);
        dp[p] = dp[p - 1] + 1;
    }
    cout << n - ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;

int hikaku(const void *n1,const void *n2)
{
    return *(int*)n2-*(int*)n1;
}


int main()
{
    int n,z=0;
    ll x=0,y=0;
    scanf("%d",&n);
    ll a[n];
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    
    qsort(a,n,sizeof(ll),hikaku);

    for(int i=0;i<n;i++)
    {
        if(a[i+1]==a[i])
        {
            if(z==1)
            {
                y=a[i];
                z=2;
                break;
            }
            if(z==0)
            {
                x=a[i];
                i=i+1;
                z=1;
            }

        }
    }

    printf("%lld\n",x*y);


    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    ll ans=1e9;
    rep(i,1<<n){
        ll m = 1;
        rep(j,n){
            if (i>>j&1){
                m*=2;
            }else{
                m+=k;
            }
        }
        chmin(ans,m);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
from functools import reduce

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a = int(input().rstrip())
    b = int(input().rstrip())
    c = int(input().rstrip())
    d = int(input().rstrip())
    e = int(input().rstrip())
    k = int(input().rstrip())
    if abs(a - b) >k or abs(a - c) >k  or abs(a - d) >k or abs(a - e) >k or abs(b - c) >k or abs(b - d) >k  or abs(b - e) >k or abs(c - d) >k or abs(c - e) >k or abs(d - e) >k:
        print(':(')
    else:
        print('Yay!')
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
s = input()
t = input()
dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]
for i in range(len(s)):
    dp[i][0] = 0
for j in range(len(t)):
    dp[0][j] = 0
for i in range(0, len(s)):
    for j in range(0, len(t)):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = dp[i][j] + 1
        else:
            dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])
i = len(s)
j = len(t)
ans = ''
while True:
    if s[i - 1] == t[j - 1]:
        ans = s[i - 1] + ans
        i -= 1
        j -= 1
    if dp[i][j] == dp[i][j - 1]:
        j -= 1
    elif dp[i][j] == dp[i - 1][j]:
        i -= 1
    if i <= 0 or j <= 0:
        break
print(ans)

Measured memory_bytes: 113244
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;

int main(){

    ll N;
    cin >> N;
    vector<ll > multiple(N, 0);
    ll two = 0;
    ll four = 0;
    ll other = 0;

    for(ll i = 0; i < N; i++){
        ll a;
        cin >> a;

        if(a % 2 == 0){
            //4の倍数は必ず４の倍数
            if((a / 2) % 2 == 0){
                four++;
            }else{
                //2も2つ以上集まれば4の倍数になるのでお役立ちしますよ
                two++;
                if(two % 2 == 0){
                    four++;
                }
            }
        }else{
            //
            other++;
        }

    }

    //4の倍数だけ存在するとき
    if(N % 2 == 0){
        if(four >= N / 2){
            cout << "Yes" << endl;
            return 0;
        }
    }else{
        if(four >= N / 2 - 1){
            cout << "Yes" << endl;
            return 0;
        }        
    }

    cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[123];

int main(){
	int k; scanf("%d%s", &k, s);
	int n = strlen(s);
	if(n > k){
		s[k] = s[k+1] = s[k+2] = '.';
		s[k+3] = 0;
	}
	printf("%s\n", s);
}


Measured memory_bytes: 3764
# 6,8,1,2,3
# 中央値である3から初めて、残りから最大→最小の繰り返しで貪欲に取る
# 3 8 1 6 2
# 最小->最大の順でやるのと両パターン試して、大きい方採用
#
# 3 1 4 1 5 9
# 1 1 3 4 5 9
# 偶数のときは、中央値も2パターン取って大きいのを採用
#
# 5 5 1
# 5 1 5

N=int(input())
A=[0] * N
for i in range(N):
  A[i] = int(input())
  
if N == 2:
  print(abs(A[0] - A[1]))
  exit(0)
  
A=sorted(A)
minA = A[0]
maxA = A[-1]

mid = 0

from collections import deque

def calc(A,first,flip):
  q = deque(A)
  ans = 0
  cur = first
  while q:
    if flip:
      a = q.popleft()
    else:
      a = q.pop()
    ans += abs(a - cur)
    cur = a
    flip^=True
  return ans

if N%2:
  # 奇数のとき
  mid = A.pop(N//2)
  ans1 = calc(A,mid,True)
  ans2 = calc(A,mid,False)
  print(max(ans1,ans2))
  
else:
  # 偶数のとき
  A2 = A.copy()
  mid1 = A.pop(N//2-1)
  ans1_1 = calc(A,mid1,True)
  ans1_2 = calc(A,mid1,False)
  
  mid2 = A2.pop(N//2)
  ans2_1 = calc(A2,mid2,True)
  ans2_2 = calc(A2,mid2,False)
  
  print(max(ans1_1,ans1_2,ans2_1,ans2_2))


Measured memory_bytes: 10900
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);

lli getLisLength(vector<lli> a)
{
  lli inf = 1e18;
  vector<lli> dp(a.size() + 3, inf);
  //inf=>INF
  rep(i, a.size())
  {
    *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
  }
  return lower_bound(dp.begin(), dp.end(), inf) - dp.begin();
}
void test()
{
  const int N = 11;
  for (int i = 1; i <= N; i++)
  {
    cout << "length"
         << " " << i << endl;
    vector<lli> q;
    rep(j, i) q.push_back(j + 1);
    set<pair<int, int>> ans;
    map<pair<int, int>, vector<lli>> example;
    do
    {
      /*
      for (auto s : q)
        cout << s << " ";
        */
      lli ma = getLisLength(q);
      reverse(q.begin(), q.end());
      lli mi = getLisLength(q);
      ans.insert(make_pair(ma, mi));
      if (!example.count(make_pair(ma, mi)))
      {
        example[make_pair(ma, mi)] = q;
      }
      reverse(q.begin(), q.end());

    } while (next_permutation(q.begin(), q.end()));
    for (auto s : ans)
    {
      cout << s.first << " " << s.second << " :";
      for (auto j : example[s])
      {
        cout << j << " ";
      }
      cout << endl;
    }
  }
}
void solve(long long N, long long A, long long B)
{
  lli n = N;
  if (A * B < N)
  {
    cout << -1 << endl;
    return;
  }
  // bool rev = true;
  // if (A < B)
  // {
  //   rev = false;
  //   swap(A, B);
  // }
  vector<int> ans(A);
  ans[0] = B;
  N -= (B + A - 1);
  for (int i = 1; i < A; i++)
    ans[i] = 1;
  for (int i = 1; i < A; i++)
  {
    if (N >= B - 1)
    {
      ans[i] += B - 1;
      N -= B - 1;
    }
    else
    {
      ans[i] += N;
      N = 0;
    }
  }
  vector<vector<int>> calc(A);
  int cnt = 1;
  rrep(i, A)
  {
    rep(j, ans[i])
    {
      calc[i].push_back(cnt++);
    }
  }
  vector<lli> last;

  rep(i, A)
  {
    for (auto s : calc[i])
      last.push_back(s);
  }
  bool flag = false;
  auto cp = last;
  reverse(cp.begin(), cp.end());
  if (last.size() != n || getLisLength(last) != B || getLisLength(cp) != A)
  {
    cout << -1 << endl;
    return;
  }
  rep(i, n) cout << cp[i] << " ";
}

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

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


Measured memory_bytes: 30444
def otoshidama(N,Y):
    a = min(N,Y//10000) + 1
    l = -1
    m = -1
    n = -1
    for x in range(a):
        b = min(N - x,(Y - 10000*x)//5000) + 1
        for y in range(b):
            if (N - x - y)*1000 == Y - 10000*x - 5000*y:
                l = x
                m = y
                n = N - x - y
    print(l,m,n)

s = list(map(int,input().split()))
N = s[0]
Y = s[1]
otoshidama(N,Y)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))
 
typedef long long ll;
 
const int INF = 1000000000;
const int MOD = 1000000007;

int main (){
	int n;
	cin >> n;
	int itmp = n;
	string stmp = to_string(n);
	int sum = 0;
	rep(i, stmp.size()) {
		sum += itmp % 10;
		itmp /= 10;
	}
	if (n % sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
# coding=utf-8

###
### for atcorder program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def get_input():
    N = []
    while True:
        try:
            N.append(input())
            #N.append(int(input()))
            #N.append(float(input()))
        except EOFError:
            break
    return N

N, A, B = [int(x) for x in input().split()]

x = A * N
y = B

if x < y:
    y = x

print(y)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

ll f(ll b, ll n){
    if(n < b) return n;
    else return f(b, n/b) + n%b;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n,s;
    cin >> n >> s;
    if(n == s){
        cout << n+1 << endl;
        return 0;
    }
    if(s > n){
        cout << -1 << endl;
        return 0;
    }
    for(ll i = 2; i * i <= n; i++){
        if(f(i, n) == s){
            cout << i << endl;
            return 0;
        }
    }
    
    ll ans = -1;
    for(ll i = 1; i * i < n; i++){
        if((n-s)%i != 0) continue;
        ll b = (n-s)/i + 1;
        if(f(b,n) == s){
            ans = b;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def read(): (Int, String, Int) = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val s = sc.next()
    val k = sc.nextInt()
    //val h = for (_ <- 0 until n) yield sc.nextInt()
    (n,s,k)
  }

  def solve(n:Int, s:String, k:Int): String = {
    val kc = s(k-1)
    s.map(c=> if (c != kc) '*' else c).mkString
  }


  def main(args: Array[String]): Unit = {
    val (n,s,k) = read()
    println(solve(n,s,k))
  }

}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;


ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

int N;
ll T[10000], A[10000];
ll dp[10000];


/****************************************
** A main function starts from here  ****
*****************************************/
int main(){
  cin >> N;
  rep(i, N){
    cin >> T[i+1] >> A[i+1];
  }

  ll a=1;
  ll t = 1;
  ll total = a+t;
  for(int n=1;n<=N;n++){
    ll fact = max((a+A[n]-1)/A[n], (t+T[n]-1)/T[n]);
    a = fact * A[n];
    t = fact * T[n];
    total = a + t;
    //cout << total << endl;
  }
  cout << total;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long 
const int p = 1e9 + 7;
char s[100100];
LL dp[100010][10][15];
int add[33];
int main(){
	scanf("%s", s + 1);
	for(int i = 1; i <= 9; i++){
		add[i] = i * 10 % 13;
	}
	int len = strlen(s + 1);
	for(int i = 1;i <= len; i++)if(s[i] != '?')s[i] -= '0';
	if(s[len] == '?'){
		for(int i = 0;i <= 9; i++){
			dp[len][i][i] = 1;
		}		
	}
	else{
		dp[len][s[len]][s[len]] = 1;
	}
	for(int i = len - 1;i >= 1; i--){
		if(s[i] != '?'){
			for(int j = 0; j <= 9; j++){
				for(int k = 0;k <= 12; k++){
					(dp[i][s[i]][(add[s[i]] + k)%13] += dp[i+1][j][k]) %= p;
				}
			}
		}
		else{
			for(int j = 0;j <= 9; j++){
				for(int k = 0;k <= 12; k++){
					for(int x = 0; x <= 9; x++){
						(dp[i][j][(add[j]+k)%13] += dp[i+1][x][k]) %= p;
					}
				}
			}			
		}
		for(int i = 1;i <= 9; i++){
			add[i] = add[i] * 10 % 13;
		}
	}
	LL ans = 0;
	for(int i = 0;i <= 9; i++)(ans += dp[1][i][5]) %= p;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 117504
n, a, b = [int(i) for i in input().split()]
s = input()
cnt_pass = 0
cnt_b = 0
for i in range(n):
    if s[i] == "a":
        if cnt_pass < a + b:
            print("Yes")
            cnt_pass += 1
        else:
            print("No")
    elif s[i] == "b":
        if cnt_pass < a + b and cnt_b < b:
            print("Yes")
            cnt_pass += 1
            cnt_b += 1
        else:
            print("No")
    else:
        print("No")

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

# define ll long long
# define mod 1000000007
# define MAX 100005
# define PI 3.141592653589793238                                                                                  //shortcut keys

# define pb push_back
# define mp make_pair
# define all(x) x.begin(),x.end()
# define fr(i,a,b) for(int i=a;i<=b;i++)

# define decimal(k) fixed<<setprecision(k)
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------
using namespace std;

int main()
{
	
	string s,t;cin>>s>>t;
	int n=s.size(),m=t.size();
	int ans=INT_MAX;
	for(int i=0;i<n-m+1;i++){
		string a=s.substr(i,m);
		int cnt=0;
		fr(i,0,m-1){
			if(a[i]!=t[i])cnt++;
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<'\n';

	return 0;
}



Measured memory_bytes: 3528
#include <iostream>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <string.h>

using namespace std;

int ok, arr[100];

int main(void) {
    memset(arr, 0, sizeof(arr));
    while(~scanf("%d", &ok)) {
        arr[ok] += 1;
    }
    int mx = *max_element(arr, arr + 100);
    for(int i = 0; i < 100; i++) {
        if(arr[i] == mx) {
            printf("%d\n", i);
        }
    }
    return 0;
}

Measured memory_bytes: 0
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var s = o.r(n,1).map(a=>a.split("").sort().join("")).sort();
  var ans = 0;
  var t = s[0], u = 0;
  for(var i = 1; i < n; i++){
    if(s[i] === t)u++;
    else{
      ans += u*(u+1)/2;
      u = 0;
      t = s[i];
    }
  }
  if(u)ans += u*(u+1)/2;
  return ans;
}

Measured memory_bytes: 56488
#include <bits/stdc++.h>
#define ll long long
#define Start ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define fr first
#define sc second
#define PI 3.14159265
#define ullt unsigned long long int
using namespace std;
void solve(){
	int n,x,t;
	cin>>n>>x>>t;
	cout<<(n/x+(n%x>0))*t;
}	
int main()
{
	Start;

	int t = 1;
	//cin>>t;
	while (t--)
	{
		solve();
		cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    int N;
    cin >> N;
    cout << N * N * N << endl;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<utility>//pair
#include<list>
#include<vector>//可変長配列
#include <assert.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define all(a) (a).begin(),(a).end()
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<ll,ll>
#define F first
#define S second
int dx[8] = { 1,0,-1,0,1,-1,-1,1 };
int dy[8] = { 0,1,0,-1,1,1,-1,-1 };

int n;
ll a[222222];
map<ll, int> ta;


int main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	ll cnt = 0;
	for (ll i = n - 1; i >= 1; i--) {
		ta[a[i] - i]++;
		cnt += ta[-(i-1)-a[i-1]];
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 27852
import java.util.*;

public class Main {

	public static void main(String[] args) {
		int n,s,max,count;
		
		max=9;
		Scanner sc = new Scanner(System.in);
		
		for(;;){
		
			n = sc.nextInt();
			s = sc.nextInt();
		
			if(n==0&&s==0)break;
			if(s>864) s=864;
			
			count = check(n-1,s,max);
		
			System.out.println(count);
		}
	}

	private static int check(int n, int s,int max) {
		int count = 0;
		
		if(s<max) max=s;
		
		if(n==0 && s==max) 	return 1;
		else if(n==0)		return 0;
		
		for(;max>=0;max--)
			if(s-max <= n*(max-1))			count += check(n-1,s-max,max-1);
		
		
		return count;
	}

}

Measured memory_bytes: 17208