akhauriyash/Code-Regression huggingface dataset:
#include<string>
#include<iostream>
using namespace std;

class Dice{
	int dn[6];
	string qu;

public:
	Dice(int d1, int d2, int d3, int d4, int d5, int d6){
		dn[0] = d1;
		dn[1] = d2;
		dn[2] = d3;
		dn[3] = d4;
		dn[4] = d5;
		dn[5] = d6;
	}

	int Result(string m){
		int w;
		qu = m;

		for (int i = 0; i < qu.size(); i++){
			switch (qu[i]){
			case 'E':
				w = dn[0];
				dn[0] = dn[3];
				dn[3] = dn[5];
				dn[5] = dn[2];
				dn[2] = w;
				break;

			case 'N':
				w = dn[5];
				dn[5] = dn[4];
				dn[4] = dn[0];
				dn[0] = dn[1];
				dn[1] = w;
				break;

			case 'S':
				w = dn[0];
				dn[0] = dn[4];
				dn[4] = dn[5];
				dn[5] = dn[1];
				dn[1] = w;
				break;

			case 'W':
				w = dn[0];
				dn[0] = dn[2];
				dn[2] = dn[5];
				dn[5] = dn[3];
				dn[3] = w;
				break;
			}
		}
		return dn[0];
	}
};

int main()
{
	int dnum[6];
	string q;

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

	Dice d(dnum[0],dnum[1],dnum[2],dnum[3],dnum[4],dnum[5]);
	cout << d.Result(q) << endl;
	
	return 0;
}


Measured memory_bytes: 3216
#include <stdio.h>
int main(){
  int i,j;
  scanf("%d %d",&i,&j);
  if(i > j){
    printf("a > b\n");
  }
  else if(j > i){
    printf("a < b\n");
  }
  else{
    printf("a == b\n");
  }
  return(0);
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int A, B; cin >> A >> B;
	int ans;
	if (A > B * 2)
		ans = A - B * 2;
	else
		ans = 0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

class LazySegmentTree {
private:
	int size_;
	vector<long long> v, lazy;
	void update(int a, int b, long long x, int k, int l, int r) {
		push(k, l, r);
		if (r <= a || b <= l) return;
		if (a <= l && r <= b) {
			lazy[k] = x;
			push(k, l, r);
		}
		else {
			update(a, b, x, k * 2, l, (l + r) >> 1);
			update(a, b, x, k * 2 + 1, (l + r) >> 1, r);
			v[k] = merge(v[k * 2], v[k * 2 + 1]);
		}
	}
	long long query(int a, int b, int k, int l, int r) {
		push(k, l, r);
		if (r <= a || b <= l) return 0;
		if (a <= l && r <= b) return v[k];
		long long lc = query(a, b, k * 2, l, (l + r) >> 1);
		long long rc = query(a, b, k * 2 + 1, (l + r) >> 1, r);
		return merge(lc, rc);
	}
 
public:
	LazySegmentTree() : v(vector<long long>()), lazy(vector<long long>()) {};
	LazySegmentTree(int n) {
		for (size_ = 1; size_ < n;) size_ <<= 1;
		v.resize(size_ * 4,0);
		lazy.resize(size_ * 4,0);
	}
	inline void push(int k, int l, int r) {
		if (lazy[k] != 0) {
			v[k] += lazy[k];
			if (r - l > 1) {
				lazy[k * 2] += lazy[k];
				lazy[k * 2 + 1] += lazy[k];
			}
			lazy[k] = 0;
		}
	}
	inline long long merge(long long x, long long y) {
		return max(x,y);
	}
	inline void update(int l, int r, long long x) {
		update(l, r, x, 1, 0, size_);
	}
	inline long long query(int l, int r) {
		return query(l, r, 1, 0, size_);
	}
};

ll h[222222];
ll dp[222222];
ll a[222222];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>h[i]; h[i]--;
	}
	for(int i=0;i<n;i++) cin>>a[i];
	LazySegmentTree st(n+1);
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		dp[i]=st.query(0,h[i])+a[i];
		st.update(h[i],h[i]+1,dp[i]);
		ans=max(ans,dp[i]);
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 21504
import numpy as np
n,m,x=map(int,input().split())
flg=np.zeros((m+1),dtype=int)
minimn=-1
data=np.zeros((n,m+1))
for i in range(n):
    data[i]=list(map(int,input().split()))
for i in range(2**n):
    flg=np.zeros((m+1))
    for j in range(n):
        if (i>>j)&1:
            flg+=data[j]
    if all(flg[1:]>=x):
        if minimn==-1:
          minimn=flg[0]
        elif flg[0]<minimn:
          minimn=flg[0]
print(int(minimn))

