akhauriyash/Code-Regression huggingface dataset:
/**
*	created: 29.09.2020 00:15:26
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rrep(i,n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define len(x) ll(x.size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
using ll = long long;
using P = pair<int,int>;
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;
template<typename T> inline bool chmax(T &a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T> inline bool chmin(T &a, T b) {if (b < a) {a = b; return 1;} return 0;}
inline void print(P a) {cout << a.first << " " << a.second << endl;}
template<typename T> T bpow(T a, ll n) {T r(1); while(n) {if (n & 1) r *= a; a *= a; n >>= 1;} return r;}
struct faster_io {faster_io() {cin.tie(0); ios_base::sync_with_stdio(false);}} faster_io_;

// Segment Tree
// query : f[a,b), Ο(log(n))
template <typename X> struct SegTree {
    using F = function<X(X, X)>;
    int n; F f; const X ex; vector<X> dat;
    SegTree(int n_, F f_, X ex_) : n(),f(f_),ex(ex_),dat(n_*4, ex_) {
        int x = 1; while (n_ > x) {x *= 2;} n = x;
    }
    void set(int i, X x) {dat[i+n-1] = x; return;}
    void build() {
        rrep(k,n-1) dat[k] = f(dat[2*k+1], dat[2*k+2]);
        return;
    }
    void update(int i, X x) {
        i += n - 1; dat[i] = x; // subject to change
        while(i) {i = (i-1)/2; dat[i] = f(dat[i*2+1], dat[i*2+2]);}
        return;
    }
    X query(int a, int b) {return query_sub(a, b, 0, 0, n);}
    private:
    X query_sub(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return ex;
        else if (a <= l && r <= b) return dat[k];
        else {
            X vl = query_sub(a, b, k*2+1, l, (l+r)/2);
            X vr = query_sub(a, b, k*2+2, (l+r)/2, r);
            return f(vl, vr);
        }
    }
};
/*
    using X = int;
    auto f = [](X x1, X x2) -> X {return f(x1, x2);};
    X ex = identity element;
    SegTree<X> seg(n, f, ex); // declaration
*/

signed main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    using X = int;
    auto f = [](X x1, X x2) -> X {return max(x1,x2);};
    X ex = 0;
    SegTree<X> seg(300003, f, ex); // declaration
    rep(i,n) {
        int x = a[i];
        int l = max(x-k,0ll);
        int r = min(x+k+1,300003ll);
        int now = seg.query(l,r) + 1;
        seg.update(x,now);
    }
    cout << seg.query(0,300003) << endl;
    return 0;
}

Measured memory_bytes: 15084
#include<iostream>
#include<string>
#include<string>
#include<cstdio>
#include<math.h>
#include<map>
#include<set>
#include<queue>
#include<vector>

using namespace std;

int main()
{
	string s;
	string ans;
	cin >> s;
	int num = s.size() - 1;
	for (int i = 0; i < num; i++) {
		if ("AC" == s.substr(i, 2)) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X; cin >> X;
    X -= 400;
    cout << 8 - X/200 << endl;

    return 0;
}


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

using namespace std;

using ll = long long;

int main(){
    ll n; cin >> n;
    ll arr[9] = {0};
    for(ll i = 0; i < n; ++i){
        ll tmp; cin >> tmp;
        if(tmp <= 399){
            arr[0]++;
        }else if(tmp <= 799){
            arr[1]++;
        }else if(tmp <= 1199){
            arr[2]++;
        }else if(tmp <= 1599){
            arr[3]++;
        }else if(tmp <= 1999){
            arr[4]++;
        }else if(tmp <= 2399){
            arr[5]++;
        }else if(tmp <= 2799){
            arr[6]++;
        }else if(tmp <= 3199){
            arr[7]++;
        }else{
            arr[8]++;
        }
    }
    ll mini = 0, maxi = 0;
    for(ll i = 0; i < 8; ++i){
        if(arr[i] != 0){
            mini++;
        }
    }
    if(mini == 0)cout << 1 << " " << arr[8];
    else cout << mini << " " << arr[8] + mini;
    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);
		String W = sc.next().toLowerCase();
		int cnt = 0;
		
		while(sc.hasNext()){
			String T = sc.next().toLowerCase();
			if(T.equals(W)){
				cnt++;
			}
		}
		
		System.out.println(cnt);
	}

}

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

def calc(tmp, cnt=0):
    for i in a[1:]:
        if tmp < 0:
            tmp = tmp + i
            if tmp <= 0:
                cnt += -tmp + 1
                tmp = 1
        elif tmp > 0:
            tmp = tmp + i
            if tmp >= 0:
                cnt += tmp + 1
                tmp = -1
    return cnt

