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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++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;

    }
}

LL comb(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< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    string s, t;
    cin >> s >> t;
    string p = "UNRESTORABLE";
    if( s.size() < t.size() ) {
        cout << p << endl;
        return 0;

    }

    bool f = false;
    int pos;
    for( int i = s.size() - t.size(); i >= 0; --i ) {
        bool flg = true;
        for( int j = 0; j < t.size(); ++j ) {
            if( s[i + j] != '?' ) {
                if( s[i + j] != t[j] ) flg = false;

            }
        }
        if( flg ) {
            f = true;
            pos = i;
            break;

        }
    }

    if( !f ) {
        cout << p << endl;
        return 0;

    }

    for( int i = pos; i < pos + t.size(); ++i ) {
        s[i] = t[i - pos];

    }

    for( int i = 0; i < s.size(); ++i ) {
        if( s[i] == '?' ) s[i] = 'a';

    }
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    INT(a,b);
    INT(n);
    int ans=0;
    while(n--){
        INT(start,end);
        if(start<a&&a<end){
            ans=1;
            break;
        }
        if(start<b&&b<end){
            ans=1;
            break;
        }
        if(a<=start&&end<=b){
            ans=1;
            break;
        }
    }
    out(ans);
}



Measured memory_bytes: 3216
// 6/28 バーチャル参加
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S[i];

    map<string, int> mp;
    rep(i, N) {
        mp[S[i]]++;
    }

    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;;
    cout << "TLE x " << mp["TLE"] << endl;;
    cout << "RE x " << mp["RE"] << endl;;
    return 0;
}

Measured memory_bytes: 6428
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
using namespace std;