Measured memory_bytes: 27096
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K;
    cin >> K;
    int c = 0;
    vector<int> A(1000000); 
    for (int i=0; i < 1000000; i++){
        if(i == 0){
            A.at(i) = 7;
            A.at(i) %= K;
        }else{
            A.at(i) = A.at(i-1)*10 + 7 ;
            A.at(i) %= K; 
        }
    }
    for (int i=0; i < 1000000; i++){
        c++;
        if(A.at(i) == 0){
            cout << c << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    

    return 0;
}

Measured memory_bytes: 7232
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<vector<i64>> a(N, vector<i64>(N));
  REP(i, N) REP(j, N) { cin >> a[i][j]; }

  vector<i64> scores(1 << N);
  REP(s, 1 << N) {
    i64 score = 0;
    REP(i, N) {
      if (~s & 1 << i) continue;
      REP(j, i) {
        if (s & 1 << j) score += a[i][j];
      }
    }
    scores[s] = score;
  }

  vector<i64> dp(1 << N);
  vector<bool> done(1 << N);
  done[0] = true;
  auto maximize = [&](auto rec, int b, int state) -> i64 {
    if (done[state]) return dp[state];
    done[state] = true;
    assert(state & 1 << b);
    i64 res = 0;
    for (int s = (1 << b); s < (1 << (b + 1)); ++s) {
      if ((s & state) == s) {
        i64 r = rec(rec, b - 1, state & ~s) + scores[s];
        res = max(res, r);
      }
    }
    dp[state] = res;
    return res;
  };
  i64 ans = maximize(maximize, N - 1, (1 << N) - 1);
  cout << ans << endl;
}


