akhauriyash/Code-Regression huggingface dataset:
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static int MOD = 1000000007;

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final String s = scanner.nextLine();

        final int[][] table = new int[s.length()][13];

        {
            final char c = getReverseIndex(s, 0);
            if (isNum(c)) {
                final int num = getNum(c);
                final int num2 = (num + 8) % 13;
                table[0][num2] = 1;
            } else {
                for (int i = 0; i < 10; i++) {
                    final int num2 = (i + 8) % 13;
                    table[0][num2] = 1;
                }
            }
        }

        for (int i = 1; i < s.length(); i++) {
            final char c = getReverseIndex(s, i);
            if (isNum(c)) {
                final int i1 = intPow(i) * getNum(c) % 13;
                for (int j = 0; j < 13; j++) {
                    table[i][(j + i1) % 13] = (table[i][(j + i1) % 13] + table[i - 1][j]) % MOD;
                }
            } else {
                for (int k = 0; k < 10; k++) {
                    final int i1 = intPow(i) * k % 13;
                    for (int j = 0; j < 13; j++) {
                        table[i][(j + i1) % 13] = (table[i][(j + i1) % 13] + table[i - 1][j]) % MOD;
                    }
                }
            }
        }

        System.out.println(table[s.length() - 1][0]);
    }

    private static int intPow(final int b) {
        int c = b % 6;
        return (int) Math.pow(10, c);
    }

    private static int getNum(final char c) {
        return c - '0';
    }

    private static boolean isNum(final char c) {
        return c >= '0' && c <= '9';
    }

    private static char getReverseIndex(final String s, final int index) {
        return s.charAt(s.length() - index - 1);
    }
}


Measured memory_bytes: 34508
s=input()
l=len(s)
 
dp=[[0 for j in range(13)] for i in range(l+1)]
dp[0][0]=1
 
for i in range(l):
    st = s[i]
    if st =='?':
        for j in range(10):
            for k in range(13):
                dp[i+1][(10*k+j)%13] += dp[i][k]
                dp[i+1][(10*k*+j)%13] %= 10**9+7
    else:
        for k in range(13):
            dp[i+1][(10*k+int(st))%13] += dp[i][k]
            dp[i+1][(10*k*+int(st))%13] %= 10**9+7
 
print(dp[l][5]%(10**9+7))

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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);

#define endl "\n";


#define mod 1000000007
#define loop(i,s,n)  for(ll i=s;i<n;i++)
#define test  ll t; cin>>t; while(t--)
#define p push_back
typedef long long ll;
int main()
{
ll n,i,j,k,count=0,sum=1;
cin>>n;
ll a[n]={0};
string s;
for(i=1;i<=n-1;i++)
{count+=(n-1)/i;}
cout<<count;




    return 0;
}