int main(){
	int a, b;
	int ans;
	cin >> a >> b;
	int x = a + b;
	int y = a - b;
	int z = a*b;
	ans = max(x, y);
	ans = max(ans, z);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <queue>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;
class Graph{
public:
    ////////////グラフサイズを渡して作成する
    ////////////infの値は必要に応じて調整すること
    Graph(long long int n):g_size(n),edges(n),result(n,0){


    }
    
  
    ///////////初期状態では有向
    ///////////無向にするときは
    /*  edges[b][a] = cost;  */
    //を追加
    void add_edge(long long int a,long long int b,long long int cost=1){
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    
    llint solve(){
        struct node{
            llint num;
            llint cost;
        };
        queue<node> q;
        
        REP(i, g_size){
            vector<llint>checked(g_size, 0);
            checked[i] = 1;
            q.push({i,0 });

            while(!q.empty()){
                for(auto x:edges[q.front().num]){
                    if(checked[x]==0){
                        result[q.front().cost + 1]++;
                        checked[x] = 1;
                        q.push({x, q.front().cost + 1});
                    }
                }
                q.pop();
            }
        }
        REP(i,g_size-1){
            cout << result[1+i]/2 << endl;
        }
        return 0;
    }
    

  
private:
    long long int g_size;
    vector<vector<long long int>> edges;
    vector<long long int> result;
};



int main(){
    llint n, x, y;
    cin >> n >> x >> y;
    Graph graph(n);
    REP(i,n-1){
        graph.add_edge(i, i + 1);
    }
    graph.add_edge(x - 1, y - 1);
 graph.solve();

    return 0;
}


Measured memory_bytes: 888
N=int(input())
lest=[]
for i in range(0,N):
    S,P=list(map(str,input().split()))
    lest.append([S,int(P),i+1])
lest.sort()
for n in range(0,100):
    for i in range(0,N-1):
        if lest[i][0]==lest[i+1][0] and lest[i][1]<lest[i+1][1]:
            a=lest[i][1]
            lest[i][1]=lest[i+1][1]
            lest[i+1][1]=a
            b = lest[i][2]
            lest[i][2] = lest[i + 1][2]
            lest[i + 1][2] = b
for i in range(0,N):
    print(lest[i][2])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int a,b;
    cin >> a >> b;
    if(a > b) swap(a,b);
    REP(i,b) cout << a;
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<string> W(N);

    for (int i = 0; i < N; i ++){
        cin >> W[i];
    } 

    int count = 0;
    for (int i = 0; i < N-1; i++){
        int n = W[i].length();
        if(W[i].substr(n-1, 1) != W[i+1].substr(0,1)){
            break;
        }

        count++;
    }
    
    sort(W.begin(), W.end());
    W.erase(unique(W.begin(), W.end()), W.end());

    if (W.size() != N || count != N-1){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct p
{
    int times,endtime;
    bool operator <(p b){
        if(endtime<b.endtime)
            return 1;
        else if(endtime==b.endtime){
            return times<b.times;
        }
        else
            return 0;

    }
    p() {}
};
int n;
p a[200000+5];
int main(){
    cin>>n;
    for(int i=0;i<n;i++)
        scanf("%d %d",&a[i].times,&a[i].endtime);
    sort(a,a+n);
    int now=0;
    for(int i=0;i<n;i++){
        if(now+a[i].times<=a[i].endtime)
            now+=a[i].times;
        else{
            printf("No\n");
            return 0;
        }

    }
    printf("Yes\n");


}


Measured memory_bytes: 1792
#include <stdio.h>

int main() {
  int n, a[100];

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


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 7;
#define debug(a) cout<<#a<<": "<<a<<'\n'
//ll read(){
//	ll ans = 0,f = 1;
//	char ch = getchar();
//	for(;ch<'0'||ch>'9';ch = getchar())if(ch=='-')f = -1;
//	for(;ch>='0'&&ch<='9';ch = getchar())ans = (ans <<3) + (ans << 1) + ch-'0';
//	return ans * f;
//}
inline int read()
    {
        int x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
char s[maxn];
int main() {
	ios::sync_with_stdio(false);
	int tem;
	//string s;
	tem = read();
	//cin >> tem;
	//cin >> s;
	scanf("%s",s);
//	if(tem >=3200)cout << s;
//	else cout << "red";
	if(tem>=3200)printf("%s",s);
	else printf("red");
	return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(n)]
AB.sort()
res = 0
for a,b in AB:
    m -= b
    if m >= 0:
        res += a*b
    else:
        m += b
        res += a*m
        break
print(res)

Measured memory_bytes: 27756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
map<string, int> cnt;
int main(){
	int n;
	scanf("%d",&n);

	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		if(cnt.count(s))
			cnt[s]++;
		else
			cnt[s]=1;
	}
	vector<pair<int, string> > v;
	for(auto it=cnt.begin();it!=cnt.end();it++){
		v.pb({it->second,it->first});
	}
	sort(v.begin(),v.end());
	int len = v.size();
	int x = v[len-1].ff;
	for(int i=0;i<len;i++){
		if(x>v[i].ff)continue;

		cout<<v[i].ss<<"\n";
	}
	
	
    return 0;
}

Measured memory_bytes: 29684
#include "bits/stdc++.h"
using namespace std;

int n, T;
int a[200005];

int main()
{
    scanf("%d %d", &n, &T);
    for(int i = 1 ; i <= n ; i++)
        scanf("%d", &a[i]);
    vector < pair < int, int > > p;
    for(int i = 1 ; i <= n ; i++)
    {
        p.push_back({a[i] + 1, a[i] + T});
    }
    long long int ans = 0;
    int curl = p[0].first;
    int curr = p[0].second;
    for(int i = 1 ; i < n ; i++)
    {
        int left = p[i].first;
        int right = p[i].second;
        if(left > curr)
        {
            ans += (max(0, curr - curl + 1));
            curl = left;
            curr = right;
        }
        else
        {
            curr = max(curr, right);
        }
    }
    ans += max(0, curr - curl + 1);
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 3188
#include <stdio.h>

int main(void)
{
	int i,j,k,n,m,l;
	long int a[100][100]={0};
	long int b[100][100]={0};
	long int c[100][100]={0};

	scanf("%d %d %d", &n, &m, &l);

	for(i=0;i<n;i++){	/*??????a?????\???*/
		for(j=0;j<m;j++){
		scanf("%dl\n",&a[i][j]);
		}
	}
	for(i=0;i<m;i++){	/*??????????????\???*/
		for(j=0;j<l;j++){
		scanf("%dl\n",&b[i][j]);
		}
	}
	for(i=0;i<n;i++){	/*????????????*/
		for(j=0;j<l;j++){
		c[i][j]=0;
		for(k=0;k<m;k++){
			c[i][j] += a[i][k]*b[k][j];
			}
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<l-1;j++){
			printf("%ld ", c[i][j]);
			}
			printf("%ld\n",c[i][l-1]);
	}

	return 0;
}

Measured memory_bytes: 844
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll A, B;    in2(A,B);
    char S[20]; ins(S);
    ll isYes=1;
    rep(i, A+B+1){
        if(i==A && S[i] != '-') isYes = 0;
        if(i!=A && S[i] == '-') isYes = 0;
    }
    puts(isYes ? "Yes":"No");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    long long s = 0;
    for(int i = 1; i <= n; i++) {
        if(i % 3 == 0 || i % 5 == 0) continue;
        s += i;
    }
    cout << s;
}

Measured memory_bytes: 3636
import fractions
a,b,c,d = map(int, input().split())
cc = b//c - (a-1)//c
dd = b//d - (a-1)//d
gcd = int(c*d / fractions.gcd(c, d))
cd = b//gcd - (a-1)//gcd

print((b-a+1) + cd - cc -dd)


Measured memory_bytes: 5344
def cmb(n,k, MOD):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD

MOD = 10**9+7
n, k = map(int, input().split())
a = list(map(int, input().split()))
ascA = sorted(a)

MAX_N = n
fac  = [0 for _ in range(MAX_N)]
finv = [0 for _ in range(MAX_N)]
inv  = [0 for _ in range(MAX_N)]

fac[0]  = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1

for i in range(2,MAX_N):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

sum_ = 0
for i in range(n-k+1):
    f = ascA[n-i-1] - ascA[i]
    c = cmb(n-i-1, k-1, MOD)
    sum_ = (sum_ + (f*c)%MOD) % MOD
    '''
    for j in range(i+k-1, n):
        f = ascA[j]-ascA[i]
        c = cmb(j-i-1, k-2, MOD)
        #print("%d %d"%(f,c))
        sum_ = (sum_ + (f*c) % MOD) % MOD
    '''

print(sum_)


Measured memory_bytes: 66344
// SeeAlso: https://atcoder.jp/contests/abc131/tasks/abc131_b

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int N, L;

int main() {
    cin >> N >> L;

    int ans = 0;
    int m = L+N-1;
    
    REP(i, N) {
        int taste = L+i;
        ans += taste;
        CHMIN(m, abs(taste));
    }    

    cout << (ans-m) << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
d.sort()
t.sort()
j = 0
for t_i in t:
    while j < n and d[j] < t_i:
        j += 1
    if j == n or d[j] != t_i:
        result = False
        break
    j += 1
else:
    result = True
print(['NO', 'YES'][result])


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

int prime[55556];

int main()
{
    //素数は2を除いて奇数なので、2n+1と表してみる。
    //素数を5つ足すと、2(a+b+c+d+e)+5となる。
    //ここで、5つの素数を5で割ると1余る数とすると、
    //2{a+b+c+d+e}は5で割り切れる。
    //よって、2(a+b+c+d+e)+5も5で割り切れる。
    //みたいな？


    for ( int i = 2; i * i <= 55555; i++) {
        for ( int j = 2; i * j <= 55555; j++) {
            prime[i * j] = 1;
        }
    }


    int size = 0;
    int n;
    cin >> n;
    for ( int i = 2; size < n ; i++) {
        if ( prime[i] == 0 && i % 5 == 1 ) {
            if ( size ) {
                printf(" ");
            }
            printf("%d", i);
            size++;
        }
    }

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long LL;

const int maxn=305;

int n,k;
LL mo;

LL C[maxn][maxn];
void Pre(int n)
{
	fo(i,0,n)
	{
		C[i][0]=1;
		fo(j,1,i) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	}
}

LL f[maxn][maxn],sf[maxn][maxn];
int main()
{
	scanf("%d %d %lld",&n,&k,&mo);
	
	Pre(n);
	
	fo(j,0,k) f[1][j]=1, sf[1][j]=k-j+1;
	fo(i,2,n+1)
	{
		fo(j,0,k)
		{
			fo(sz,1,i-1) (f[i][j]+=f[i-sz][j]*sf[sz][j+1]%mo*C[i-2][sz-1])%=mo;
		}
		sf[i][k]=f[i][k];
		fd(j,k-1,1) sf[i][j]=(sf[i][j+1]+f[i][j])%mo;
	}
	
	printf("%lld\n",f[n+1][0]);
}

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

int r, D, x;

int main() {
    cin >> r >> D >> x;

    for (int i = 0; i < 10; i++) {
        int ans = r * x - D;
        printf("%d\n", ans);
        x = ans; 
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define sortv(v) sort(v.begin(),v.end());
#define sorta(a,n) sort(a,a+n);
#define arrayin(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define arrayout(a,n) for(int i=0;i<n;i++) cout<<" ";cout<<"\n";
#define INF INT_MAX //Infinity
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<pair<int,int>>
#define viii vector<tuple<int,int,int>>
#define mii map<int,int>
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define nl "\n"
ulli poW(lli x,ulli y)
{
	//this function only returns correct values upto the order of ~10^18
	//use pow of math to obtain greater answers
	lli temp;
	if(y==0)
		return 1;
	temp=poW(x,y/2);
	if(y%2==0)
		return temp*temp;
	else return x*temp*temp;
}

int bSearch(int low,int high,int a[],int sh)
{
	//function for searching till where is a sh<=
	while(low<high)
	{
		int mid=low+(high-low+1)/2;
		if(a[mid]>sh)
			high=mid-1;
		if(a[mid]<=sh)
			low=mid;
	}
	return low;
}

int main()
{
    fio;
	int n;
	cin>>n;
	mii m;
	int counter3=0;
	REP(i,n)
	{
		int x;
		cin>>x;
		if(x<400)
			m[0]=1;
		else if(x>=400&&x<800)
			m[1]=1;
		else if(x>=800&&x<1200)
			m[2]=1;
		else if(x>=1200&&x<1600)
			m[3]=1;
		else if(x>=1600&&x<2000)
			m[4]=1;
		else if(x>=2000&&x<2400)
			m[5]=1;
		else if(x>=2400&&x<2800)
			m[6]=1;
		else if(x>=2800&&x<3200)
			m[7]=1;
		else if(x>=3200)
			counter3++;
	}
	if(m.size()!=0)
	{
		if(counter3==0)
			cout<<m.size()<<" "<<m.size()<<nl;
		else
		{
			cout<<m.size()<<" "<<m.size()+counter3<<nl;
		}
	}
	else cout<<"1"<<" "<<counter3<<nl;
}

Measured memory_bytes: 256
n = int(input())
s = input()

ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2*j-i
        if k < n and s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            ans -= 1

print(ans)


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

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        int rx = root(x), ry = root(y);
        if (rx == ry) return false;
        if (size(rx) < size(ry)) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }

    bool isSame(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par[root(x)];
    }
};


int main(){
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vector<int> G[101010];
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for (int i = 0; i < k; i++){
        int c, d;
        cin >> c >> d;
        c--; d--;
        if(uf.isSame(c, d)){
            G[c].push_back(d);
            G[d].push_back(c);
        }
    }
    for (int i = 0; i < n; i++) {
        if(i) cout << " ";
        cout << uf.size(i) - 1 - G[i].size();
    }
    return 0;
}

Measured memory_bytes: 7936
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#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 all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int a; cin >> a;
  cout << a+a*a+a*a*a << endl;
  
}

Measured memory_bytes: 3616
import java.util.*;
class Main{
	void aaaa(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int y;
		int min=2000000000;
		int x=-2000000000;
		for(int i=0;i<N;i++){
			y=sc.nextInt();
			if(y-min>x)x=y-min;
			if(min>y)min=y;
		}
		System.out.println(x);
	}
	public static void main(String[]arg){
		Main dn=new Main();
		dn.aaaa();
	}
}

Measured memory_bytes: 94356
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int n;
int x[30], y[30], r[30], c[30];
int on[30];
double dist(int x, int y){
  return sqrt(x *x + y* y);
}
bool ison(int x, int y, int r, int x2, int y2, int r2){
  double d = dist(x-x2, y- y2);
  if(d < (double)r + r2) return true;
  return false;
}
char memo[1<<24];
int dfs(int S){
  if(memo[S] != -1) return memo[S];
  int res = __builtin_popcount(S);
  REP(i, n)REP(j, n){
    if(i != j && !(S & (1 << i)) && !(S & (1 << j)) && c[i] == c[j]){
      if(!(on[i] & (~S)) && !(on[j] & (~S))){
        res = max(res, dfs(S | (1<<i) | (1<<j)));
      }
    }
  }
  return memo[S] = res;
}

int main(){
  while(cin>>n && n){
    REP(i, n) cin>>x[i]>>y[i]>>r[i]>>c[i];
    memset(on, 0, sizeof(on));
    REP(up, n)FOR(low, up + 1, n){
      if(ison(x[up], y[up], r[up], x[low], y[low], r[low])) on[low] |= (1<<up);
    }
    memset(memo, -1, sizeof(memo));
    cout<<dfs(0)<<endl;
  }
      
  return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  
  for(int i=0;i<5;i++){
    cout << s.at(i);
  }
  
  cout << " ";
  
  for(int i=6;i<13;i++){
    cout << s.at(i);
  }
  
  cout << " ";
  
  for (int i=14;i<19;i++){
    cout << s.at(i);
  }
  
  cout << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
//    val input = readLine()?.split(" ")
//    val inputInt = arrayListOf<Int>()
//    input?.forEach { inputInt.add(it.toInt()) }

    var index = 0

    while (true) {
        val input = readLine()?.toInt() ?: return

        if (input == 0) return

        index++

        println("Case $index: $input")
    }

}



Measured memory_bytes: 32172
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    cin>>n;
    string ret="";
    if(n==0)ret="0";
    while(n){
        ret=to_string(!!(n%2))+ret;
        n-=!!(n%2);
        n/=-2;
    }
    cout<<ret<<endl;
}

Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        m: usize,
        a: [u32; n],
        b: [u32; m],
    }
    let mut and = vec![];
    let mut i = 0;
    let mut j = 0;
    while i < n && j < m {
        if a[i] == b[j] {
            and.push(a[i]);
            i += 1;
            j += 1;
        } else if a[i] < b[j] {
            i += 1;
        } else {
            j += 1;
        }
    }
    let mut or = a.clone();
    or.append(&mut b.clone());
    or.sort();
    or.dedup();
    let mut ans = String::new();
    ans.push_str(&format!("{} {}\n", and.len(), or.len()));
    for a in and {
        ans.push_str(&format!("{}\n", a));
    }
    for b in or {
        ans.push_str(&format!("{}\n", b));
    }
    print!("{}", ans);
}

fn main() {
    run();
}



Measured memory_bytes: 15940
x1, y1, x2, y2 = [int(i) for i in input().split()]
x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x3 - (x2 - x1)
y4 = y3 - (y2 - y1)
print(x3, y3, x4, y4)

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

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

using namespace std;

/* function */
//  - none - 


/* code */
int main (void) 
{

  /* Variable_Proclamation */
  int mul;    // input
  int div;    // input
  int rem;    // input
  string ans;    // output

  int i;    // subscript
  int comp; // comparison


  /* Input, Array_Proclamation */
  cin >> mul >> div >> rem;


  /* Initialize */
  // ans = "NO";


  /* Calculation */
  for(i=1; true; i++)
  {

    comp = mul * i;
    // cout << comp << " " << comp%div << endl;
    
    if(comp % div == rem)
    {
      ans = "YES";
      break;
    }
    else if(comp % div == 0)
    {
      ans = "NO";
      break;
    }

  }
  

  /* Output */
  cout << ans << endl;


  return 0;

}


/* entity */
//  - none -




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

int main(){
	int n;
  	cin >> n;
	vector<int> a(n);
	for(int i = 0; i<n;i++)
		cin >> a[i];
  	sort(a.begin(), a.end());
  	int tmp = a[0];
  	int c=1;
  	for(int i = 1; i<n;i++) {
		if(a[i] != tmp) {
          	tmp = a[i];
          	c++;
        }
	}
  	cout << c << endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
using P = pair<int,int>;
#define MOD 2019

int main()
{
  int N;cin>>N;
  vector<int> A(N+1);
  for (int i=1;i<=N;i++)
    cin>>A[i];
  
  //山１に降った雨をRとして二分探索する
  ll r = pow(10,10);
  ll l = -1;
  while (r-l>1)
  {
    ll mid = (r-l)/2 + l;
    ll tmp = mid;
    for (ll i=1;i<=N;i++)
    {
       tmp = A[i] - tmp/2;
       tmp *= 2;
    }
    if (mid <= tmp) l = mid;
    else r = mid;
    //cout<<l<<" "<<r<<endl;
  }
  
  //lが山１に降った雨です！
  ll ans=l;
  cout<<ans<<" ";
  for (ll i=1;i<N;i++)
  {
    ans = A[i] - ans/2;
    ans *= 2;
    cout<<ans<<" ";
  }
}

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

int main() {
  int A, B,C;
  cin >> A >> B >> C;
  bool tr= false;
  if (A==C&&C==B) {
    tr=true;
  }
  if(tr){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{ 
  int N;cin>>N;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
  }
  sort(ALL(vec));
  reverse(ALL(vec));
  priority_queue<int> q;
  q.push(vec[0]);
  int res = 0;
  for (int i = 1; i < N; i++)
  {
    res += q.top();
    q.pop();
    q.push(vec[i]);
    q.push(vec[i]);
  }
  

  cout<<res<<endl;
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 6896
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    pair<int , int> p[N];
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        p[i] = make_pair(tmp, i+1);
    }
    
    // 昇順ソート（第一要素）
    sort(p, p + N);

    for(int i=0;i<N;i++){
        if(i != 0)
            cout << ' ';
        cout << p[i].second;
    }
    cout << endl;

}

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

int main() {
	int N;
	cin >> N;
	int D[N][2];
	int count = 0;
	int flag = 0;
	for(int i=0;i<N;i++){
		for(int j=0; j < 2; j++){
			cin >> D[i][j];
		}
		if(D[i][0] ==D[i][1]){
			count++;
		}else{
			count = 0;
		}
		if(count >=3){
			flag = 1;
		}
	}
	if(flag == 1) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
  
}


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

int main() 
{
  int dice[6];
  int temp;
  char order[200];
  int i;
  for(i = 0;i < 6;++i){
    cin >> dice[i];
  }
  cin >> order;
  for(i = 0; order[i] != '\0';++i){
    if(order[i] == 'N'){
      temp = dice[0];
      dice[0] = dice[1];
      dice[1] = dice[5];
      dice[5] = dice[4];
      dice[4] = temp;
    }else if(order[i] == 'W'){
      temp = dice[0];
      dice[0] = dice[2];
      dice[2] = dice[5];
      dice[5] = dice[3];
      dice[3] = temp;
    }else if(order[i] == 'S'){
      temp = dice[0];
      dice[0] = dice[4];
      dice[4] = dice[5];
      dice[5] = dice[1];
      dice[1] = temp;
    }else{
      temp = dice[0];
      dice[0] = dice[3];
      dice[3] = dice[5];
      dice[5] = dice[2];
      dice[2] = temp;
    }
  }
  cout << dice[0] << endl;
  return 0;
}


Measured memory_bytes: 3092
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			int A = sc.nextInt();
			int B = sc.nextInt();
			int C = sc.nextInt();
			int D = sc.nextInt();
			
			while(true) {
				C -= B;
				if(C <= 0) {
					System.out.println("Yes");
					return;
				}
				
				A -= D;
				if(A <= 0) {
					System.out.println("No");
					return;
				}
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 32792
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	c := b - a
	l := 0
	for i := 1; i <= 999; i++ {
		r := l + i
		if r-l == c {
			fmt.Println(l - a)
			return
		}
		l = r
	}
}


Measured memory_bytes: 512
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
count=0
for i in range(N):
	x=A[N-i]+A[N-1-i]
	count+=min(x,B[N-i-1])
	A[N-i-1]=max(0,A[N-i-1]-max(0,B[N-i-1]-A[N-i]))
print(count)

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

int main(){
    double R;
    cin >> R;

    double ans = 2.0 * 3.141592 * R;
    cout << fixed << setprecision(10);
    cout << ans << endl;

    return 0;
}


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

int main(){
	fast_io();
	int n;
	cin >> n;
	vector<int> v(n);
	cu(i,0,n){
		cin >> v[i];
	}
	vec<vec<ll>> dp(n, vec<ll>(n, 0));
	vec<vec<ll>> s(n, vec<ll>(n, 0));
	cu(i,0,n)s[i][i] = v[i];
	cu(l,1,n){
		cu(i,0,n-l){
			dp[i][i + l] = LLONG_MAX;
			cu(j,i,i+l){
				dp[i][i+l] = min(dp[i][i+l], dp[i][j] + dp[j+1][i+l] + s[i][j] + s[j+1][i+l]);
			}
			s[i][i + l] = s[i][i] + s[i+1][i+l];
		}
	}
	cout << dp[0][n-1] << '\n';
}


Measured memory_bytes: 2816
// be name khoda
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin >> x;
    if (x>=30) cout<<"Yes";
    else cout<<"No";
    return 0;
}

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

int a[10004],b[10004];

int main() {
    ios::sync_with_stdio(0);
    int n;
    cin>>n;
    for(int x=1;x<=n;x++) {
        int y = x*1.08;
        if(y==n) {
            cout<<x<<endl; return 0;
        }
    }
    cout<<":("<<endl;
    return 0;
}




Measured memory_bytes: 256
#074-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
w1,w2,s1,s2,c,lim=IL()
l=[]
for i in range(31):
    for j in range(31):
        w=w1*i*100+w2*j*100
        if w<lim:
            l.append(w)
ans_c=0
ans=[100*w1,0]
for w in l:
    maxs=min(c*w//100,lim-w)
    maxs1=maxs//s1+1
    maxs2=maxs//s2+1
    for i in range(maxs1+1):
        for j in range(maxs2+1):
            s=s1*i+s2*j
            if s+w!=0:
                if s+w<=lim and s<=maxs and ans_c<100*s/(s+w):
                    ans_c=100*s/(s+w)
                    ans=[s+w,s]
print(ans[0],ans[1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i =(b)-1;i>=(a);--i)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
typedef vector<int> vi;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 10;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << ((c/b+(c%b != 0)) <= (a/d + (a%d != 0)) ? "Yes" : "No" );
	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
#include<iomanip>

#define	rep(i, n) for(int i=0; i<n; i++)

#define P pair<int, int>

typedef long long ll;

using namespace std;

#include <string>
#include <cctype>
typedef string::const_iterator State;
class ParseError {};


int main() {
	int N, M, D;
	cin >> N >> M >> D;
	string place[105];
	rep(i, N) cin >> place[i];

	int ans = 0;
	rep(i, N) {
		int cnt = 0;
		rep(j, M) {
			if (place[i][j] == '.') cnt++;
			else cnt = 0;
			if (cnt >= D) ans++;
		}
	}
	rep(j, M) {
		int cnt = 0;
		rep(i, N) {
			if (place[i][j] == '.') cnt++;
			else cnt = 0;
			if (cnt >= D) ans++;
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3176
#include <iostream>

using namespace std;

int main()
{
    char c ;
    cin >> c ;
    if  ( ( c == 'a' ) || ( c == 'u' ) || ( c == 'e' ) || ( c == 'i' ) || ( c == 'o' ) )
        cout << "vowel" ;
    else
        cout << "consonant" ;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> num(0);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    num.push_back(1);
    for (int i = 1; i < n; i++) {
        if (a.at(i - 1) == a.at(i)) {
            num.at(num.size() - 1)++;
        }
        else num.push_back(1);
    }
    sort(num.begin(), num.end());
    int ans = 0;
    if (num.size() <= k) {
        cout << ans << endl;
        return 0;
    }
    else {
        for (int i = 0; i < num.size() - k; i++) {
            ans += num.at(i);
        }
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 2168
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

using Graph = vector<vector<int>>;
int main(){
  int N; cin >> N;

  Graph G(N);
  if (N % 2 == 0){
    for (int i = 0; i < N; ++i){
      for (int j = i + 1; j < N; ++j){
        if (j != N - i - 1) G[i].push_back(j);
      }
    }
  }
  else{
    for (int i = 0; i < N; ++i){
      for (int j = i + 1; j < N; ++j){
        if (j != N - i - 2) G[i].push_back(j);
      }
    }
  }

  int M = 0;
  for (int i = 0; i < N; ++i){
    for (auto v: G[i]){
      M++;
    }
  }
  cout << M << endl;
  for (int i = 0; i < N; ++i){
    for (auto v: G[i]){
      if (!G[i].empty()) cout << i + 1 << " ";
      cout << v + 1 << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n;
	cin >> n;
	vector<P> vec;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		vec.emplace_back(a,i);
	}
	sort(all(vec));
	for(int i = 0;i < n;i++) cout << (i ? " " : "") << vec[i].second + 1;
	cout << endl;
}

Measured memory_bytes: 2544