if a[0]:
    hugou = 1 if a[0] > 0 else -1
    print(min(calc(a[0]), calc(-hugou, abs(a[0]) + 1)))
else:
    print(min(calc(1, 1), calc(-1, 1)))


Measured memory_bytes: 14464
#include <iostream>
using namespace std;
int main() {
    long n, d, c = 0;
    cin >> n >> d;
    d = d * d;
    for (long i = 0; i < n; i++) {
        long x, y;
        cin >> x >> y;
        if (x * x + y * y <= d) {
            c++;
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 3632
use proconio::input;

fn main() {
    input! {
        x: isize,
        y: isize,
    }
    let mut count = 0;

    let sub = y.abs() - x.abs();

    if sub > 0  {
        if x < 0 {
            count += 1;
        }
        count += sub;
        if y < 0 {
            count += 1;
        }
    } else if sub < 0 {
        if x >= 0 {
            count += 1;
        }
        count -= sub;

        if y > 0 {
            count += 1;
        }
    } else {
        if x != y {
            count += 1;
        }
    }

    println!("{}", count);
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

long long int gcd(long long int a,long long int b){
    if(a<b){
        long long int tmp=a;
        a=b;
        b=tmp;
    }

    long long int r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

long long int lcm(long long int a,long long int b){
    long long int g = gcd(a,b);
    return (a/g)*b;
}


int main() {
    ll r;
    cin >> r;

    pl(3*r*r)

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int M[3], D[3], i;

    for(i=1; i<=2; i++){
        cin >> M[i] >> D[i];
    }

    if(D[2] == 1){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int cost(int arr[][3],int n){
    long long int dp[n][3];
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
    for(int i=1;i<n;i++){
       dp[i][0]=max(dp[i-1][1]+arr[i][0],dp[i-1][2]+arr[i][0]);
       dp[i][1]=max(dp[i-1][0]+arr[i][1],dp[i-1][2]+arr[i][1]);
       dp[i][2]=max(dp[i-1][0]+arr[i][2],dp[i-1][1]+arr[i][2]);
    }
    long long result=dp[n-1][0];
    for(int i=1;i<3;i++){
        result=max(result,dp[n-1][i]);
    }
    return result;
}
int main() {
	// your code goes here
	int n;
	cin>>n;
	int arr[n][3];
	for(int i=0;i<n;i++){
	    for(int j=0;j<3;j++){
	        cin>>arr[i][j];
	    }
	}
	long long int res=cost(arr,n);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back



/* do your best */

int main() {
  
  lint n; cin >> n;
  lint div = 10;
  lint ans = 0;
  if(n % 2) {
    cout << 0 << endl;
    return 0;
  }
  while(1) {
    if(div <= n) ans += n / div;
    else break;
    div *= 5;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int result = a+b;
		if (result >= 24) {
			result = result - 24;
			System.out.println(result);
		}
		else
			System.out.println(result);
	}
}


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

int abs(int a) {
  if (a<0) {return -a;}
  else {return a;}
}

int main() {
  int N, L; cin >> N >> L;
  int sum = 0;
  int mabs = 1000;
  int eaten;
  for (int i = 0; i < N; i++) {
    sum += (L+i);
    if (abs(L+i) < mabs) {
      mabs = abs(L+i);
      eaten = i;
    }
  }
  cout << sum-(L+eaten) << endl;
}
  

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using long_t = int64_t;

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

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

		int sum = 0;
		for( int a = 1; a <= K; ++a ) {
			for( int b = 1; b <= K; ++b ) {
				for( int c = 1; c <= K; ++c ) {
					sum += gcd( gcd( a, b ), c );
				}
			}
		}

		cout << sum << endl;
	}

	static int gcd( int a, int b ) { return b ? gcd( b, a%b ) : a; }
};

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


Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    reverse(all(a));
    int dp[n+1];
    fill(dp,dp+n,inf);
    rep(i,n){
        *upper_bound(dp,dp+n,a[i])=a[i];
    }
    cout<<lower_bound(dp,dp+n,inf)-dp<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
int main(){
  string word;
  int num;
  map<string,vector<int> > index;
  while(cin >> word >> num){
    index[word].push_back( num );
  }

  for(map< string,vector<int> > ::iterator it = index.begin(); it != index.end() ; it++){
    vector<int>ve;
    ve = it->second;
    sort(ve.begin(),ve.end());
    cout << it->first << endl;
    for(vector<int>::iterator itt = ve.begin() ; itt != ve.end() ; itt++){
      if(ve.begin() == itt)cout << *itt;
      else  cout <<" "<< *itt;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include<stdio.h>
int main()
{
    long long int a,b,k;
    scanf("%lld%lld%lld",&a,&b,&k);

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


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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);
    for (int i = 0; i < h; i++) {
        cin >> c[i];
    }

    int pat = 0;
    for (int maskR = 0; maskR < (1 << h); maskR++) {
        for (int maskC = 0; maskC < (1 << w); maskC++) {
            int count = 0;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if ((1 & maskR>>i) && (1 & maskC>>j) && c[i][j] == '#') {
                        count++;
                    }
                }
            }
            if (count == k) {
                pat++;
            }
        }
    }

    cout << pat << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define pb push_back
#define mp make_pair
#define F first
#define S1 second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define mod 1e9+7
#define P(a,b) pair<a,b>
#define CIN(V,s,n) for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n) for(int i=s;i<n;i++){cout <<  V[i] << " ";}

using namespace std;
ll up(vector<vector<char> > &G,ll r,ll c,ll m)
{
    ll n = G.size();
    if(r>=0 && c >=0 && r < n && c < m)
    {
        if(G[r][c]=='*')
            return (1 + up(G,r,c-1,m));
        else
            return 0;
    }
    else
        return 0;
}
ll down(vector<vector<char> > &G,ll r,ll c,ll m)
{
    ll n = G.size();
    if(r>=0 && c >= 0 && r < n && c < m)
    {
        if(G[r][c]=='*')
            return (1 + down(G,r,c+1,m));
        else
            return 0;
    }
    else
        return 0;
}
ll left(vector<vector<char> > &G,ll r,ll c,ll m)
{
    ll n = G.size();
    if(r>=0 && c >= 0 && r < n && c < m)
    {
        if(G[r][c]=='*')
            return (1 + left(G,r-1,c,m));
        else
            return 0;
    }
    else
        return 0;
}
ll right(vector<vector<char> > &G,ll r,ll c,ll m)
{
    ll n = G.size();
    if(r>=0 && c >= 0 && r < n && c < m)
    {
        if(G[r][c]=='*')
            return (1 + right(G,r+1,c,m));
        else
            return 0;
    }
    else
        return 0;
}
void is_star(vector<vector<char> > &G,vector<pair<ll , pair<ll ,ll > > > &S,ll r,ll c,ll m)
{
    ll u = up(G,r,c-1,m);
    ll d = down(G,r,c+1,m);
    ll l = left(G,r-1,c,m);
    ll r1 = right(G,r+1,c,m);

    if(u==d && d==l && l==r1 && d!=0)
    {
        for(ll i=1;i<=u;i++)
        {
            S.pb(mp(r+1,mp(c+1,i)));
        }
    }
}
void find_stars(vector<vector<char> > &G,vector<pair<ll , pair<ll ,ll > > > &S,ll m)
{
    ll n = G.size();
    for(ll i=1;i<n-1;i++)
    {
        for(ll j=1;j<m-1;j++)
        {
            if(G[i][j]=='*')
                {
                    //cout <<i << " " << j << endl;
                    is_star(G,S,i,j,m);
                }
        }
    }
}

int main()
{
	ll n,m,i,j,k,l,w,s,u,v,count0=0;
	cin >> n ;
	vector<ll> V(n);
	CIN(V,0,n);

	ll sum=0;
	for(i=0;i<n;i++)
        sum += V[i];
    ll t_sum=0,dif=1e9;
    vector<ll> dif1(n);
    for(i=0;i<n;i++)
    {
        t_sum += V[i];
        dif1[i] = abs((sum-t_sum) - t_sum);
    }

    sort(all(dif1));
    cout << dif1[0];
    return 0;
}


Measured memory_bytes: 256
k = int(input())

L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(L[k-1])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s;
    cin >> s;
    int cnt = 0;
    for(int i=0; i<s.length(); i++) {
        if(s[i]=='o') cnt++;
    }
    cout << 700 + 100*cnt << endl;
    return 0;
}



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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))


int main()
{
    int i,j,a,b,m;

    cin >> a >> b;
    bool ok = false;

    for(i=1; i<=10000; i++)
    {
        j = (i*8)/100;
        m = (i*10)/100;
        if(j==a && m==b)
        {
            ok = true;
            break;
        }
    }

    if(ok)
        cout << i <<endl;
    else
        cout<<-1<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>

int main(){

    size_t n;
    std::cin >> n;

    size_t x = 0, y = 0;
    for(size_t i = 0; i < n; i++){
        std::string s, t;
        std::cin >> s >> t;

        if(s > t){
            x += 3;
        }else if(s < t){
            y += 3;
        }else{
            x++;
            y++;
        }
    }

    std::cout << x << ' ' << y << std::endl;

    return 0;
}



Measured memory_bytes: 3216
S=input()
ans=0
if len(S)-1==0:
    print(int(S))
    quit()
for i in range(2**(len(S)-1)):
    k=bin(i)[2:].zfill(len(S)-1)
    l=int(S[0])
    for j in range(len(k)):
        t=int(k[j])
        if t==1:
            ans+=l
            l=int(S[j+1])
        else:
            l=l*10+int(S[j+1])
    ans+=l
print(ans)


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

int main() {
  string op;
  int a , b ;
  cin >> a ;
  cin >> op ;
  cin >> b ;
  if (op =="+")
    cout << a+b << endl;
  else
    cout << a-b << endl;


   }
     

  // ここにプログラムを追記


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int main() {
	int H, W; cin >> H >> W;
	int h, w; cin >> h >> w;
	cout << (H * W) - (H * w) - (W * h) + h * w << endl;
}


Measured memory_bytes: 256
#include<stdio.h>


int main(void)
{
	int fib[100];
	int n,i, j, k, l = 0;

	scanf("%d", &n);

	fib[0] = 1;
	fib[1] = 1;

	for (i = 2;i <= n;i++) {

		fib[i] = fib[i - 1] + fib[i - 2];
		
	}

	printf("%d\n", fib[n]);
	

	return 0;
}
 



Measured memory_bytes: 2072
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
main()
{
	string s;
	cin>>s;
	
	int n=s.length(),d;
	cin>>d;
	
	vector<vector<long long>> dp(d,vector<long long> (2));
	dp[0][1]=1;
	
	for(int i=0;i<n;i++)
	{
		vector<vector<long long>> new_dp(d,vector<long long> (2));
		for(int j=0;j<d;j++)
		{
			for(int k=0;k<10;k++)
			{
				new_dp[(j+k)%d][0]=(new_dp[(j+k)%d][0]+dp[j][0])%MOD;
			}
		}
		
		for(int j=0;j<d;j++)
		{
			for(int k=0;k<s[i]-'0';k++)
			{
				new_dp[(j+k)%d][0]=(new_dp[(j+k)%d][0]+dp[j][1])%MOD;
			}
		}
		
		for(int j=0;j<d;j++)
		{
			new_dp[(j+s[i]-'0')%d][1]=(new_dp[(j+s[i]-'0')%d][1]+dp[j][1])%MOD;
		}
		
		dp=new_dp;
	}
	
	long long ans=(dp[0][0]+dp[0][1]-1+MOD)%MOD;
	
	cout<<ans<<endl;
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===



int dp[5000];



int main()
{
	int N, M;
	cin >> N >> M;

	Vi a(M), b(M);
	Vi c(M);
	for (int i = 0; i < M; ++i) {
		cin >> a[i] >> b[i];
		for (int j = 0; j < b[i]; ++j) {
			int tmp;
			cin >> tmp;
			--tmp;
			c[i] |= (1 << tmp);
		}
	}

	for (int i = 0; i < 5000; ++i) {
		dp[i] = I_INF;
	}
	dp[0] = 0;

	int d = (1 << N) - 1;

	for (int i = 0; i < M; ++i) {
		for (int mask = 0; mask <= d; ++mask) {
			if (dp[mask] != I_INF) {
				dp[mask | c[i]] = min(dp[mask | c[i]], dp[mask] + a[i]);
			}
		}
	}

	if (dp[d] == I_INF) {
		cout << -1 << endl;
	}
	else {
		cout << dp[d] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

/*小数点以下の長さを指定
cout << fixed << setprecision(15) << y << endl;
*/

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}


int main() {
	string s;
	cin >> s;
	string Heisei = "Heisei";
	string TBD = "TBD";
	if (s[5] == '0'){
		if (s[6] == '1' || s[6] == '2' || s[6] == '3' || s[6] == '4'){
			cout << Heisei << endl;
		}
		else cout << TBD << endl;
		return 0;
	}
	else cout << TBD << endl;

	return 0;
}




Measured memory_bytes: 3512
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define DIVCEIL(A,B) ((A+(B-1))/B)
using namespace std;


void solve(long long N, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    int a=0, b=0, c=0;
    long long acc=0l;
    vector<long long> l1(N,0);
    vector<long long> l2(N,0);
    while(b<N){
        if(a<N && A[a] < B[b]){
            acc++;
            a++;
        }else{
            l1[b] = acc;
            b++;
        }
    }
    b=0; c=0; acc=0;
    while(c<N){
        if(b<N && B[b] < C[c]){
            acc+=l1[b];
            b++;
        }else{
            l2[c] = acc;
            c++;
        }
    }
    cout << accumulate(l2.begin(), l2.end(), 0l) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    std::vector<long long> C(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&C[i]);
    }
    solve(N, std::move(A), std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 4224
import java.util.Scanner;

public class Main 
{
	static boolean isPrime(int x)
	{
		if(x == 2)return true;
		for(int i = 2; i*i <= x; i++)
		{
			if(x%i == 0)return false;
		}
		return true;
	}

	public static void main(String[] args) 
	{
		Scanner scan = new Scanner(System.in);
		
		while(true)
		{
			int n = scan.nextInt();
			if(n == 0)break;
			int ans = 0;
			
			for(int i = n+1; i <= 2*n; i++)
			{
				if(isPrime(i)){ans += 1;}
			}
			
			System.out.println(ans);
		}
	}

}



Measured memory_bytes: 27692
#include <bits/stdc++.h>
#define ll long long 
#define all(v) v.begin() , v.end()
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define tr(con) for(auto it = con.begin(); it!= con.end() ; it++)
#define INF 1e9+7   // 1 * 10^9+ 7
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define fo(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n; cin >> n ;
	ll h[n+1];
	h[0]  = 0;
	rep(i,1,n) cin >> h[i];
	ll val[n+1];
	val[0]=  0;
	val[1] = 0;
	val[2]= abs(h[2]-h[1]);
	rep(i,3,n){
		val[i] = min(val[i-2] + abs(h[i] - h[i-2]) , val[i-1] +abs(h[i]-h[i-1]) );
	}
	cout << val[n];
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    int L[N];
    REP(i, N) cin >> L[i];

    int s = 0;
    REP(i, N) s += L[i];

    REP(i, N) {
        if (s - L[i] <= L[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# B - Some Sums
# 標準入力の取得
N,A,B = list(map(int, input().split()))

# 1～Nまで全探索
answer = 0
for n in range(1, N+1):
    digit_sum = sum(list(map(int, str(n))))
    if A <= digit_sum and digit_sum <= B:
        answer += n

# 結果出力
print(answer)


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

int main() {
int n,l,b,a,s=0;
string p="Impossible";
cin>>n>>l>>b;
for(int i=1;i<n;i++){
    cin>>a;
    if(a+b>=l){
        p="Possible";
        s=i;
        i=n;
    }
    b=a;
}
cout<<p<<endl;
if(s>0){
    for(int i=1;i<s;i++){
        cout<<i<<endl;
    }
    for(int i=n-1;i>s;i--){
        cout<<i<<endl;
    }
    cout<<s<<endl;
}
	return 0;
}

Measured memory_bytes: 768
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include <random>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n;
  scanf("%d",&n);
  string s;
  cin >> s;
  vi a(n);
  rep(i,n) a[i] = s[i]=='o';
  rep(si,2)rep(ti,2) {
    vi b(n);
    b[0] = si; b[1] = ti;
    rep(i,n) {
      int j = (i+1)%n;
      b[(i+2)%n] = b[i]^b[j]^a[j];
    }
    if (b[0] == si && b[1] == ti) {
      string ans;
      rep(i,n) ans += "WS"[b[i]];
      cout<<ans<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}






















Measured memory_bytes: 1408
import sys


def main():
  n, m, *lst = map(int, sys.stdin.read().split())
  set1, setn = set(), set()
  for i, j in zip(*[iter(lst)] * 2):
    if i == 1:
      set1.add(j)
    if j == n:
      setn.add(i)
  print('POSSIBLE' if set1 & setn else 'IMPOSSIBLE')


if __name__ == '__main__':
  main()

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

int main(){
	int x, y;
	cin >> x >> y;
	if (x%y == 0) {
		cout << -1 << endl;
	}
	else {
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

ll f(ll a, ll b) {
    if (a == 0) {
        ll res = 0;
        rep(i, 45) {
            ll loop = (b + 1) / (1ll << (i + 1));
            ll rem = max(0ll, (b + 1) % (1ll << (i + 1)) - (1ll << i));
            ll bit = (loop * (1ll << i) + rem) % 2;
            res |= bit << i;
        }
        return res;
    }

    return f(0, a - 1) ^ f(0, b);
}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << f(a, b) << endl;
}

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

using namespace std;
long long A[4000];
long long g[4000][4000]; //g[i][j]でg_iのx^jの係数を覚える


int main(){
    int N;
    int S;
    cin >> N >> S;
    for(int i=0; i<4000; i++){
        for(int j=0; j<4000;j++){
            g[i][j]=0;
        }
    }
    for(int i=1; i<=N; i++){
        cin >> A[i];
    }
    long long mod=998244353;
//g[0][j]=0
//g[i+1](x) = (1+x^A[i+1])(1+g[i](x))
//g[i+1][0]++
//g[i+1][j]+=g[i][j]
//g[i+1][A[i+1]]++
//g[i+1][j]+=g[i][j-A[i+1]]
//
    for(int i=1; i<=N; i++){
        g[i][0]++;
        g[i][A[i]]++;
        for(int j=0; j<=S; j++){
            g[i][j]+=g[i-1][j];
            if(j>=A[i]){
                g[i][j]+=g[i-1][j-A[i]];
            }
            g[i][j]%=mod;
        }
    }
/*
    for(int i=1; i<=N; i++){
        for(int j=0; j<=S; j++){
            cout << g[i][j] << " " ;
        }
        cout << endl;
    }
*/
    long long ans=0;
    for(int i=0; i<N; i++){
        ans +=g[i+1][S];
    }
    cout << ans%mod << endl;
}

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

using namespace std;

int main(void){
    string s;

    cin >> s;
    int n = s.length();
    int a = 0;
    int b = 0;

    for(int i = 0; i < n; i++){
        if(s[i] == '0') a++;
        if(s[i] == '1') b++;
    }

    cout << 2 * min(a, b) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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

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

	string s; cin>>s;
	s+='0';
	if(s[0]=='9'||s[1]=='9') cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 256
while l = gets
    str = l.chomp
    26.times do |i|
        decode = ""
        str.each_char.with_index do |ch|
            if ch.match(/[a-z]/)
                if ch.ord + i > 'z'.ord
                    decode += (ch.ord + i - 26).chr
                else
                    decode += (ch.ord + i).chr
                end
            else
                decode += ch
            end
        end
        if decode =~ /the|this|that/
            puts decode
        end
    end
end



Measured memory_bytes: 7364
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  int *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);

  A = (int *)malloc(sizeof(int)*n);
  B = (int *)malloc(sizeof(int)*n);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

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

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 16276
import java.util.Scanner;
import java.text.*;
public class Main {
	public static void main(String[] args) {
		NumberFormat format = NumberFormat.getInstance();
		format.setMaximumFractionDigits(8);
		Scanner scan = new Scanner(System.in);
		long a=Integer.parseInt(scan.next());
		long b=Integer.parseInt(scan.next());
		System.out.print(a/b+" "+a%b);
		double f = (double)a/b;
		System.out.println(" "+String.format("%8f",f));
		scan.close();
	}
}

Measured memory_bytes: 17264
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define MOD 1000000007

using namespace std;

ll powa(ll x, ll y, ll z)
{
    x%=z;
    ll res = 1;
    while(y>0)
    {
        if(y&1)
            res = (x*res)%z;
        x*=x;
        x%=z;
        y>>=1;
    }
    
    return res;
    
}

ll fact[300000];

ll ncr(ll n, ll r)
{
    if(r>n)
        return 0;
    if(r == 0)
        return 1;
    ll temp = fact[n];
    //cout<<n<<"! = "<<temp<<"\n";
    //cout<<r<<"! = "<<fact[r]<<"\n";
    temp*=powa((fact[r]*fact[n-r])%MOD,MOD-2,MOD);
    temp%=MOD;
    //cout<<n<<" C "<<r<<" = "<<temp<<"\n";
    return temp;
}

ll nc2(ll n)
{
    ll temp = (n)*(n-1);
    temp/=2;
    return temp%MOD;
}

int main()
{
   FAST/**/
   fact[0] = 1;
   for(ll i=1;i<300000;i++)
        fact[i] = (fact[i-1]*i)%MOD;
   
   ll n,m,k;
   cin>>n>>m>>k;
   
   ll ans = 0;
   
   for(ll i=1;i<=n;i++)
   {
       for(ll j=1;j<=m;j++)
       {
           ll temp = ncr(n*m-2,k-2);
           //cout<<"temp = "<<temp<<"\n";
           ll temp1 = (nc2(i)*(j-1)) + nc2(j)*(i-1) + nc2(i)*(m-j) + nc2(m-j+1)*(i-1) + nc2(n-i+1)*(j-1) + nc2(j)*(n-i) + nc2(n-i+1)*(m-j) + nc2(m-j+1)*(n-i);
           //cout<<"at "<<i<<" , "<<j<<" val = "<<temp1<<"\n";
           temp1%=MOD;
           temp1+=nc2(i) + nc2(n-i+1) + nc2(j) + nc2(m-j+1);
           temp1%=MOD;
           //temp1-=(m*j+n*i)%MOD;
           //temp1%=MOD;
           if(temp1<0)
                temp1+=MOD;
           ans+=(temp*temp1)%MOD;
           ans%=MOD;
           
       }
   }
   
   ans*=powa(2,MOD-2,MOD);
   ans%=MOD;
   cout<<ans;
   
   return 0;
}

Measured memory_bytes: 2560
import sys
readline = sys.stdin.readline

DIV = 998244353
N,S = map(int,readline().split())
A = list(map(int,readline().split()))

# ある数の取り得る状態は以下
# (1)部分集合Pに含まれない
# (2)部分集合Pに含まれ、和に使われている
# (3)部分集合Pに含まれ、和に使われていない

# dp[j][k] = 部分集合Pに含まれ(j)、総和がkになっている場合の数
dp = [[0] * (S + 1) for j in range(2)]
dp[0][0] = 1

for i in range(N):
  nextline = [[0] * (S + 1) for j in range(2)]
  for k in range(S, -1, -1):
    # (1)部分集合Pに含まれない
    nextline[0][k] += dp[0][k]
    nextline[0][k] += dp[1][k]
    nextline[0][k] %= DIV

    # (2)部分集合Pに含まれ、和に使われている
    if k + A[i] <= S:
      nextline[1][k + A[i]] += dp[0][k]
      nextline[1][k + A[i]] += dp[1][k]
      nextline[1][k + A[i]] %= DIV

    # (3)部分集合Pに含まれ、和に使われていない
    nextline[1][k] += dp[0][k]
    nextline[1][k] += dp[1][k]
    nextline[1][k] %= DIV
    
  dp = nextline

print((dp[0][-1] + dp[1][-1]) % DIV)


Measured memory_bytes: 91452
#include <bits/stdc++.h>
#define N 100005

using namespace std;

int v[N], ap[N];

int main()
{
    int n, rez, cm1, cm2, cv1, cv2, om1, om2, ov1, ov2;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        scanf("%d", &v[i]);
    for(int i = 0; i < n; i += 2)
        ap[v[i]]++;
    cm1 = cm2 = 0;
    cv1 = -1;
    cv2 = -2;
    for(int i = 0; i < N; i++)
    {
        if(ap[i] >= cm1)
        {
            cm2 = cm1;
            cv2 = cv1;
            cm1 = ap[i];
            cv1 = i;
        }
        else if(ap[i] >= cm2)
        {
            cm2 = ap[i];
            cv2 = i;
        }
        ap[i] = 0;
    }
    om1 = cm1;
    om2 = cm2;
    ov1 = cv1;
    ov2 = cv2;

    for(int i = 1; i < n; i += 2)
        ap[v[i]]++;
    cm1 = cm2 = 0;
    cv1 = -1;
    cv2 = -2;
    for(int i = 0; i < N; i++)
    {
        if(ap[i] >= cm1)
        {
            cm2 = cm1;
            cv2 = cv1;
            cm1 = ap[i];
            cv1 = i;
        }
        else if(ap[i] >= cm2)
        {
            cm2 = ap[i];
            cv2 = i;
        }
    }

    if(cv1 != ov1)
        rez = n - cm1 - om1;
    else rez = min(n - cm1 - om2, n - cm2 - om1);
    printf("%d", rez);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define fr(i,x,y) for(int i=(x);i<=(y);i++)
#define rf(i,x,y) for(int i=(x);i>=(y);i--)
#define frl(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;
const int N=500005;
int n,m,a[N];
char c[N];

ll cal(int x){ return 1LL*(1+x)*x/2; }

int main(){
	scanf("%s",c+1);
	n=strlen(c+1);
	fr(i,1,n){
		int j=i;
		for(;j<n&&c[j+1]==c[i];j++);
		a[++m]=j-i+1;
		i=j;
	}
	ll ans=0;
	if (c[1]=='>') ans+=cal(a[1]);
	for(int i=c[1]=='>'?2:1;i<=m;i+=2){
		ans+=cal(max(a[i],a[i+1]));
		ans+=cal(min(a[i],a[i+1])-1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1664
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
// #include <atcoder/all>

#define REPI(i, S, N) for(int i=int(S); i<int(N); i++)
#define REP(i, N) REPI(i, 0, N)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
// using mint = atcoder::modint1000000007;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

ll mpow(ll a, ll b) {
  ll tmp = (b % 2) ? a : 1;
  return (b ? tmp * mpow((a * a) % 1000000007, b / 2) % 1000000007 : 1);
}

auto solve() {
  in<ll> N;
  
  ll all = mpow(10, N), na = mpow(9, N);
  
  return (((((all + 1000000007 - na) % 1000000007) + 1000000007 - na) % 1000000007) + mpow(8, N))  % 1000000007;
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 3616
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;
struct Info{
	int l, r;
	inline bool operator <(const Info &x) const {
		return r == x.r ? l < x.l : r > x.r;
	}
}tk[200007];
multiset<Info> S;
multiset<Info>::iterator it;
inline bool Cmp(const Info &a, const Info &b){
	return a.l == b.l ? a.r < b.r : a.l > b.l;
}
int fastin(){
	register int i; register char ch;
	while (ch = getchar(), ch < '0' || ch > '9');
	i = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9') i = i * 10 + ch - '0';
	return i;
}
int main(){
	register int n, m, i, t, lim, ans, cnt;
	n = fastin(), m = fastin();
	for (i = 1; i <= n; ++i) {
		tk[i].l = fastin();
		tk[i].r = fastin();
	}
	sort(tk + 1, tk + n + 1, Cmp);
	t = tk[1].l;
	lim = 0;
	for (i = 1; t; --t) {
		while (i <= n && tk[i].l >= t) S.insert(tk[i++]);
		if (S.size()) {
			S.erase(S.begin());
			++lim;
		}
	}
	cnt = 0;
	for (; i <= n; ++i) tk[++cnt] = tk[i];
	for (it = S.begin(); it != S.end(); ++it) tk[++cnt] = *it;
	if (cnt == 0) {
		puts("0");
		return 0;
	}
	sort(tk + 1, tk + cnt + 1);
	ans = 0;
	for (t = m, i = 1; i <= cnt && t > lim; ++i) {
		if (tk[i].r <= t) --t;
		else ++ans;
	}
	if (i <= cnt) ans += cnt - i + 1;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 11136
N = int(input())
MOD = 10 ** 9 + 7

dp = [[[[0 for i in range(4)] for j in range(4)] for k in range(4)] for l in range(N+1)]
dp[0][3][3][3] = 1

for n in range(N):
    for a in range(4):
        for b in range(4):
            for c in range(4):
                if dp[n][a][b][c] == 0:
                    continue
                
                for l in range(4):
                    if l == 2 and a == 1 and b == 0:
                        continue
                    if l == 2 and a == 0 and b == 1:
                        continue
                    if l == 1 and a == 2 and b == 0:
                        continue
                    if l == 2 and a == 1 and c == 0:
                        continue
                    if l == 2 and b == 1 and c == 0:
                        continue

                    dp[n+1][l][a][b] += dp[n][a][b][c]
                    dp[n+1][l][a][b] %= MOD

ans = 0
for a in range(4):
    for b in range(4):
        for c in range(4):
            ans += dp[N][a][b][c]
            ans %= MOD
    
print(ans)

Measured memory_bytes: 3312
#include "bits/stdc++.h"
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 

#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
//const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

const int mod = 998244353;

struct dsu{
	int parent[N];
	void make_set(int v){
		parent[v] = v;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);
		if(a != b)
			parent[b] = a;
	}
};


//~ vector< vector<int> > edge;
//~ int main(){
	//~ int n, m; cin >> n >> m;
	//~ for(int i = 1; i <= m; i++){
		//~ int w, u, v; cin>> w >> u >> v;
		//~ edge.push_back({w,u,v});
	//~ }
	//~ sort(edge.begin(), edge.end());
	//~ vector< vector<int> > ans;
	//~ dsu d;
	//~ d.make_set(n);
	//~ for(int i = 0; i < (int)edge.size(); i++){
	//~ for(int i = 0; i < 1; i++){
		//~ int u = edge[i][1];
		//~ int v = edge[i][2];
		//~ int x = d.find_set(u);
		//~ int y = d.find_set(v);
		//~ cout<< x<<" "<<y<<endl;
		//~ if(u != v){
			//~ d.union_sets(u, v);
			//~ ans.push_back(edge[i]);
		//~ }
	//~ }
	
	//~ for(int i = 0; i < (int) edge.size(); i++){
		//~ cout<< ans[i][0]<<" "<<ans[i][1]<<" "<<ans[i][2]<<endl; 
	//~ }
	//~ return 0;
//~ }
 
		

int main(){
	int n; cin>>n;
	string s; cin>> s;
	if(n%2 != 0){
		cout<<"No";
		return 0;
	}
	bool ok = true;
	int k = (int)s.size()/2;
	for(int i = 0; i < (int)s.size()/2; i++,k++){
		
		if(s[i] != s[k])
			ok = false;
	}
	if(ok)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 256