Measured memory_bytes: 11400
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
    int n[12]={1,3,1,2,1,2,1,1,2,1,2,1};
    int a,b;
    cin>>a>>b;
    if(n[a-1]==n[b-1])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{	
	int a, b, ans, i;
	cin >> a >> b;
	ans = -1;
	for(i = 0; i < 1e9; i++){
		if(abs(a-i) == abs(b-i)){
			ans = i;
			cout << ans << endl;
		}
	}
	if(ans == -1) cout << "IMPOSSIBLE" << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
    int N;
    cin>>N;
    vector<char>A(N);
    int cnt=0;
    int ans=0;
    rep(i,N){
        cin>>A[i];
        if(A[i]=='D'){
            cnt--;
        }
        else{
            cnt++;
        }
        if(ans<cnt){
            ans=cnt;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vs>		vvs;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	int A, B, K;
	cin >> A >> B >> K;

	vi cand;
	for (int i = 1; i <= min(A, B); i++)
		if (A % i == 0 && B % i == 0)
			cand.push_back(i);

	cout << cand[cand.size() - K] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/*typedef struct event{
    ll sta, pp, x;
    event(ll s,ll t,ll X){
        sta = s;
        pp = t;
        x = X;
    };
}event;*/
int main() {
    ll Q;
    cin>>N>>Q;
    ll s,t,x;
    priority_queue<vec, mat, greater<vec> > pque;
    rep(i,N){
        cin>>s>>t>>x;
        pque.push(vec{x-t,2,x});
        pque.push(vec{x-s,1,x});
    }
    rep(i,Q){
        cin>>x;
        pque.push(vec{-x,0,i});
    }
    vector<ll> ans(Q,0);
    set<ll> stop;
    while(!pque.empty()){
        vec e = pque.top();
        pque.pop();
        if(e[1] == 0){
            ans.at(e[2]) = (stop.empty() ? -1 : *stop.begin());
        }else if(e[1] == 2){
            stop.insert(e[2]);
        }else{
            stop.erase(e[2]);
        }
        //cout<<stop.size()<<endl;
    }
    rep(i,Q) cout<<ans.at(i)<<endl;
}

Measured memory_bytes: 42920
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    ll n;
    cin>>n;
    if (n==0)
        cout<<"0\n";
    else
    {
        string s="";
        while (n)
        {
            if (n%2==1 || n%2==-1)
            {
                n--;
                s+='1';
            }
            else
                s+='0';
            n/=-2;
        }
        reverse(s.begin(),s.end());
        cout<<s<<endl;
    }
}

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

int main() {
    int n;
    cin >> n;
    vector<int> S(n);
    for (int i = 0; i < n; i++) {
        cin >> S.at(i);
    }
    int q;
    cin >> q;
    vector<int> T(q);
    for (int i = 0; i < q; i++) {
        cin >> T.at(i);
    }

    int ans = 0; 
    for (int t = 0; t < q; t++) {
        for (int s = 0; s < n; s++) {
            if (T.at(t) == S.at(s)) {
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    int i;
    int sum=0, avr, ans=0;
    int n;
    scanf("%d", &n);
    int x[n];
    for ( i=0; i<n; i++ ) {
        scanf("%d", &x[i]);
        sum += x[i];
    }
    avr = (int)round((double)sum/n);

    for ( i=0; i<n; i++ )
        ans += (x[i]-avr)*(x[i]-avr);
    printf("%d\n", ans);
    return EXIT_SUCCESS;
}


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

int main() {
	// your code goes here
	long long int a,b,c,d;
	long long int ans;
	
	cin>>a>>b>>c>>d;
	
	if((a*b) > (c*d))
	    cout<<a*b;
	else
	    cout<<c*d;
	
	return 0;
}


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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;

ll gcd(ll a, ll b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b; 
    if (a < b) swap(a,b);
    if (b == 0) return a;
    return a%b == 0 ? b : gcd(b, a%b);
}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<pair<ll,ll>> d;
    int zero = 0;
    for (int i=0;i<N;i++){
        ll a, b;
        cin >> a >> b;
        if (a == 0 && b == 0) zero++;
        else d.emplace_back(a,b);
    }
    map<pair<ll,ll>,pair<int,int>> mp;
    for (int i=0;i<d.size();i++){
        ll g = gcd(d[i].first,d[i].second);
        pair<ll,ll> p = make_pair(d[i].first/g,d[i].second/g);
        if (p.second < 0) {
            p.first = - p.first;
            p.second = - p.second;
        }
        if (p.second == 0 && p.first < 0) {
            p.first = - p.first;
        }
        bool rot = false;
        if (p.first <= 0) {
            ll tmp = p.second;
            p.second = - p.first;
            p.first = tmp;
            rot = true;
        }
        if (rot) mp[p].second++;
        else mp[p].first++;
    }
    mint ans = 1;
    for (auto p : mp){
        int s = p.second.first;
        int t = p.second.second;
        mint u = 1;
        u += mint(2).pow(s) - 1;
        u += mint(2).pow(t) - 1;
        ans *= u;
    }
    ans -= 1;
    ans += zero;

    cout << ans << "\n";
}

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

int main()
{
    int S, h, m, s;
    cin >> S;

    s = S % 60;
    m = ((S - s) % 3600) / 60;
    h = (S - s) / 3600;

    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

int main()
{   
    int n;
    string s;
    cin >> n >> s;
    int a = 0;
    rep(i, n) if(s[i] == 'R') a++;
    int b = 0, ans = a;
    rep(i, n) {
        if(s[i] == 'R') a--;
        else b++;
        int now = max(a, b);
        ans = min(ans, now);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3704
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N; cin >> N;
	vector<ll> L(N + 1, 0);
	L[0] = 2; L[1] = 1;
	for (int i = 2; i <= N;i++) {
		L[i] = L[i - 1] + L[i - 2];
	}
	cout << L[N] << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;


class Program
{
    internal static void Main(string[] args)
    {
        int[] inp = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int A = inp[0];
        int B = inp[1];
        int C = inp[2];

        if (A + B >= C) {
            WriteLine("Yes");
        } else {
            WriteLine("No");
        }
    }
}


Measured memory_bytes: 13268
import sys
input = sys.stdin.readline

#単入力
n=int(input())

#リスト入力
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]


for i in range(1,n):
    if a[i]-a[i-1]==1:
        b.append(c[a[i]-2])
print(sum(b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

int main(){
	int n,a;cin >> n >> a;
	vector<vector<ll>> dp(55,vector<ll>(2505,0));
	dp[0][0] = 1;
	rep(i,n) {
		int temp;cin >> temp;
		vector<vector<ll>> p(55,vector<ll>());
		p = dp;
		rep(j,i+1){
			for(int num = temp;num < 2505;num++){
				if(p[j][num-temp] != 0) {
					dp[j+1][num] += p[j][num-temp];
				}
			}
		}
	}
	ll ans = 0;
	for(int i = 1;i <= n;i++){
		ans += dp[i][i*a];
	}
	cout << ans << endl;

} 
 

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

int main(){
	ll x, K, D; scanf("%lld %lld %lld", &x, &K, &D);
	ll ans;
	if(x < 0) x *= -1; 
	ll plus = x % D;
	ll minus = plus - D;
	ll num = (x - plus) / D;
	if(num >= K){
		ans = x - D * K;
	}
	else{
		if((K - num) % 2 == 0) ans = plus;
		else ans = minus;
	}
	
	printf("%lld\n", abs(ans));
}

Measured memory_bytes: 3792
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 100000000000000;/* 1e+9a */
namespace utils{

    class Repeater{
        int st;
        int ed;
        int d;
    public:
        class rep_iterator{
            int i; int d;
        public:
            rep_iterator(int x, int pd) :i(x), d(pd) {}

            int& operator*(){ return i; }
            bool operator==(const rep_iterator& k) const { return i == k.i; }
            bool operator!=(const rep_iterator& k) const { return i != k.i; }
            rep_iterator& operator++(){ i+=d; return *this; }
        };

        explicit Repeater(int N) :st(0), ed(N), d(1) {}
        Repeater(int b, int e) :st(b), ed(e), d(1) {if(st > ed){ st--; ed--; d = -1; } }

        rep_iterator begin() const{ return rep_iterator(st, d); }
        rep_iterator end() const{ return rep_iterator(ed, d); }

    };

    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;

class solver{
    vector<vector<ll>> dp;
    vector<ll> A;
public:
    solver(vector<ll> A) : dp(A.size(), vector<ll>(A.size(), INF)), A(A) {}

    ll solve(int l, int r){
       if(r < l) return 0;
       if(dp[l][r] != INF) return dp[l][r];

       return dp[l][r] = max(A[l] - solve(l+1, r), A[r] - solve(l, r-1));
    }

};


void sub_main(istream &is) {
    ll N;
    is >> N;
    if(!is) return;
    vector<ll> A(N);
    for (auto &&a : A) {
        is >> a;
    } // end a
    cout << solver(A).solve(0, N-1) << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_L.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


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

int a[110];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for(int i = n-1; i > 0; i--)
		printf("%d ", a[i]);
	printf("%d\n", a[0]);
}



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

int main() {
  int a[3];cin>>a[0]>>a[1]>>a[2];
  sort(a, a+3);
  if (a[0] == 5 && a[2] == 7 && a[1] == 5) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

const double pi = 3.141592653589793;
// -------------------------------------------------------

int N;
int F[110][6][3];
int P[110][20];
int open[6][3];
int overlap[110];

int main() {
  cin >> N;
  repe(i, 1, N) {
    repe(j, 1, 5) {
      repe(k, 1, 2) {
        cin >> F[i][j][k];
        if (F[i][j][k] == 1) {
          open[j][k]++;
        }
      }
    }
  }
  repe(i, 1, N) {
    repe(j, 0, 10) { cin >> P[i][j]; }
  }

  int ans = -inf;
  for (int bit = 1; bit < (1 << 10); ++bit) {
    repe(i, 0, N) { overlap[i] = 0; }

    for (int i = 0; i < 5; ++i) {
      for (int j = 0; j < 2; ++j) {
        int ij = 2 * i + j;
        if ((1 << ij) & bit) {
          for (int k = 1; k <= N; ++k) {
            if (F[k][i + 1][j + 1] == 1) {
              overlap[k]++;
            }
          }
        }
      }
    }

    int score = 0;
    repe(i, 1, N) { score += P[i][overlap[i]]; }
    chmax(ans, score);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import numpy as np


def solve(L: int, R: int, d: int):
    ans = 0
    for i in range(L,(R+1)):
        if i%d == 0:
            ans += 1

    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    solve(L, R, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26980
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)2e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)2e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (2 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 2, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 1) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 2;
    LL sum = a;
    while(b){
        if(b&2)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

vector<vector<int> > xc(100001), yc(100001);

PII func(PII p){
    PII res(0, 0);
    if(!xc[p.first].empty()){
        vector<int> line = xc[p.first];
        xc[p.first].clear();
        ++res.first;
        for(auto &i:line){
            res = res + func(PII(p.first, i));
        }
    }
    if(!yc[p.second].empty()){
        vector<int> line = yc[p.second];
        yc[p.second].clear();
        ++res.second;
        for(auto &i:line){
            res = res + func(PII(i, p.second));
        }
    }
    return res;
}

signed  main(){
    int x, y;
    map<int, int> m;
    {
        int line[]={1, 3, 5, 7, 8, 10, 12};
        for(auto &i:line)m[i]=1;
    }
    {
        int line[]={4, 6, 9, 11};
        for(auto &i:line)m[i]=2;
    }
    m[2]=3;
    cin >> x >> y;
    cout << (m[x] == m[y]?"Yes":"No") << endl;
}



Measured memory_bytes: 4992
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *

# Binary Indexed Tree
class BIT:

    def __init__(self, N):
        self.N = N
        self.bit = [0] * (N+1)

    def add(self, x, a):
        while x <= self.N:
            self.bit[x] += a
            x += x & -x

    def sum(self, x):
        ret = 0
        while x != 0:
            ret += self.bit[x]
            x -= x & -x
        return ret

    # x < sum(index) となる最小の index を返す
    def upper_bound(self, x):
        l, r = -1, self.N
        while l+1 < r:
            m = (l+r)//2
            y = self.sum(m)
            if x < y:
                r = m
            else:
                l = m
        return r

    # x <= sum(index) となる最小の index を返す
    def lower_bound(self, x):
        l, r = -1, self.N
        while l+1 < r:
            m = (l+r)//2
            y = self.sum(m)
            if y < x:
                l = m
            else:
                r = m
        return r

N = int(input())
P = [int(x) for x in input().split()]
I = [0] * (N+1)
for i, x in enumerate(P, 1):
    I[x] = i
bit = BIT(N+1)
bit.add(I[N], 1)
ans = 0
for x in range(N-1, 0, -1):
    s = bit.sum(I[x])
    l = bit.lower_bound(s)
    r = bit.upper_bound(s)
    ans += x*((bit.upper_bound(s+1)-r)*(I[x]-l)+(l-bit.lower_bound(s-1))*(r-I[x]))
    bit.add(I[x], 1)
print(ans)


Measured memory_bytes: 58604
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MAX_V=114514LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};


int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  rep(i,n){
    if(a[i]%2==0){
      if(a[i]%3==0||a[i]%5==0)continue;
      cout<<"DENIED"<<endl;
      return 0;
    }
  }
  cout<<"APPROVED"<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    string s, cmd, p;
    cin >> s;
    int q, a, b;
    cin >> q;
    rep(i, q) {
        cin >> cmd >> a >> b;
        if (cmd == "replace") {
            cin >> p;
            s = s.replace(a, b - a + 1, p);
        } else if (cmd == "reverse") {
            reverse(s.begin() + a, s.begin() + b + 1);
        } else if (cmd == "print") {
            cout << s.substr(a, b - a + 1) << "\n";
        }
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3204
#include <stdio.h>

int main(){
 int n,k,i,j,l[5005],nl,ln[2502];
 long p[5005],c[5005],m=-1000000001,d,e,g,lc[2502];
 scanf("%d",&n);
 scanf("%d",&k);
 for(i=0;i<n;i++){
  scanf("%ld",&p[i]);
  p[i]--;
 }
 for(i=0;i<n;i++){
  scanf("%ld",&c[i]);
  if(c[i]>m){
   m=c[i];
  }
  l[i]=-1;
 }
 for(i=0;i<n;i++){
  if(l[i]==-1){
   l[i]=nl;
   lc[nl]=c[i];
   ln[nl]=1;
   for(j=p[i];j!=i;j=p[j]){
    l[j]=nl;
    lc[nl]+=c[j];
    ln[nl]++;
   }
   nl++;
  }
 }
 for(i=0;i<n;i++){
  g=k%ln[l[i]];
  if(k>=ln[l[i]]){
   g+=ln[l[i]];
  }
  d=c[i];
  if(lc[l[i]]>0){
   d+=(long)((k-g)/ln[l[i]])*lc[l[i]];
  }
  e=d;
  for(g--,j=p[i];g>0;g--,j=p[j]){
   e+=c[j];
   if(e>d){
    d=e;
   }
  }
  if(d>m){
   m=d;
  }
 }
 printf("%ld",m);
 return 0;
}


Measured memory_bytes: 1844
# ABC051B - Sum of Three Integers.py
import sys
import itertools

k, s = map(int, sys.stdin.readline().strip().split())

n = 0
for iz in range(s // 3, k + 1):
    for iy in range((s - iz) // 2, k + 1):
        x = s - iy - iz
        if 0 <= x <= iy <= iz:
            y, z = iy, iz
            # print((x, y, z))
            n += len(set(itertools.permutations((x, y, z))))

print(n)


Measured memory_bytes: 3060
#include<cstdio>
using namespace std;
typedef long long ll;

ll n, a[200000], temp[200000];

ll getNum(ll* d, ll n) {
  if (n <= 1) return 0;
  ll m = n / 2;
  ll ans = getNum(d, m) + getNum(d+m, n-m);
  for (ll i = 0; i < n; i++) temp[i] = d[i];
  ll f1 = 0, f2 = 0;
  while (f1 + f2 < n) {
    if (f2 != (n-m) && (f1 == m || temp[f1] > temp[m + f2])) ans += m - f1, d[f1 + f2] = temp[m + f2], f2++;
    else d[f1 + f2] = temp[f1], f1++;
  }
  return ans;
}

int main() {
  scanf("%lld", &n);
  for (ll i = 0; i < n; i++) scanf("%lld", &a[i]);
  printf("%lld\n", getNum(a, n));
}



Measured memory_bytes: 5792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(ll x)
{
    if(x==1) return 1;
    else return 2*f(x/2)+1;
}


int main()
{
    ll h;
    cin>>h;
    cout<<f(h)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <memory.h>
#include <algorithm>
#define case        printf("Case %d: ",++tc);
#define read        freopen("tst.txt","r",stdin)
#define write       freopen("out.txt","w",stdout)
typedef long long ll;
using namespace std;
#define pi acos(-1)
#define mx 100001
ll dp[102][mx];
ll val[102],wt[102],n,w;
const ll inf = 1e14;

main(){
ll t,tc = 0;

scanf("%lld%lld",&n,&w);
for(ll i = 0; i<n; i++)    scanf("%lld%lld",wt+i,val+i);

for(ll i = 0; i<=n; i++)    fill(dp[i],dp[i]+mx,inf);

dp[0][0] = 0;
ll ans = 0;

for(ll i = 1; i<=n; i++){
    for(ll j = 0; j<mx; j++){
        if(j==0)    dp[i][j] = 0;
        else if(val[i-1]<=j) dp[i][j] = min(wt[i-1]+dp[i-1][j-val[i-1]],dp[i-1][j]);
        else dp[i][j] = dp[i-1][j];
        if(dp[i][j]<=w) ans = max(ans,j);
    }
}

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

return 0;
}



Measured memory_bytes: 79104
import Control.Monad
import Control.Applicative
import qualified Data.IntMap.Strict as I
import Data.List
import Data.Function (on)

convenients :: [[Int]] -> I.IntMap Int
convenients = foldl' (foldl' (\m d -> I.insertWith (+) d 1 m)) I.empty

fixDate :: Int -> I.IntMap Int -> Int
fixDate quorum m = case sortBy (flip compare `on` snd)
                        . filter ((>= quorum) . snd) . I.toAscList $ m of
                       [] -> 0
                       (n:_) -> fst n

main :: IO ()
main = do
    (n:q:_) <- map read . words <$> getLine
    unless (n == 0 && q == 0) $ do
        replicateM n getLine >>=
            print . fixDate q . convenients . map (map read . tail . words)
        main

Measured memory_bytes: 5364
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
priority_queue<int,deque<int>,greater<int>> Aapp;
priority_queue<int,deque<int>,greater<int>> Bapp;
deque<int> Capp;
int x,y,a,b,c;
void init(void){
	cin>>x>>y>>a>>b>>c;
	int aapp[a+1],bapp[b+1],capp[c+1];
	for(int i=1;i<=a;i++)
		cin>>aapp[i];
	for(int i=1;i<=b;i++)
		cin>>bapp[i];
	for(int j=1;j<=c;j++)
		cin>>capp[j];
	sort(aapp+1,aapp+a+1,greater<int>());
	sort(bapp+1,bapp+b+1,greater<int>());
	sort(capp+1,capp+c+1,greater<int>());
	for(int i=1;i<=x;i++)
		Aapp.push(aapp[i]);
	for(int j=1;j<=y;j++)
		Bapp.push(bapp[j]);
	for(int k=1;k<=c;k++)
		Capp.push_back(capp[k]);
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	init();
	while(!Capp.empty()){
		int xx=Capp.front();
		Capp.pop_front();
		int maxone=max(Aapp.top(),Bapp.top());
		int minone=min(Aapp.top(),Bapp.top());
		int AmB=(Aapp.top()==maxone);
		if(xx>=minone){
			if(!AmB){
				Aapp.pop();
				Aapp.push(xx);
			}
			else{
				Bapp.pop();
				Bapp.push(xx);
			}
		}
		else{
			if(xx>=maxone){
				if(AmB){
					Aapp.pop();
					Aapp.push(xx);
				}
				else{
					Bapp.pop();
					Bapp.push(xx);
				}
			}
			else
				break;
		}
	}
	int ans=0;
	while(!Aapp.empty()){
		ans+=Aapp.top();
		Aapp.pop();
	}
	while(!Bapp.empty()){
		ans+=Bapp.top();
		Bapp.pop();
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
using namespace std;
int main(){
int N;
cin>>N;
vector<int> A(N);
for(int i=0;i<N;i++) cin>>A[i];

vector<int> rev(N);
for(int i=0;i<N;i++) rev[A[i]-1]=i+1;
for(int i=0;i<N;i++) cout<<rev[i]<<endl;
return 0;}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <ios>
#include <iomanip>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;

void solve() {
    int N,W;
    cin >> N >> W; 
    vi v(N),w(N);
    rep(i,N){
        cin >> v[i] >> w[i];
    }
    int dp[N+1][W+1];

    rep(i,N+1){
        rep(j,W+1){
            dp[i][j]=0;
        }
    }

    rep(i,N){
        rng(j,1,W+1){
            if(w[i] > j) {
                dp[i+1][j] = dp[i][j];
            } else{
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
            }
        }
    }
    print(dp[N][W]);
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


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

#define ENDL '\n'
#define io ios_base::sync_with_stdio(false);cin.tie(0);
#define sayy cout<<"YES"<<ENDL;
#define sayn cout<<"NO"<<ENDL;

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

int main(){
    io

    int n;
    cin >> n;

    vector<int> v(n);
    for(int i(0); i<n; i++){
        cin >> v.at(i);
    }

    int ans(0), brick(1);
    for(int i(0); i<v.size(); i++){
        if(v.at(i) != brick){
            ans++;
        }
        else{
            brick++;
        }
    }

    if(ans == n){
        cout << -1 << ENDL;
    }
    else{
        cout << ans << ENDL;
    }

    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h> 
using namespace std;  
long INF=1000000000000000;
int main() {
    long A,B,Q;
    cin>>A>>B>>Q;
    
    set<long> s,t;
    s.insert(INF);
    s.insert(-INF);
    t.insert(INF);
    t.insert(-INF);
    for(int i=0;i<A;i++){
        long ps;
        cin>>ps;
        s.insert(ps);
    }
    for(int i=0;i<B;i++){
        long pt;
        cin>>pt;
        t.insert(pt);
    }
    
    
    for(int q=0;q<Q;q++){
        long x;
        cin>>x;
        
        long ls=abs(x-*(--s.upper_bound(x)));
        long rs=abs(x-*(s.lower_bound(x)));
        long lt=abs(x-*(--t.upper_bound(x)));
        long rt=abs(x-*(t.lower_bound(x)));
        
        cout<<min(max(ls,lt),min(max(rs,rt),min(ls+rt+min(ls,rt),rs+lt+min(rs,lt))))<<endl;
    }
}

Measured memory_bytes: 10752
import java.io.*;

class Main {
    BufferedReader bf;
    PrintWriter writer;
    StringBuilder sb;
    static boolean local_system = false;

    void run() throws IOException {
        long[] c = longs();
        long l = c[1] * c[1];
        int co = 0;
        for(int i = 0,h=(int)c[0];i<h;i++){
            long[] d = longs();
            if(d[0]*d[0] + d[1]*d[1] <= l) co++;
        }
        writer.println(co);
    }

    public static void main(String[] args) throws IOException {
        long start_time = System.currentTimeMillis();
        Main obj = new Main();
        obj.run();
        long end_time = System.currentTimeMillis();
        if (local_system) obj.writer.println("Time : " + (end_time - start_time));
        obj.close();
    }

    public Main(){
        writer = new PrintWriter(System.out);
        bf = new BufferedReader(new InputStreamReader(System.in));
        sb = new StringBuilder();
    }

    public int getInt() throws IOException {
        return Integer.parseInt(bf.readLine());
    }

    public long getLong() throws IOException {
        return Long.parseLong(bf.readLine());
    }

    public int[] ints() throws IOException {
        String[] data = bf.readLine().split(" ");
        int[] send = new int[data.length];
        for (int i = 0, h = data.length; i < h; i++) send[i] = Integer.parseInt(data[i]);
        return send;
    }

    public long[] longs() throws IOException {
        String[] data = bf.readLine().split(" ");
        long[] send = new long[data.length];
        for (int i = 0, h = data.length; i < h; i++) send[i] = Long.parseLong(data[i]);
        return send;
    }

    public void close() throws IOException{
        writer.flush();
        writer.close();
        bf.close();
    }
}




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

int main()
{
    int H, W, h, w;
    char ans;
    cin >> H >> W;
    string s;
    string atoz = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> s;
            if (s == "snuke")
            {
                h = i;
                w = j;
            }
        }
    }
    cout << atoz[w] << h + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}
int func2(int x){
  int sum=0;
  while(x>0){
    sum+=x%10;
    x/=10;
  }
  return sum;
}

int main() {
  int n,a,b;
  cin>>n>>a>>b;
  int sum=0;
  for(int i=1;i<=n;i++){
    if(func2(i)<=b&&func2(i)>=a){sum+=i;}
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,ans=0;
    cin>>n;
    int a[n],b[n],c[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=0;i<n;i++) cin>>b[i];
    for(i=0;i<n-1;i++) cin>>c[i];
    int p,q;
    p=a[0];
    //cout<<p<<endl;
    ans=b[p-1];
    //cout<<ans;

    for(i=1;i<n;i++){
        if(a[i]-a[i-1]==1){
            ans += b[a[i]-1]+ c[a[i-1]-1];
        }
        else{
            ans += b[a[i]-1];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>
using namespace std;
 
int main()
{
    string a;
    cin>>a; 
    int sz= a.size();
    
    stack<char> st;
    for ( int i = 0 ; i < a.size() ; i ++ )
	{
        if ( a[i] == 'T' )
		{
            if ( !st.empty() )
			{
                if (st.top() == 'S' )
				{
                    sz -= 2 ;
                    st.pop() ;
                }
            }
			else
                st.push(a[i]) ;
        }
		else
            st.push(a[i]) ;
    }
    cout << sz << endl ;
   
    return 0 ;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  
  vector<bool>oks(N+1,true);
  for(int i=0;i<M;++i){
    int a;cin>>a;
    oks[a]=false;
  }
  
  vector<long long int>dp(N+1);
  dp[0]=1;
  for(int now=0;now<N;++now){
    for(int next=now+1;next<=min(N,now+2);++next){
      if(oks[next]){
        dp[next]+=dp[now];
		dp[next]%=mod;
      }
    }
  }
  
    cout<<dp[N]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <stack>
#include <queue>
#include <deque>
#include <iomanip>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <bitset>

/*----------------------------------------------------------------*/

using ld = long double;
using vld = std::vector<ld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using str = std::string;
using vstr = std::vector<str>;
using vb = std::vector<bool>;
using vvb = std::vector<vb>;

/*----------------------------------------------------------------*/

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }
template<typename T> T sqr(T a) { return a * a; }

/*----------------------------------------------------------------*/

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

/*----------------------------------------------------------------*/

ll gcd(ll n, ll m) { return m != 0 ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; sqr(i) <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll popcnt(ll n) {
    n = ((n & 0xaaaaaaaaaaaaaaaa) >> 1) + (n & 0x5555555555555555);
    n = ((n & 0xcccccccccccccccc) >> 2) + (n & 0x3333333333333333);
    n = ((n & 0xf0f0f0f0f0f0f0f0) >> 4) + (n & 0x0f0f0f0f0f0f0f0f);
    n = ((n & 0xff00ff00ff00ff00) >> 8) + (n & 0x00ff00ff00ff00ff);
    n = ((n & 0xffff0000ffff0000) >> 16) + (n & 0x0000ffff0000ffff);
    n = ((n & 0xffffffff00000000) >> 32) + (n & 0x00000000ffffffff);
    return n;
}

/*----------------------------------------------------------------*/

void solve();

/*----------------------------------------------------------------*/

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

    solve();
}

void solve() {
    ll n, max_w; std::cin >> n >> max_w;

    vll v(n), w(n);
    for (ll i = 0; i < n; i++)
        std::cin >> v[i] >> w[i];

    vvll dp(n + 1, vll(max_w + 1, 0));
    for (ll i = 0; i < n; i++) for (ll j = 0; j <= max_w; j++) {
        chmax(dp[i][j], dp[i + 1][j]);
        if (j + w[i] <= max_w)
            chmax(dp[i][j] + v[i], dp[i + 1][j + w[i]]);
    }

    std::cout << dp[n][max_w] << '\n';
}



Measured memory_bytes: 10720
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int N, A, B;
int main() {
	cin >> N >> A >> B;
	if ((N == 1 && A != B) || A > B) cout << 0 << endl;
	else cout << 1LL * (B - A) * (N - 2) + 1 << endl;
	return 0;
}

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

int main(void) {
	int n, d, x;
	cin >> n >> d >> x;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		if (d % a[i] == 0) x += d / a[i];
		else x += d / a[i] + 1;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
using namespace std;
const int N= 1e5;


int main(){ 
    fast;
    ll n, t;
    cin >> n >> t;
    cout << (2 * t) - n;

    return 0;
}


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

void palindrome_check(char *str, int *n)
{
	int flag = 1;
	int k = strlen(str);
	int i;
	for (i = 0; i <= k / 2; i++){
		if (str[i] != str[k - i - 1]){
			flag = 0;
			break;
		}
	}
	
	if (flag == 1){
		*n += 1;
	}
}

int main(void)
{
	char str[201];
	int check;
	
	check = 0;
	while (scanf("%s", str) != EOF){
		
		palindrome_check(str, &check);
	}
	
	printf("%d\n", check);
	
	return (0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
constexpr ll infl = 1ll<<60;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n;
    cin>>n;
    ll mi = n-1;
    for(ll i=2ll;i*i<=n;++i)if(n%i==0){
        mi = min(i-1+n/i-1,mi);
    }
    cout << mi << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		String S[] = new String[N]; 
		int AC = 0;
		int WA = 0;
		int TLE = 0;
		int RE = 0;
		
		for(int i=0;i<N;i++) {
			S[i] = in.next();
			switch (S[i]) {
			case "AC":
				AC++;
				break;
			case "WA":
				WA++;
				break;
			case "TLE":
				TLE++;
				break;
			case "RE":
				RE++;
				break;
			}
		}
		
		System.out.println("AC x " + AC);
		System.out.println("WA x " + WA);
		System.out.println("TLE x " + TLE);
		System.out.println("RE x " + RE);
	}
}


Measured memory_bytes: 64104
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	string s;
  	cin >> s;
	cout << (s[1] == 'R' ? "ABC":"ARC") << endl;
}

Measured memory_bytes: 3592
S = input()
t = input()

n = len(S)
m = len(t)

for i in range(n-m, -1, -1):
  t_ = S[i:i+m]
  for j in range(m+1):
    if j == m:
      print((S[:i] + t + S[i+m:]).replace('?', 'a'))
      exit()
    if t_[j] == '?':
      continue
    elif t_[j] != t[j]:
      break
  
print('UNRESTORABLE')

Measured memory_bytes: 8996
require 'prime'

n = gets.to_i
ary = Prime.prime_division(n)
count = 0
div_ary = []
ary.each do |i|
  a = i.shift
  b = i.shift
  check_j = 0
  (1..b).each do |j|
    if b > check_j
      div_ary.push(a**j)
      b -= j
      check_j = j
    else
      break
    end
  end
end
print div_ary.uniq.count

Measured memory_bytes: 14380