Measured memory_bytes: 4256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
using namespace std;
ll n,a[100000],s=0,x=-1,y=-1,cnt;
int32_t main(){
cin>>n;
for(ll i=0;i<n;i++)
cin>>a[i];
for(ll i=0;i<n;i++)
if(a[i]<0){
    cnt++;
}
if(cnt%2==0){
    for(ll i=0;i<n;i++)
        s=s+abs(a[i]);
    cout<<s;
    return 0;
}else {
for(ll i=0;i<n;i++)
    a[i]=abs(a[i]);
sort(a,a+n);
s=s-a[0];
for(ll i=1;i<n;i++)
    s=s+a[i];
    cout<<s;
    return 0;
}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    int n;
    cin >> n;
    vector<int> vec;
    while(n--){
        int a;
        cin >> a;
        int count = 0;
        while(a>=0){
            if(a%2==0){
                a/=2;
                count++;
            }else{
                break;
            }
        }
        vec.push_back(count);
    }
    vector<int>::iterator ans;
    ans = min_element(vec.begin(),vec.end());
    cout << *ans <<endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

const int shichigosan[] = {357, 375, 537, 573, 735, 753};
const int po[] = {3, 5, 7};


bool check(int num[], int n, int len){
	bool appeared[3];
	REP(i,3){
		appeared[i] = false;
	}
	int x=0;
	REP(i,len){
		REP(k,3){
			if (num[i]==po[k]){
				appeared[k] = true;
				break;
			}
		}
	}
	REP(i,3){
		if (!appeared[i]){
			return false;
		}
	}
	REP(i,10){
		x += num[i]*pow(10,i);
	}
	// debug(x);
	if (x > n){
		return false;
	}
	return true;
}

int dfs(int num[], int n, int len, int x){
	if (x==len){
		// REP(i,len){
		// 	printf("%d", num[len-1-i]);
		// }
		if (!check(num, n, len)){
			// printf(" : NG\n");
			return 0;
		}
		// printf(" : OK\n");
		return 1;
	}else{
		int ret=0;
		REP(i,3){
			num[x] = po[i];
			ret += dfs(num, n, len, x+1);
		}
		return ret;
	}
}

int main(){
	
	string nstr;
	int n, len, ans=0;
	
	cin >> nstr;
	n = stoi(nstr);
	len = nstr.length();
	
	if (n < 1000){
		REP(i,6){
			if (shichigosan[i] <= n){
				ans++;
			}
		}
		cout << ans << endl;
		return 0;
	}
	
	ans = 6;
	
	for (int i=4; i<len; i++){
		ans += pow(3, i) - pow(2, i)*3 + 3;
	}
	
	int num[10];
	REP(i,10){
		num[i] = 0;
	}
	
	cout << ans + dfs(num, n, len, 0) << endl;
	
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

struct edge {int to, cost, time;};

int main() {
  int n, m;
  while(cin >> n >> m) {
    if(!n && !m) return 0;
    vector<edge> ra[101];

    rep(i, 0, n) {
      int a, b, c, t;
      cin >> a >> b >> c >> t;
      edge f, g;
      f.to = b, g.to = a, f.cost = c, g.cost = c, f.time = t, g.time = t;
      ra[a].pb(f);
      ra[b].pb(g);
    }

    int k;
    cin >> k;
    rep(i, 0, k) {
      int s, e, r;
      cin >> s >> e >> r;
      int si[101];
      priority_queue<P, vector<P>, greater<P> > que;
      fill(si, si + 101, INT_MAX);
      si[s] = 0;
      que.push(P(0, s));
      while(!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if(si[v] < p.first) continue;
        rep(i, 0, ra[v].size()) {
          edge ed = ra[v][i];
          if(si[ed.to] > si[v] + (r ? ed.time : ed.cost)) {
            si[ed.to] = si[v] + (r ? ed.time : ed.cost);
            que.push(P(si[ed.to], ed.to));
          }
        }
      }

      cout << si[e] << endl;
    }
  }
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int n;
  cin >> n;
  int bit = 1<<n;
  int a[n], b[n];
  int ans = 0;
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<n; i++) cin >> b[i];
  for(int i=0; i<bit; i++){
    int tmp = 0;
    for(int j=0; j<n; j++){
      if (i & (1<<j)) tmp += a[j]-b[j];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
import math

N = int(input())

n = math.floor(math.log10(N))


def check(n):
    c7 = False
    c5 = False
    c3 = False
    while n != 0:
        d = n % 10
        if d == 7:
            c7 = True
        elif d==5:
            c5 = True
        elif d==3:
            c3 = True
        else:
            return False


        n //= 10
    if c7 and c5 and c3:
        return True
    else:
        return False


def f(cur, i):
    if cur > N:
        return 0

    if i==-1:
        if check(cur):
            # print("OK:{}".format(cur))
            return 1
        else:
            # print("NG:{}".format(cur))
            return 0

    r7 = f(cur + 7 * (10 ** i), i - 1)
    r5 = f(cur + 5 * (10 ** i), i - 1)
    r3 = f(cur + 3 * (10 ** i), i - 1)
    r0 = f(cur + 0 * (10 ** i), i - 1)
    return r7 + r5 + r3 + r0

nn = 10 ** n

r7 = f(7 * nn, n - 1)
r5 = f(5 * nn, n - 1)
r3 = f(3 * nn, n - 1)
r0 = f(0 * nn, n - 1)

ret = r7 + r5 + r3 + r0

print(ret)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
    int n, q; cin >> n >> q;
    string s; cin >> s;
    vector<int> vc(n,0);
    for(int i=1;i<n;i++) {
        vc[i] = vc[i-1];
        if(s[i]=='C'&&s[i-1]=='A')
            vc[i]++;
    }
    rep(i, q){
        //cout << vc[i] << endl;
        int l, r; cin >> l >> r;
        l--,r--;
        cout << vc[r] - vc[l] << endl;
    }
}


Measured memory_bytes: 1408
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"5 3 11
1"# => r#"30"#,

r#"3 3 4
2"# => r#"22"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        mut abc: [u64; 3],
        k: u32,
    }
    abc.sort();
    (abc[0] + abc[1] + abc[2] * 2_u64.pow(k)).to_string()
}

Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int main()
{
    int n;
    cin >> n;
    unordered_set<string> seen;

    string str;
    cin >> str;
    seen.insert(str);
    char last = str.back();
    for (int i = 1; i < n; i++)
    {
        cin >> str;
        if (seen.find(str) != seen.end() || str[0] != last)
        {
            cout << "No";
            return 0;
        }
        seen.insert(str);
        last = str.back();
    }
    cout << "Yes";
}

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

using ll = long long;
using ld = long double;

int n, a, b;

ll f(ll x, ll k) {
  ll ceil = (x - k * b + a - b - 1) / (a - b);
  return max(0LL, ceil);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);

  cin >> n >> a >> b;
  vector<int> h(n);
  for(int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int hi = 1e9, lo = 1, ans = -1;
  while(hi >= lo) {
    ll mid = (hi + lo) / 2;
    ll temp = 0;
    for(int i = 0; i < n; i++) {
      temp += f(h[i], mid);
    }
    if(mid >= temp) {
      ans = mid;
      hi = mid - 1;
    } else {
      lo = mid + 1;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3712
object Main extends App {
  import scala.annotation.tailrec

  def ans(s: String): String = {
    val xs = cards(s)
    val n = xs.head + xs(1)
    val p = others(xs).map(_ + n).count(_ <= 20) / 7.0

    if (p < 0.5) "NO"
    else "YES"
  }
  def others(xs: Seq[Int]): Seq[Int] = 1.to(10).filterNot(xs.contains)
  def cards(s: String): Seq[Int] = s.split(' ').map(_.toInt)

  @tailrec
  def loop() {
    val line = scala.io.StdIn.readLine()
    if (line == null) return
    else {
      println(ans(line))
      loop()
    }
  }

  loop()
}

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

using namespace std;

void scan(__int128 &x)//ﾊ菠・
{
    x = 0;
    int f = 1;
    char ch;
    if((ch = getchar()) == '-') f = -f;
    else x = x*10 + ch-'0';
    while((ch = getchar()) >= '0' && ch <= '9')
        x = x*10 + ch-'0';
    x *= f;
}
void _print(__int128 x)
{
    if(x > 9) _print(x/10);
    putchar(x%10 + '0');
}
void print(__int128 x)//ﾊ莎・
{
    if(x < 0)
    {
        x = -x;
        putchar('-');
    }
    _print(x);
}

int main() {
	__int128 a, v, b, w, t;
	scan(a), scan(v);
	scan(b), scan(w);
	scan(t);
	
	if (v <= w) {
		cout << "NO\n";
		return 0;
	}
	__int128 d = abs(a - b);
	if (d <= (v - w) * t) cout << "YES\n";
	else cout << "NO\n";
	
	return 0;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(A: int, B: int, C: int):
    if A%2 == 0 or B%2 == 0 or C%2 == 0:
        print(0)
    else:
        print(min(A*B, B*C, C*A))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define clr(a,v) memset((a),(v),sizeof(a))

const int MAX_X = 100;

int X, Y, E;
std::vector<int> G[MAX_X];
bool used[MAX_X];
int pr[MAX_X];
int ans;

bool dfs( int v )
{
  if( v < 0 )
    return true;
  if( used[v] )
    return false;

  used[v] = true;

  for( int u : G[v] )
  {
    if( dfs( pr[u] ) )
    {
      pr[u] = v;
      return true;
    }
  }

  return false;
}

int main()
{
  scanf( "%d%d%d", &X, &Y, &E );
  rep( i, E )
  {
    int x, y;
    scanf( "%d%d", &x, &y );
    G[x].push_back( y );
  }

  clr( pr, -1 );

  rep( x, X )
  {
    clr( used, false );
    
    if( dfs(x) )
      ++ans;
  }

  printf( "%d\n", ans );

  return 0;
}

Measured memory_bytes: 2756
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 100005;
string s;
 
ll knap[2505][55];
 
int main(){
	fast_io();
	knap[0][0] = 1;
	int n,a;
	cin >> n >> a;
	cu(i,0,n){
		int x;
		cin >> x;		
		fd(i,2500,0){
			fu(l,0,50){
				if(knap[i][l] && i + x <= 2500){
					knap[i + x][l+1] += knap[i][l];
				}
			}
		}
	}
	ll ans = 0;
	fu(i,1,50){
		ans += knap[i * a][i];	
	}
	cout << ans << '\n';
}
	

Measured memory_bytes: 768
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
bool ex[24];
int cnt[13];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;cin>>N;
  ex[0]=true;
  FOR(i,0,N){
    int d;cin>>d;
    cnt[d]++;
  }
  if(cnt[0]||cnt[0]>=2||cnt[12]>=2){
    cout<<0<<endl;
    return 0;
  }
  if(cnt[12])ex[12]=true;
  vector<int> v;
  FOR(i,1,12){
    if(cnt[i]==1){
      v.push_back(i);
    }
    if(cnt[i]==2){
      ex[i]=ex[24-i]=true;
    }
    if(cnt[i]>=3){
      cout<<0<<endl;
      return 0;
    }
  }
  int ans=0;
  int n=v.size();
  FOR(i,0,1<<n){
    bool ex2[24];
    FOR(j,0,24) ex2[j]=ex[j];
    FOR(j,0,n){
      if(i&(1<<j)){
        ex2[v[j]]=true; 
      }else{
        ex2[24-v[j]]=true;
      }
    }
    int mn=1e9;
    FOR(i,0,24){
      FOR(j,i+1,24){
        if(ex2[i] && ex2[j]){
          mn=min(mn,abs(j-i));
          mn=min(mn,24-abs(j-i));
        }
      }
    }
    if(mn!=1e9)ans=max(ans,mn);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,l[200005],r[200005];
char s[200005];
int main()
{
    scanf("%d",&n);
    scanf("%s",s+1);
    for(int i=1;i<=n;i++)
    {
        l[i]=l[i-1];
        if(s[i]=='#') l[i]++;
    }
    for(int i=n;i>=1;i--)
    {
        r[i]=r[i+1];
        if(s[i]=='.') r[i]++;
    }
    int ans=1e9;
    for(int i=1;i<n;i++)
        ans=min(ans,l[i]+r[i+1]);
    ans=min(ans,l[n]);
    ans=min(ans,r[1]);
    printf("%d\n",ans);
}



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

int main() {
  int a,b,cnt=1,ans=0;
  cin>>a>>b;
  while(cnt<b){
    cnt+=a-1;
    ans++;
  }
  cout<<ans<<endl;
}

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

int main() {
    double r, S, L;
    double Pi = 3.141592653589;

    cin >> r; 

    S = Pi*r*r;
    L = 2*Pi*r;

    printf("%lf %lf\n", S, L);

    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int d;
  cin>>d;
  vector<int> c(26);
  for (int i = 0; i < 26; ++i)
  {
    cin>>c[i];
  }
  vector<vector<int>> s(d,vector<int>(26));
  for (int i = 0; i < d; ++i)
  {
    for (int j = 0; j < 26; ++j)
    {
      cin>>s[i][j];
    }
  }
  int ans=0;
  vector<int> last(26,0);
  for (int i = 0; i < d; ++i)
  {
    int tmp;
    cin>>tmp;
    last[tmp-1]=i+1;
    ans+=s[i][tmp-1];
    for (int j = 0; j < 26; ++j)
    {
      ans-=c[j]*(i+1-last[j]);
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3676
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;

#define Sort(a) sort(a.begin(),a.end())
#define ReSort(a) sort(a.rbegin(),a.rend())
#define Reverse(a) reverse(a.begin(),a.end())
#define Sum(a) accumulate(a.begin(),a.end(),0)
#define SumLL(a) accumulate(a.begin(),a.end(),0LL)
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

void print() { cout << endl; }
template <class H> void print(H && h) { cout << h << endl; }
template <class H, class... T> void print(H && h, T && ... t) { cout << h << " "; print(forward<T>(t)...); }
void CINPUT() {}
template<class H, class ...T> void CINPUT(H && h, T && ...t) { cin >> h; CINPUT(forward<T>(t)...); }

//INPUT//
#define in(...) int __VA_ARGS__; CINPUT(__VA_ARGS__);
#define In(T,...) T __VA_ARGS__; CINPUT(VA_ARGS__);
#define Vin(T,name,n) int n; cin>>n; vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn(T,name,n) vector<T> name(n); rep(i,n)cin>>name[i];

//OUTPUT//
#define yes(flag) puts((flag) ? "yes" : "no");
#define Yes(flag) puts((flag) ? "Yes" : "No");
#define YES(flag) puts((flag) ? "YES" : "NO");
#define Yay(flag) puts((flag) ? "Yay!" : ":(");
#define poss(flag) puts((flag) ? "possible" : "impossible");
#define Poss(flag) puts((flag) ? "Possible" : "Impossible");
#define POSS(flag) puts((flag) ? "POSSIBLE" : "IMPOSSIBLE");
#define out(n) cout << (n) << endl;
#define Vout(a) rep(i, sz(a))cout << a[i] << (i==sz(a)-1?"\n":" ");

int main() {
	in(a, b, t);
	out(t / a * b);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<int>l(n);
  rep(i,n)cin>>l[i];
  sort(all(l));
  int res=0;
  rep(i,n)
  {
    repi(j,i+1,n)
    {
      res+=max((int)(lower_bound(l.begin()+j,l.end(),l[i]+l[j])-l.begin())-j-1,0);
    }
  }
  cout<<res<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

int main(){
  ll n; cin >> n;
  ll ans = 0;
  for(ll i = 2; i*i <= n; i++){
    if(n % i == 0){
      int c = 0;
      while(n % i == 0){
        n /= i;
        c++;
      }
      for(int j = 1; j <= c; j++){
        ans++;
        c -= j;
      }
    }
  }
  if(n != 1) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3548
N = gets.to_i
as = gets.strip.split(/ /).collect{|n| n.to_i}

count = 1
up = nil
prev_a = as[0]
(1...as.length).each{|i|
	a = as[i]
	
	if prev_a == a
	elsif prev_a < a
		if up == nil || up == true
			up = true
		else
			up = nil
			count += 1
		end
	else
		if up == nil || up == false
			up = false
		else
			up = nil
			count += 1
		end
	end
	
	prev_a = a
}

puts count


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define __              ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i,a,b) 		for(int i=a;i<b;i++)
#define repb(i,a,b) 	for(int i=a;i>=b;i--)
#define inp(a,n)		for(int i=0 ; i<n ; i++){cin >> a[i];} 

void file(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
	#endif
}

int bs(int a[] , int s , int e, int x){
	if(s<=e){
		int m = (s+e)/2;
		if(a[m]==x)
			return m;
		else if(a[m] > x)
			return bs(a,s,m-1,x);
		else return bs(a,m+1,e,x);
	}
	return -1;
}

int32_t main(){	

	int x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	vi arr(a);
	vi arg(b);
	vi col;
	inp(arr,a);
	inp(arg,b);
	for(int i=0 ; i<c ; i++){
		int p; cin >> p; col.push_back(p);
	}

	sort(arr.rbegin() , arr.rend());
	sort(arg.rbegin() , arg.rend());

	rep(i,0,x){
	//	cout << arr[i] << " ";
		col.pb(arr[i]);
	}
	//cout << endl;
	rep(i,0,y){
	//	cout << arg[i] << " ";
		col.pb(arg[i]);
	}
	int ans=0;
	//cout << endl;
	sort(col.rbegin() , col.rend());
	rep(i , 0 , x+y){

		ans += col[i];
	}
	cout << ans << endl;


	
}

Measured memory_bytes: 7920
#include<iostream>
#include<map>
#include<cmath>

using namespace std;

int main() {
	int a, b;

	cin >> a;
	cin >> b;

	if (a == 1) a = 14;
	if (b == 1) b = 14;

	if (a < b) {
		cout << "Bob" << endl;
	}
	else if (a > b) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Draw" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    int m = 1 << n;
    VI a(m);
    REP(i,m) a[i] = in();
    map<int, int> mp;
    REP(i,m) mp[-a[i]]++;
    priority_queue<int> que;
    int ma = *max_element(ALL(a));
    que.push(n);
    for (auto tmp : mp){
        int x = tmp.second;
        if (-tmp.first == ma){
            if (x == 1) continue;
            cout << "No" << endl;
            return 0;
        }
        // cout << -tmp.first << " " << x << endl;
        VI v;
        REP(i,x){
            if (que.empty()){
                cout << "No" << endl;
                return 0;
            }
            int p = que.top();
            que.pop();
            if (p > 1){
                que.push(p - 1);
                v.push_back(p - 1);
            }
        }
        for (int x : v) que.push(x);

        // priority_queue<int> hoge(que);
        // while (!hoge.empty()){
        //     cout << hoge.top() << " ";
        //     hoge.pop();
        // }
        // cout << endl;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  string s;
  cin>>s;
  int a = 0;
  int n = s.size();
  ll res = 0;
  REP(i,n-1) {
    if (s[i] == 'A') ++a;
    else if (s.substr(i,2) == "BC") {
      res += a;
      ++i;
    } else {
      a = 0;
    }
  }
  cout << res << endl;
  return 0;
}


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

int A, B, C;

int main () {
	cin >> A >> B >> C;
	if (A==B) {
		cout << C << endl;
	} else if (A==C) {
		cout << B << endl;
	} else {
		cout << A << endl;
	}
}


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

int main()
{
	int item , knapsack;
	scanf("%d%d",&item,&knapsack);
	
	vector<long long int> dp(knapsack+10);
	for(int i = 0 ; i < item; i++){
		int w , v; 
		scanf("%d%d",&w,&v);
		for(int weight = knapsack ; weight >= w ; weight--){
			if(weight-w == 0 or dp[weight-w] ){
				dp[weight] = max(dp[weight-w] + v , dp[weight] );
			}
		}
	}
	
	long long int mx = 0;
	for(auto x : dp) mx = max(mx,x);
	
	printf("%lld\n",mx);
	
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>

int main()
{
	int n;scanf("%d\n",&n);
	int p1=0,p2=0,p4=0;
	for(int i=1;i<=n;i++)
	{
		int ai;
		scanf("%d",&ai);
		if(ai%4==0) p4++;
		else ai%2==0? p2++: p1++;
	}
	if(p2==0)
	{
		if(p1<=p4+1)
			puts("Yes");
		else
			puts("No");
	}
	else
	{
		if(p1<=p4)
			puts("Yes");
		else
			puts("No");
	}
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


/**
 * 整数の集合 A と、整数 X が与えられる。
 * Aの部分集合 S に対して関数f(S)をSの全要素をexorした値と定義する。
 * X ^ f(S) の最大値を返す
 */
ll maxSubsetExor(vector<ll> A, ll X) {

  const int N = A.size();
  const int M = 62;

  auto at = [&](const ll Ai, const int j) -> int {
    return (Ai >> (M-j-1) & 1);
  };


  int s = 0;
  REP(j, M) {
    int p = -1;
    for (int i = s; i < N; i++) if (at(A[i], j)) { p = i; break; }
    if (p != -1) {
      swap(A[s], A[p]);
      for (int i = s+1; i < N; i++) if (at(A[i], j)) A[i] ^= A[s];
      s++;
    }
  }

  ll ans = X;
  s = 0;
  REP(j, M) {
    if (at(ans, j) == 0 && at(A[s], j)) ans ^= A[s];
    if (at(A[s], j)) s++;
  }

  return ans;
}

int main2() {
  int N; cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];

  ll S = 0;
  REP(i, N) S ^= A[i];

  REP(i, N) A[i] &= ~S;

  ll P = maxSubsetExor(A, 0);
  ll Q = S ^ P;

  cout << P + Q << endl;

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

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

    set<char> st;
    for (int i = 0; i < s.size(); i++) {
        st.insert(s[i]);
    }

    if (st.size() == s.size()) {
        cout << "yes" << endl;
    }
    else {
        cout << "no" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn check(a: String, b: String) -> String {
    if a == "unko" {
        b
    } else if a.len() > b.len() {
        a
    } else if a.len() < b.len() {
        b
    } else {
        std::cmp::max(a, b)
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..m)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let need: Vec<usize> = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6].to_vec();
    let mut dp: Vec<String> = vec!["unko".to_string(); n + 9];
    dp[0] = "".to_string();
    for i in 0..n {
        for &j in a.iter() {
            if dp[i] == "unko" {
                continue;
            }
            dp[i + need[j]] = check(dp[i + need[j]].clone(), dp[i].clone() + &j.to_string());
        }
    }
    println!("{}", dp[n]);
}

Measured memory_bytes: 59644
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": # "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

int main()
{
	vi prime(1,2);
	for(int i=3;prime.size()<=10000;i+=2){
		bool ok=true;
		for(int j=0;prime[j]*prime[j]<=i;j++){
			if(i%prime[j]==0){
				ok=false;
				break;
			}
		}
		if(ok)
			prime.push_back(i);
	}
	
	for(int n;cin>>n,n;)
		cout<<accumulate(prime.begin(),prime.begin()+n,0)<<endl;
	
	return 0;
}

Measured memory_bytes: 0
import java.util.Collections;
import java.util.ArrayList;
import java.util.*;
import java.util.regex.Pattern;  
import java.util.Scanner;  
import java.util.regex.Matcher; 
public class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		{
			String s=sc.nextLine();
			
				if((s.charAt(2)==s.charAt(3)) && (s.charAt(4)==s.charAt(5)))
				{
					System.out.println("Yes");
				}
				else
				{
					System.out.println("No");
					
				}
		
				
			
					
		     
		     }		
			
		
	}

	
	
	
}
		


Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <queue>

using namespace std;

int main()
{
    string s;
    cin >> s;
    string devide[] = {"dream", "dreamer", "erase", "eraser"};

    /* code */
    queue<int> bfs;
    bfs.push(0);

    while (!bfs.empty())
    {
        /* code */
        int a = bfs.front();
        bfs.pop();

        if (a == s.size())
        {
            cout << "YES" << endl;
            return 0;
        }

        for (string d : devide)
        {
            if (s.substr(a, d.size()) == d)
            {
                bfs.push(a + d.size());
            }
        }
    }

    cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
const int INF=1e9+5;
const int N=3000+5;
const int mod=998244353;

int n,s;

ll a[N];
ll dp[N][N];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>s;
	for(int i=1;i<=n;++i) cin>>a[i];
	for(int i=1;i<=n;++i){
		dp[i][a[i]]=i;
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=s;++j){
			if(j>=a[i]) dp[i][j]+=dp[i-1][j]+dp[i-1][j-a[i]];
			else dp[i][j]+=dp[i-1][j];
			dp[i][j]%=mod;
		}
	}	
	ll ans=0;
	for(int i=1;i<=n;++i) ans=(ans+dp[i][s])%mod;
	cout<<ans;
	return 0;
}


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

int main(){
    string S;
    cin>>S;
    int cnt = S.length();
    // cout<<cnt<<endl;
    if(S.at(cnt-1)=='s'){
        S = S+ "es";
    }
    else{
        S = S + "s";
    }
    cout<<S<<endl;
}

Measured memory_bytes: 3588
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans=INF;
    rep(i,max(X,Y)+1){
        chmin(ans,2*C*i+A*max((ll)0,X-i)+B*max((ll)0,Y-i));
    }
    cout << ans << endl;
}

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

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

    sort (a, a+n);
    int count = 0, check = a[0], ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == check) {
            count++;
            if (i == n - 1) {
                ans += count % 2;
            }
        } else {
            ans += count % 2;
            count = 1;
            check = a[i];
            if (i == n - 1) {
                ans += count % 2;
            }
        }
    }

    cout << ans << endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end());
    for (int i = 0; i < k; i++)
    {
        h.pop_back();
        if (i == n - 1) break;
    }
    ll ans = 0;
    for (int i = 0; i < h.size(); i++)
    {
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}

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

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  D(x)         cout << #x << " - " << x << endl;
  #define  D2(x)        cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]" << endl;
  #define  all(x)       (x).begin(), (x).end()
  #define  D2p(x)       cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << endl;
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 2e5 + 4;
  vi adj[maxn];
  vll counter(maxn);
  void dfs(int src,int parcount,int par=-1){
  	  counter[src] += parcount;
  	  for(int x:adj[src]){
			if(par == x)continue;
			else{
				dfs(x,counter[src],src);
			}
  	  }
  }	
  void solve(){
    int n,q;
    cin >> n >> q;
    for(int i=0;i<n-1;i++){
    	int a,b;
    	cin >> a >> b;
    	adj[a].push_back(b);
    	adj[b].push_back(a);
    } 
    while(q--){
    	int p,x;
    	cin >> p >> x;
    	counter[p]+=x;
    }
    dfs(1,0);
    for(int i=1;i<=n;i++){
    	cout << counter[i] << ' ';
    }	
  }

  int main(){
    IOS
    solve();
    cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 25072
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const ll MOD = 1e9 + 7;

ll power(ll x, ll e) {
  ll v = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) {
      v = v * x % MOD;
    }
    x = x * x % MOD;
  }
  return v;
}

ll inverse(ll x) {
  return power(x, MOD - 2);
}

vector<ll> fact, factInv;
void initFact(int N) {
  fact.resize(N + 1);
  factInv.resize(N + 1);
  fact[0] = 1;
  for (int i = 1; i <= N; i++) {
    fact[i] = fact[i - 1] * i % MOD;
  }
  factInv[N] = inverse(fact[N]);
  for (int i = N - 1; i >= 0; i--) {
    factInv[i] = factInv[i + 1] * (i + 1) % MOD;
  }
}

ll choose(int n, int k) {
  if (k > n) {
    return 0;
  } else {
    return fact[n] * factInv[k] % MOD * factInv[n - k] % MOD;
  }
}

ll f(ll pA, ll pB, ll N) {
  ll res = 0;
  ll qA = pA * inverse((pA + pB) % MOD) % MOD;
  ll qB = pB * inverse((pA + pB) % MOD) % MOD;
  for (int b = 0; b < N; b++) {
    ll e = 1;
    e = e * power(qA, N) % MOD;
    e = e * power(qB, b) % MOD;
    e = e * choose(N + b - 1, N - 1) % MOD;
    e = e * (N + b) % MOD;
    res = (res + e) %  MOD;
  }
  return res;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  initFact(300000);
  ll N, A, B, C;
  while (cin >> N >> A >> B >> C) {
    ll pA = A * inverse(100) % MOD;
    ll pB = B * inverse(100) % MOD;
    ll pC = C * inverse(100) % MOD;
    ll res = (f(pA, pB, N) + f(pB, pA, N)) % MOD * inverse((1 - pC + MOD) % MOD) % MOD;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;

const unsigned int LEN = 100005;

class P {
private:
    string name;
    unsigned int t;
public:
    void SetParam(string name1, unsigned int time) {
        name = name1;
        t = time;
    }
    // 残り時間を計算
    unsigned int remainTime(unsigned int time) {
        t -= time;
    }
    unsigned int getTime() {
        return t;
    }
    string getName() {
        return name;
    }
};

P Q[LEN];   // キュー
unsigned int head;   // キューの先頭の場所
unsigned int tail;   // キューの末尾＋ 1 の場所（最後の要素の隣）
unsigned int n;      // キューにいれるプロセスの数

void enqueue(P x) {
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return (x);
}

unsigned int min(unsigned int a, unsigned int b)
{
    return a < b ? a : b;
}

int main()
{
    unsigned int elaps = 0, c;
    unsigned int i;
    unsigned int q;  // クオンタム

    P u;

    cin >> n >> q;
    for (unsigned int i = 0; i < n; i++) {
        string name;
        unsigned int time;

        cin >> name;
        cin >> time;
        Q[i].SetParam(name, time);
    }
    head = 0; tail = n;

    /* シミュレーション */
    while ( head != tail ) { // キューに未完了のプロセスがある
        u = dequeue();      // キューの先頭のプロセスを取り出す
        c = min(q, u.getTime());
        u.remainTime(c);    // 残り時間
        elaps += c;         // 経過時間

        if ( u.getTime() > 0 ) {
            enqueue(u);     // クオンタムで終わらないプロセスをキューの末尾に追加
        }
        else {
            cout << u.getName() << " " << elaps << endl;
        }
    }
    return (0);
}


Measured memory_bytes: 7032
#include <bits/stdc++.h>
using namespace std;
int main() {
    long test=1;
    // cin>>test;
    while(test--)
    {
	long long n,m,i,j,a,b,c,d,ans=0;
	set<int> s1={1,3,5,7,8,10,12},s2={4,6,9,11},s3={2};
	cin>>a>>b;
	if((s1.count(a) && s1.count(b))||(s2.count(a) && s2.count(b)))
	cout<<"Yes";
	else cout<<"No";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
bool judge(string s){
    
    rep(i, 0, s.length()){
        if(!(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C'))return 0;
    }
    return 1;
}
main(){
    string S;
    int maxi = 0;
    cin >> S;
    rep(i,0,S.size())rep(j,i,S.size()){
        string str = S.substr(i, j-i+1);
        if(judge(str))maxi = max(maxi, j-i+1);
    }
    cout << maxi << endl;
    
}

Measured memory_bytes: 256