akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long long dp[(1<<17)];
long long arr[16][16];
long long sum[(1<<17)];
int n;
long long rec(int mask){
	if(mask == 0)return 0;
	if(dp[mask] != -1)return dp[mask];
	long long ret = 0;
	for( int i = mask; i > 0; i = ((i-1)&mask)){
		ret = max(ret, sum[i] + rec(mask^i));
	}
	return dp[mask] = ret;
}
int main(){
	cin >> n;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			cin >> arr[i][j];
	for(int i = 0; i < (1<<17); i++)
		dp[i] = -1;
	for(int i = 0; i < (1<<n); i++){
		for(int j = 0; j < n; j++){
			if((i & (1<<j)) == 0)continue;
			for(int k = j+1; k < n; k++){
				if((i & (1<<k)) != 0){
					sum[i] += arr[j][k];
				}
			}
		}
	}
	cout << rec((1<<n)-1);
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;

ll N, ans;

void dfs(string s, int e7, int e5, int e3) {
    if(stoll(s) > N) return;
    if(stoll(s) <= N and e7 and e5 and e3) ans++;
    dfs(s+"7", true, e5, e3);
    dfs(s+"5", e7, true, e3);
    dfs(s+"3", e7, e5, true);
}

int main() {
    cin >> N;
    dfs("0", 0, 0, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < int(b); ++i)
#define rrep(i,b,a) for(int i = (b); i --> int(a);)
#define trav(i,v) for(auto&i:v)
#define all(c) (c).begin(), (c).end()
#define sz(c) int((c).size())
#define vcr(v,n) vi v(n); trav(var,v) cin >> var;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	ll n;
	cin >> n;
	ll k = n/11;
	n %= 11;
	cout << 2*k + (n > 0) + (n > 6) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long gcd(long a, long b) {
  if(a < b) gcd(b, a);
  long r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
long lcm(long a, long b) {
  long c;
  c=gcd(a,b);
  return a*b/c;
}
int main() {
  long N, M;
  string S, T;
  cin>>N>>M;
  cin>>S>>T;
  long a,b,c;
  a=gcd(N,M);
  b=N/a;
  c=M/a;
  bool ok=true;
  for(long i=0;i<a;i++){
    if(S.at(i*b)!=T.at(i*c)){
      ok=false;
      break;
    }
  }
  if(ok){
    cout<<lcm(N,M)<<endl;
  }else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

#define x first
#define y second
#define NMAX 100005

int a, b, c;

int main (){
    
    scanf("%d%d%d",&a,&b,&c);
    if(a == b && b == c) {
        if((a&1))
            printf("0\n");
        else
            printf("-1\n");
        return 0;
    }
    
    int step = 0;
    while((!(a & 1)) && (!(b & 1)) && (!(c & 1))) {
        int a2 = b / 2 + c / 2;
        int b2 = a / 2 + c / 2;
        int c2 = a / 2 + b / 2;
        a = a2;
        b = b2;
        c = c2;
        step++;
    }
    
    printf("%d\n", step);
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;
const int INF = 1001001001;

int main() {

    int x[5];
    for (int i = 0; i < 5; i++)
    {
      cin >> x[i] ;
      if(x[i]==0){
        cout << i+1 << endl ;
        return 0 ;
      }
    }
        return 0; 
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstring>
using namespace std;
char buf[150][150];
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
bool check(int tx,int ty)
{
    if(tx<0||ty<0)return false;
    return buf[tx][ty]=='#';
}
void solve(int x)
{
    memset(buf,' ',sizeof(buf));
    for(int i=1;i<=x;i++)
    {
        for(int j=1;j<=x;j++)
        {
            buf[i][j]='#';
        }
    }
    int X=x,Y=2;
    int cnt=0;
    for(int p=0;p<=10000;p++)
    {
        if(X>x+10||Y>x+10||X<0||Y<0)break;
        if(x%4==1&&X==(x+3)/2&&Y==(x+1)/2)break;
        if(x%4==3&&X==(x+1)/2&&Y==(x+3)/2)break;
        buf[X][Y]=' ';
        X+=dx[cnt];Y+=dy[cnt];
        if(check(X+dx[cnt],Y+dy[cnt])&&!check(X+dx[cnt]*2,Y+dy[cnt]*2))
        {
            cnt++;
            cnt%=4;
        }
    }
    for(int i=1;i<=x;i++)
    {
        for(int j=1;j<=x;j++)
        {
            cout << buf[i][j];
        }
        cout << endl;
    }
    return;
}
int main()
{
    int q;
    cin >> q;
    for(int i=0;i<q;i++)
    {
        int k;
        cin >> k;
		if(k==2)
		{
			cout << "##" << endl;
			cout << "# " << endl;
		}
        else solve(k);
		if(i!=q-1)cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

const int N = 305;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n , sz[N] , parent[N];
long long mas[N][N];
long long answ;
vector < pair< long long,pair<int,int> > > g;
vector <int> G[N];

int find_her(int x){
    if(x == parent[x])return x;
    return parent[x] = find_her(parent[x]);
}

void tmerge(int a,int b,long long c){
    int aa = a , bb = b;
    int d1 = aa , d2 = bb;
    a = find_her(a);
    b = find_her(b);
    if(sz[a] < sz[b]){
        swap(a , b);
        swap(aa , bb);
        swap(d1 , d2);
    }
    for(int i=0;i<(int)G[a].size();i++){
        for(int j=0;j<(int)G[b].size();j++){
            int gag1 = G[a][i];
            int gag2 = G[b][j];
            aa = d1;
            bb = d2;
            if(gag1 > gag2){
                swap(gag1 , gag2);
                swap(aa , bb);
            }
            mas[gag1][gag2] = min(mas[gag1][gag2] , mas[min(aa , gag1)][max(aa , gag1)] + c + mas[min(bb , gag2)][max(bb , gag2)]);
        }
    }
    if(a != b){
        sz[a] += sz[b];
        parent[b] = a;
        for(int i=0;i<(int)G[b].size();i++) G[a].push_back(G[b][i]);
        G[b].clear();
    }
}

int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        parent[i] = i;
        sz[i] = 1;
        G[i].push_back(i);
    }
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            mas[i][j] = 1ll * inf * inf;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            long long val;
            scanf("%lld",&val);
            if(i < j) g.push_back(make_pair(val , make_pair(i,j)));
        }
    }
    sort(g.begin() , g.end());
    for(int i=0;i<(int)g.size();i++){
        long long x = g[i].first;
        int a = g[i].second.first;
        int b = g[i].second.second;
        if(x > mas[a][b]){
            cout<<-1<<endl;
            return 0;
        }
        if(x == mas[a][b])continue;
        answ += x;
        tmerge(a , b , x);
    }
    cout<<answ<<endl;
    return 0;
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define M 1000000007
#define allv v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define mx 1000010

ll f(ll n){
	if(n%4==0)return n;
	if(n%4==1)return 1;
	if(n%4==2)return n+1;
	if(n%4==3)return 0;
}
int main(){
	IOS;
	ll a,b;cin>>a>>b;
	ll ans;
	if(a>=1)
	ans=f(a-1)^f(b);
	else ans=f(b);
	cout<<ans;
	return 0;
}



Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Summarize count of factor within list -- START --
def summarize_list(l):
  sl=sorted(l)

  a=sl[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append([a,c])
      a=x
      c=1
  res.append([a,c])

  return res
# Summarize count of factor within list --- END ---

# nCr -- START --
def nCr(n):
  return (n*(n-1))//2
# nCr --- END ---

def main():
  n=I()
  l=LI()
  mp=[0]*(n+1)

  sl=summarize_list(l)
  # print(sl)

  ans=0
  for x,c in sl:
    mp[x]=c
    ans+=nCr(c)

  # print(mp)
  # print(ans)

  for x in l:
    print(ans-nCr(mp[x])+nCr(mp[x]-1))

main()
# print(main())


Measured memory_bytes: 117060
M,D = list(map(int,input().split()))
ans = 0
for m in range(1,M+1):
  for d in range(1,D+1):
    if d < 11:
      continue
    d1,d2 = map(int,list(str(d)))
    if d1*d2 == m and d1 != 1 and d2 != 1:
      ans += 1
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
    int n, a1, a2, a3, a4;
    cin >> n;
    a1 = n / 1000;
    a2 = (n - 1000 * a1) / 100;
    a3 = (n - 1000 * a1 - 100 * a2) / 10;
    a4 = n - 1000 * a1 - 100 * a2 - 10 * a3;

    if (a2 != a3)
    {
        cout << "No" << endl;
    }
    else if (a1 == a2 || a4 == a3)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

typedef long long ll;

const int MAXN = ((int)2e5) + 1;
string s;
string t;


int main() {
	ios_base::sync_with_stdio(0);
	
	cin >> s;
	int n = s.size();
	
	for(int i = 0; i < n; i++) {
		if(i < n-1 && s[i] == 'B' && s[i+1] == 'C') {
			t.push_back('B');
			i++;
		} else {
			t.push_back(s[i] == 'A' ? 'A' : '$');
		}	
	}
	n = t.size();
	
	ll ans = 0;
	int cntA = 0;
	
	for(int i = 0; i < n; i++) {
		if(t[i] == '$') {
			cntA = 0;
		} else {
			if(t[i] == 'B') ans += cntA;
			if(t[i] == 'A') cntA++;
		}
	}

	cout << ans << '\n';
	
	return 0;
}



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

int main(){
  long long int N, A, B;
  long long int d, t;
  
  cin >> N >> A >> B ;
  
  if((B - A) % 2 == 0){
    cout << (B - A) / 2;
  }
  else{
    if((N-B) > (A-1)){
      d = A-1;
    }
    else{
      d = N-B;
    }
    t = (B - A) / 2;
    cout << d + t + 1;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

vector<int> a;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    a.resize(n);
    vector<int> s(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    sort(all(a));
    s[0] = a[0];
    rep(i, 1, n) s[i] = s[i - 1] + a[i];
    int end = -1;
    repb(i, n - 2, 0){
        if(s[i] * 2 < a[i + 1]){
            end = i;
            break;
        }
    }
    cout << n - 1 - end << endl;
}

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

using namespace std;

int main(){
    string s;
    cin >> s;
    if(s.length()%2==0){
        int cnt=0;
        for(int i=0;i<s.length()/2;i++){
            if(s[i]!=s[s.length()-i-1]){
                cnt++;
            }
        }
        cout << cnt << endl;
    }
    else{
        int cnt=0;
        for(int i=0;i<(s.length()-1)/2;i++){
            if(s[i]!=s[s.length()-i-1]){
                cnt++;
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

int n,k,mod=1e9+7;
vector<vector<int>> graph(100010);

ll dfs(int now,int from)
{
    ll canuse,ans=1;
    if(from==-1)canuse=k-1;
    else canuse=k-2;
    //if(k<graph[now].size())return 0;
    //else{
        for(auto x:graph[now])
        {
            if(x==from)continue;
            ans*=canuse;
            canuse--;
            ans%=mod;
        }
        for(auto x:graph[now])
        {
            if(x==from)continue;
            ans*=dfs(x,now);
            ans%=mod;
        }
        return ans;
    //}
}

int main()
{
    cin>>n>>k;
    REP(i,n-1)
    {
        int a,b;cin>>a>>b;a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    ll ans=k*dfs(0,-1);ans%=mod;
    cout<<ans<<endl;
}

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

using namespace std;

const int MOD = 1000000007;

int add(int x, int y) { return ((x += y) >= MOD) ? x - MOD : x; }
int mul(int x, int y) { return (long long) x * y % MOD; }
int pw(int x, int y) {
   int ans = 1;
   for (; y > 0; y >>= 1, x = mul(x, x)) {
      if (y & 1) ans = mul(ans, x);
   }
   return ans;
}

int main() {
   ios_base::sync_with_stdio(false);
   int N;
   cin >> N;
   vector<int> X(N);
   for (int i = 0; i < N; ++i) {
      cin >> X[i];
   }
   int coeff = 0;
   int ans = 0;
   int fact = 1;
   for (int i = 0; i + 1 < N; ++i) {
      coeff = add(coeff, pw(i + 1, MOD - 2));
      fact = mul(fact, i + 1);
      ans = add(ans, mul(coeff, X[i + 1] - X[i]));
   }
   cout << mul(ans, fact) << "\n";
   return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
void print(vector<vector<long long int>> &dp)
{
    for(long long int i=0;i<dp.size();i++)
    {
        for(long long int j=0;j<dp[0].size();j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
}
int main() 
{
	long long int n,k;
	cin>>n>>k;
	vector<long long int> A(n);
	for(long long int i=0;i<n;i++)
	{
	    cin>>A[i];
	}
	vector<vector<long long int>> dp(n,vector<long long int>(k+1));
	vector<vector<long long int>> prefix(n,vector<long long int>(k+1));
	for(long long int i=0;i<n;i++)
	{
	    for(long long int j=0;j<=k;j++)
	    {
	        if(j==0)
	        {
	            dp[i][j]=1;
	            prefix[i][j]=1;
	            continue;
	        }
	        if(i==0)
	        {
	            if(j<=A[i])
	            {
	                dp[i][j]=1;
	            }
	            else
	            {
	                dp[i][j]=0;
	            }
	            prefix[i][j]=((prefix[i][j-1])%mod+(dp[i][j])%mod)%mod;
	            continue;
	        }
	        long long int index=max((long long int)0,j-A[i]);
	        if(index==0)
	        {
	            dp[i][j]=prefix[i-1][j];
	        }
	        else
	        {
	            dp[i][j]=(((prefix[i-1][j]%mod)-(prefix[i-1][j-A[i]-1]%mod)+mod)%mod);
	        }
	        prefix[i][j]=((prefix[i][j-1]%mod)+(dp[i][j]%mod))%mod;
	    }
	} 
// 	print(dp);
// 	print(prefix);
	cout<<dp[n-1][k]; 
}

Measured memory_bytes: 157552
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ld pie=3.1415926535;
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,k; cin>>n>>k;
    if((n-1)*(n-2)/2<k){
        cout<<-1<<endl;
    }
    else{
        cout<<n-1+(n-1)*(n-2)/2-k<<endl;
        rep(i,n-1) cout<<i+1<<" "<<n<<endl;
        int cnt=(n-1)*(n-2)/2-k;
        for(int i=1;i<=n-2;i++){
            for(int j=i+1;j<=n-1;j++){
                if(cnt==0){
                    i=n; j=n; continue;
                }
                cout<<i<<" "<<j<<endl;
                cnt--;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
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 N;
int u[100100],v[100100],w[100100];
vector<pair<int,int>> V[100100];
int col[100100];
bool used[100100];

void solve(int X){
    REP(i,V[X].size()){
        if(used[V[X][i].first] == 1) continue;
        if(V[X][i].second == 0){
            col[V[X][i].first] = col[X];
            used[V[X][i].first] = 1;
            solve(V[X][i].first);
        }
        else{
            col[V[X][i].first] = abs(col[X] - 1);
            used[V[X][i].first] = 1;
            solve(V[X][i].first);
        }
    }
}

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    cin >> N;
    REP(i,N-1){
        cin >> u[i] >> v[i] >> w[i];
        u[i]--;v[i]--;
        w[i] %= 2;
        V[u[i]].pb({v[i],w[i]});
        V[v[i]].pb({u[i],w[i]});
    }
    col[0] = 0;
    used[0] = 1;
    solve(0);
    REP(i,N){
        cout << col[i] << endl;
    }
}

Measured memory_bytes: 9600
#include <iostream>
using namespace std;
using std::swap;
int main()
{	
	int a[5],b[5],i,j,t;
	t = 0;
	for (i = 0; i < 5; ++i) {
		cin >> a[i];
		if (a[i] % 10 == 0)b[i] = 0;
		else b[i] = 10 - (a[i] % 10);
	}
	for (i = 0; i < 5; ++i) {
		for (j = i + 1; j < 5; ++j) {
			if (b[j] < b[i]) { 
				swap(b[j], b[i]);
				swap(a[j],a[i]);
			}
		}
	}
	for (i = 0; i < 5; ++i) {
		if (i != 4)t += (a[i] + b[i]);
		else t += a[i];
	}
	cout << t << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef pair<double,ll> pdl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<pdd> vdd;
typedef vector<pdi> vdi;
typedef vector<pdl> vdl;
typedef vector<string> vs;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
const ll MOD=1000000007;
const ll mod=998244353;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template<class T>
void rsort(vector<T>& v){
	sort(v.rbegin(),v.rend());
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
bool is_sorted(vector<T>& v){
	return is_sorted(v.begin(),v.end());
}
template<class T>
bool sorted(vector<T>& v){
	return is_sorted(v);
}
void precompute(){

	return;
}
void solve(){
	int n,m,k;
	cin>>n>>m>>k;
	vvl v(n+1,vl(m+1));
	while(k--){
		int a,b,c;
		cin>>a>>b>>c;
		v[a][b]=c;
	}
	vector<vvl> dp(n+1,vvl(m+1,vl(4)));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			dp[i][j][0]=max(dp[i][j-1][0],dp[i-1][j][0]);
			dp[i][j][1]=max(max(dp[i][j-1][0],max(dp[i-1][j][0],max(dp[i-1][j][1],max(dp[i-1][j][2],dp[i-1][j][3]))))+v[i][j],dp[i][j-1][1]);
			dp[i][j][2]=max(dp[i][j-1][1]+v[i][j],dp[i][j-1][2]);
			dp[i][j][3]=max(dp[i][j-1][2]+v[i][j],dp[i][j-1][3]);
		}
	}
	cout<<max(dp[n][m][0],max(dp[n][m][1],max(dp[n][m][2],dp[n][m][3])));
	return;
}

int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	precompute();
	for(int looping=1;looping<=numberofsubtestcases;looping++){
//		cout<<"Case #"<<looping<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 706720
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = in.nextInt();
        }
        int way = 0;
        for (int i = 0; i < n - 2; i++) {
            if ((arr[i] > arr[i + 1] && arr[i + 1] > arr[i + 2]) || (arr[i] < arr[i + 1] && arr[i + 1] < arr[i + 2])) {
                way++;
            }
        }
        System.out.println(way);
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int n,m;
	cin>>n>>m;
	ce((n-1)*(m-1))
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	int a,b;
	cin>>a>>b;
	int f[b+1],sum=0;
	for(int i=1;i<=b;i++){
		cin>>f[i];
		sum+=f[i];
	}
	if(sum<a){
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
	long long n;
	cin>>n;
	vector< long long > a;
  for( long long i = 0; i<n; i++ )
  {
    a.push_back(i+1);
  }
  long long ans;
  ans = 0;
  for (long long i = 0; i < n; i++)
  {
    if( a[i]%3==0 || a[i]%5==0 )
    {
        continue;
    }
    else
    {
        ans = ans + a[i];
       
    }
  }
  cout<<ans;
  
    
}

Measured memory_bytes: 11504
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>

using namespace std;

template <class T>
using lp_queue=priority_queue<T, deque<T>, greater<T>>;

using Weight=int;
using DArray=vector<Weight>;
using DMatrix=vector<DArray>;

static const Weight INF=(1<<30)-1;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

bool shortest_distance(const Graph &g, size_t s, vector<Weight> &d) {
    /* Bellman-Ford */
    // returns true iff g has no negative cycles
    size_t V=g.size();
    d.assign(V, INF); d[s]=0;
    bool negative_cycle=false;
    for (size_t k=0; k<V; ++k)
        for (size_t i=0; i<V; ++i)
            for (const Edge &e: g[i])
                if (d[e.dst] > d[e.src] + e.weight && d[e.src] < INF) {
                    d[e.dst] = d[e.src] + e.weight;
                    if (k == V-1) {
                        d[e.dst] = -INF;
                        negative_cycle = true;
                    }
                }

    return !negative_cycle;
}

int main() {
    size_t V, E, r;
    scanf("%zu %zu %zu", &V, &E, &r);

    Graph g(V);
    for (size_t i=0; i<E; ++i) {
        size_t s, t;
        Weight d;
        scanf("%zu %zu %d", &s, &t, &d);

        connect(g, s, t, d);
    }

    vector<Weight> d;
    bool has_ncycle=!shortest_distance(g, r, d);

    if (has_ncycle)
        return !printf("NEGATIVE CYCLE\n");

    for (Weight w: d)
        if (w < INF) {
            printf("%d\n", w);
        } else {
            printf("INF\n");
        }

    return 0;
}

Measured memory_bytes: 2800
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    long long count=0;
    if(n>=500);
    {count+=(n/500*1000);n%=500;}
    count+=(n/5*5);
    printf("%lld\n",count);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define speed                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define pb push_back
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define endl "\n"
#define mod 1000000007
#define mod1 998244353
#define ff first
#define ss second
#define MAX 500005
#define N 10004
#define INF 1000000009
#define all(v) v.begin(), v.end()
#define sbit(a) __builtin_popcount(a)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<ll, ll> pll;
typedef pair<pll, ll> ppl;
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
ll power(ll x, ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0)
        return 0;
    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }

    return res;
}
void solve()
{

    ll n, x, m;
    cin >> n >> x >> m;
    ll ans = x;
    ll t = x * x;
    ll c = 0;
    map<ll, ll> mp;
    n--;
    ll s[m + 1];
    mem0(s);
    ll tans = 0;
    ll tmp;
    for (ll i = 1; i <= (n,m + 1); i++)
    {
        ll md = t % m;
        if (!mp.count(md))
        {
            tans += md;
            t = md * md;
        }
        else
        {
            c = i - mp[md];
            tmp = mp[md];
            break;
        }
        mp[md] = i;
        s[i] = tans;
    }
    if (mp.count(0))
    {
        ans += tans;
        cout << ans << endl;
        return;
    }
    tmp--;
    n -= tmp;
    ll div = n / c;
    ll md = n % c;
    ans += (div * (s[c + tmp] - s[tmp]));
    ans += s[tmp];
    ans += s[tmp + md] - s[tmp];
    cout << ans << endl;
}
int main()
{
    speed;
    ll kk;
    kk = 1;
    //cin >> kk;
    while (kk--)
    {

        solve();
    }

    return 0;
}

Measured memory_bytes: 7548
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
const int maxn = 200000 + 5;
int a[maxn];
int main(){
	int n,k;
	cin >> n >> k;
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i = k;i<n;i++){
		if(a[i]>a[i-k]){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 3940
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    String S = scanner.next();
    String T = scanner.next();
    int count = 0;
    for(int i = 0;i < S.length();i++){
      if(S.charAt(i) == T.charAt(i)) continue;
      count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 41284
function bigAdd(x,y){
   var a=(x+"").split("").reverse().map(Number);
   var b=(y+"").split("").reverse().map(Number);
   var c=[];
   var max=Math.max(a.length,b.length);
   for(var i=0;i<max+1;i++)c[i]=0;
   for(var i=0;i<max;i++){
      var sum=0;
      if(a.length>i)sum+=a[i];
      if(b.length>i)sum+=b[i];
      c[i]+=sum;
   }
   for(var i=0;i<max;i++){
      if(c[i]>=10){
         c[i]-=10;
         c[i+1]++;
      }
   }
   if(c[c.length-1]==0)c.pop();
   var str=c.reverse().join("");
   return str;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.trim().split("\n");
while(true){
   if(Arr.length==0)break;
   var arr=Arr.shift().split(/[\+\=]/);
   var ans=[];
   for(var i=0;i<=9;i++){
      var a=arr[0].replace(/X/g,i);
      var b=arr[1].replace(/X/g,i);
      var c=arr[2].replace(/X/g,i);
      if(bigAdd(a,b)==c)ans.push(i);
   }
   console.log((ans.length==1)?ans[0]:"NA");
}

Measured memory_bytes: 10476
#include<iostream>
using namespace std;
typedef long long int ll;

ll GCD(ll,ll);
ll a, b, gcd, lcm, temp;

int main(void){
	while(cin >> a >> b){
		if( a < b){
			temp = a;
			a = b;
			b = temp;
		}
		gcd = GCD(a,b);
		lcm = a * b / gcd;
		cout << gcd << ' ' << lcm << endl;
	}
	return 0;
}

ll GCD(ll a, ll b){
	if(a % b == 0)
		return (b);
	else
		return (GCD(b, a%b));
}

Measured memory_bytes: 1152
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

        int N = scanner.nextInt();
        Map<Integer, Integer> primeMap = new HashMap<>();
        for (int i = 2; i <= N; i++) {
            Map<Integer, Integer> tempMap = getPrimeMap(i);
            for (Map.Entry<Integer, Integer> e : tempMap.entrySet()) {
                if (primeMap.containsKey(e.getKey())) {
                    int temp = primeMap.get(e.getKey());
                    primeMap.put(e.getKey(), temp + e.getValue());
                } else {
                    primeMap.put(e.getKey(), e.getValue());
                }
            }
        }

        Map<Integer, Integer> map = new HashMap<>();
        int n3 = 0;
        int n5 = 0;
        int n15 = 0;
        int n25 = 0;
        int n75 = 0;
        for (Map.Entry<Integer, Integer> e : primeMap.entrySet()) {
            if (e.getValue() > 1) {
                if (e.getValue() >= 74) {
                    n75++;
                }
                if (e.getValue() >= 24) {
                    n25++;
                }
                if (e.getValue() >= 14) {
                    n15++;
                }
                if (e.getValue() >= 4) {
                    n5++;
                }

                n3++;
            }
        }

        int temp = n75
                + n25 * (n3-1)
                + n15 * (n5-1)
                + (n3-2) * n5 * (n5-1) / 2;
        System.out.println(temp);
    }

    static Map<Integer, Integer> getPrimeMap(int n) {
        int i = 2;
        int tmp = n;

        Map<Integer, Integer> primeMap = new HashMap<>();
        while (i * i <= n) {
            if (tmp % i == 0) {
                tmp /= i;
                int a = 0;
                if (primeMap.containsKey(i)) {
                    a = primeMap.get(i);
                }
                primeMap.put(i, a+1);
            } else {
                i++;
            }
        }
        if (tmp != 1) {
            int a = 0;
            if (primeMap.containsKey(i)) {
                a = primeMap.get(tmp);
            }
            primeMap.put(tmp, a+1);
        }

        return primeMap;
    }

}


Measured memory_bytes: 22868
east :: String -> Int-> [Int]
east [] n = []
east (x:xs) n 
  | x == 'E' = (n+1) : (east xs (n+1))
  | otherwise = n : (east xs n)

west :: String -> Int -> [Int]
west [] n = []
west (x:xs) n 
  | x == 'W' = (n+1) : (west xs (n+1))
  | otherwise = n : (west xs n)

main = do
  n <- (read :: String -> Int) <$> getLine
  s <- getLine
  let y = zipWith (+) (reverse $ east (reverse s) 0) (west s 0)
  putStrLn . show $ (-) (minimum y) 1


Measured memory_bytes: 43388
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int n = s.size();
	vector<int> table(n, 0);
	if(s[0]=='A'||s[0]=='G'||s[0]=='T'||s[0]=='C')table[0]=1;
	for(int i = 1; i < n; ++i){
		char c = s[i];
		if(c == 'A' || c == 'G' || c == 'T' || c == 'C'){
			table[i] = table[i - 1] + 1;;
		}
		else{
			table[i] = 0;
		}
	}
	int res = 0;
	for(int i = 0; i < n; ++i){
		res = max(res, table[i]);
	}
	cout<<res<<endl;	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
using ld = long double;
using ml = boost::multiprecision::cpp_int;

namespace NyaGadget
{
#define rep(i, b, e) for (ll i = b; i < e; i++) // repeat
	/********** for each macro **********/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)

	/*** 二次元累積和ライブラリ***/

	struct CumulativeSum2D
	{
		vector<vector<ll>> gsum;

		/**
		@brief 二次元累積和の構築
		@param 二次元配列の行
		@param 二次元配列の列
		@param 二次元配列の値
		@note
		 引数で渡された二次元配列から累積和を構築する。
		**/
		CumulativeSum2D(ll h, ll w, const vector<vector<ll>>& v)
		{	// 0で初期化されたgsum[0][x]とgsum[y][0]も追加して配列を構築
			gsum.resize(h + 1);
			each(i, e, gsum)
				e.resize(w + 1);

			rep(y, 1, h + 1)
			{
				rep(x, 1, w + 1)
					gsum[y][x] = gsum[y - 1][x] + gsum[y][x - 1] - gsum[y - 1][x - 1] + v[y - 1][x - 1];
			}
		}

		/**
		@brief 結果取得関数
		@param ymin 左上y座標
		@param xmin 左上x座標
		@param ymax 左下y座標
		@param xmax 左下x座標
		@note
		 二次元範囲の累積結果をO(1)で出力する。
		 引数は閉区間で与える。
		**/
		ll Result(ll ymin, ll xmin, ll ymax, ll xmax)
		{	// 累積和のgsumは元の座標と1ずつずれているので調整
			ymin++; xmin++; ymax++; xmax++;
			return gsum[ymin - 1][xmin - 1] + gsum[ymax][xmax] - gsum[ymax][xmin - 1] - gsum[ymin - 1][xmax];
		}
	};

#undef rep
#undef fori
#undef each
}

#define all(c) (c).begin(), (c).end()            // begin to end
#define divc(a, b) ceil((ld) a / (ld) b);        // div ceiling
#define rep(i, b, e) for (ll i = b; i < e; i++)  // repeat
#define repr(i, b, e) for (ll i = b; e < i; i--) // repeat reverse
#define size(c) ((ll) (c).size())                // collection size
#define sum(b, e) accumulate(all(b, e), 0LL)     // accumulate 
/********** const value **********/
#define llong_max 9223372036854775807            // 9 * 10^18
#define ldbl_max 1.79769e+308                    // 1.7 * 10^308
#define mod 1000000007                           // 1e9 + 7
#define pi 3.14159265                            // 3.14 ...
/********** for each macro **********/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)
#define forir(i, ...) if(ll i = size(v)) for(__VA_ARGS__) if(i--, true)
#define eachr(i, e, v) forir(i, auto& e: boost::adaptors::reverse(v))

using namespace NyaGadget;

struct Test
{
	ll money = 0;   // 費用
	ll land = 0;    // 土地の面積
};

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

	string s1, s2;
	if (size(s) % 2 == 0)
	{
		s1 = s.substr(0, size(s) / 2);
		s2 = s.substr(size(s) / 2, size(s) - 1);
	}
	else
	{
		s1 = s.substr(0, size(s) / 2);
		s2 = s.substr(size(s) / 2 + 1, size(s) - 1);
	}

	reverse(all(s2));

	ll count = 0;
	each(i, e, s1)
	{
		if (s2[i] != e) count++;
	}

	cout << count;
	return 0;
}


Measured memory_bytes: 256
string_list=list(map(int,input().split()))
r=string_list[0]
D=string_list[1]
x_2000=string_list[2]
def calculate_next(x):
    return x*r-D


x_next = x_2000
for i in range(10):
    x_next=calculate_next(x_next)
    print(x_next)

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

int main() {
	int a, b;
	cin >> a >> b;
	
	if (a <= 0 && 0 <= b) { cout << "Zero" << endl; }
	else if (a > 0) { cout << "Positive" << endl; }
	else if ((b - a + 1) % 2 == 0) { cout << "Positive" << endl; }
	else { cout << "Negative" << endl; }
	
	return 0;
}

Measured memory_bytes: 256
serial = list(input())
numbers = [int(s) for s in serial]
ak = "0"
bk = "0"
ck = "0"
for ai in range(2):
    for bi in range(2):
        for ci in range(2):
            kotae = 0
            if ai == 0:
                kotae = numbers[0] + numbers[1]
            else:
                kotae = numbers[0] - numbers[1]
            if bi == 0:
                kotae = kotae + numbers[2]
            else:
                kotae = kotae - numbers[2]
            if ci == 0:
                kotae = kotae + numbers[3]
            else:
                kotae = kotae - numbers[3]

            if kotae == 7:
                ak = "+" if ai == 0 else "-"
                bk = "+" if bi == 0 else "-"
                ck = "+" if ci == 0 else "-"
print(serial[0] + ak + serial[1] + bk + serial[2] + ck + serial[3] + "=7")

Measured memory_bytes: 3064
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()
ans = sum(a)
if ans%10==0:
    for i in range(n):
        if a[i] %10:
            ans -= a[i]
            print(ans)
            exit()
    ans = 0
 
print(ans)

Measured memory_bytes: 3060
sx, sy, tx, ty = map(int, input().split())
w = tx-sx
h = ty-sy
s = ""
s += "U"*h
s += "R"*w
s += "D"*h
s += "L"*w
s += "L"
s += "U"*(h+1)
s += "R"*(w+1)
s += "D"
s += "R"
s += "D"*(h+1)
s += "L"*(w+1)
s += "U"
print(s)


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

int main() {
  string str;   //今回は15文字入力と予めわかっている

  cin >> str;
  vector<int> vec(4);

    for (int i = 0; i < 4; ++i) {

        vec.at(i) = (int)(str[i] - '0');  //str[i]　はchar型なのでchar→intへ変換

        }
  bool finished = false;
  
    for (int tmp = 0; tmp < (1 << 3); tmp++) {
      bitset<3> s(tmp);
      int sum = vec.at(0);
      string shiki = to_string(vec.at(0));
      // cout << tmp << endl; //
      for(int i = 0; i < 3; i++) {
        if(s[i]) {
          sum += vec.at(i+1);
          shiki += "+";
          shiki += to_string(vec.at(i+1));   
        }
        else {
          sum -= vec.at(i+1);
          shiki += "-";
          shiki += to_string(vec.at(i+1));   
        }
        if(i == 2 && sum == 7) {
            cout << shiki + "=7";
          finished = true;
          break;
          } 
      }
      if (finished) {
        break;
      }
    }

}



Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Strivore
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000000;
const int MAX_K = 1000000;
const int MAX_M = MAX_N + MAX_K;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

char s[MAX_N + 4];
int fs[MAX_M + 1], invfs[MAX_M + 1];

/* subroutines */

int powmod(int a, int n) {  // a^n % MOD
  int pm = 1;
  while (n > 0) {
    if (n & 1) pm = (ll)pm * a % MOD;
    a = (ll)a * a % MOD;
    n >>= 1;
  }
  return pm;
}

inline int nck(int n, int k) {  // nCk % MOD
  return (ll)fs[n] * invfs[n - k] % MOD * invfs[k] % MOD;
}

void prepare_fracs(int n) {
  fs[0] = invfs[0] = 1;
  for (int i = 1; i <= n; i++) {
    fs[i] = (ll)fs[i - 1] * i % MOD;
    invfs[i] = powmod(fs[i], MOD - 2);
  }
}

/* main */

int main() {
  int k;
  scanf("%d%s", &k, s);
  int n = strlen(s);

  prepare_fracs(n + k);

  int sum = 0;

  for (int i = 0; i <= k; i++) {
    int d = 
      (ll)powmod(25, i) * powmod(26, k - i) % MOD
      * nck(n - 1 + i, n - 1) % MOD;
    sum = (sum + d) % MOD;
  }

  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 19696
#include<stdio.h>
#define reg register
#define ri reg int
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define nrep(i, x, y) for(ri i = x; i >= y; --i)
#define DEBUG 1
#define ll long long
#define max(i, j) (i) > (j) ? (i) : (j)
#define min(i, j) (i) < (j) ? (i) : (j)
struct IO {
	#define MAXSIZE (1 << 20)
	#define isdigit(x) (x >= '0' && x <= '9')
	char buf[MAXSIZE], *p1, *p2;
	char pbuf[MAXSIZE], *pp;
	#if DEBUG
	#else
		IO() : p1(buf), p2(buf), pp(pbuf) {}
		~IO() {
			fwrite(pbuf, 1, pp - pbuf, stdout);
		}
	#endif
	inline char gc() {
		#if DEBUG
    		return getchar();
		#endif
    	if(p1 == p2)
			p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin);
    	return p1 == p2 ? ' ' : *p1++;
	}
	inline bool blank(char ch) {
    	return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
	}
	template <class T>
	inline void read(T &x) {
    	register double tmp = 1;
    	register bool sign = 0;
    	x = 0;
    	register char ch = gc();
    	for(; !isdigit(ch); ch = gc())
    		if(ch == '-') sign = 1;
    	for(; isdigit(ch); ch = gc())
			x = x * 10 + (ch - '0');
    	if(ch == '.')
			for(ch = gc(); isdigit(ch); ch = gc())
        		tmp /= 10.0, x += tmp * (ch - '0');
    	if(sign) x = -x;
	}
	inline void read(char *s) {
		register char ch = gc();
		for(; blank(ch); ch = gc());
		for(; !blank(ch); ch = gc())
			*s++ = ch;
    	*s = 0;
	}
	inline void read(char &c) {
    	for(c = gc(); blank(c); c = gc());
	}
	inline void push(const char &c) {
		#if DEBUG
    		putchar(c);
		#else
    		if(pp - pbuf == MAXSIZE) {
				fwrite(pbuf, 1, MAXSIZE, stdout);
				pp = pbuf;
			}
    		*pp++ = c;
		#endif
	}
	template <class T>
	inline void write(T x) {
    	if(x < 0) {
			x = -x;
			push('-');
		}
    	static T sta[35];
    	T top = 0;
    	do{
			sta[top++] = x % 10;
			x /= 10;
    	}while(x);
    	while(top)
			push(sta[--top] + '0');
	}
	template <class T>
	inline void write(T x, char lastChar) {
    	write(x);
		push(lastChar);
	}
} io;
int n;
int main() {
	io.read(n);
	io.write((10000 - n) % 1000);
}

Measured memory_bytes: 1460
from collections import Counter
n = int(input())
mod = 10 ** 9 + 7

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

primes = []
for i in range(1, n + 1):
    p = prime_factorize(i)
    primes.extend(p)
c = Counter(primes)

ans = 1
for k, v in c.items():
    ans *= (v + 1) % mod
print(ans % mod) 


Measured memory_bytes: 39408
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;

int main(int argc, char ** argv) {
	ll n;
	cin >> n;
	n = 2*n;
	vi a(n,0);
	for(ll i=0; i<n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	ll ans = 0;
	for(ll i=(n%2); i<n; i+=2) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,sum1=0,sum2=0;
	for(int i=0;i<3;i++){
		cin>>a;
		if(a==5)
		sum1++;
		if(a==7)
		sum2++;	
	}
	if(sum1==2&&sum2==1)
	cout<<"YES";
	else
	cout<<"NO";
	
	
	
	
	return 0;
} 

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#define Abs(_A) (((_A) > 0) ? (_A) : (-(_A)))
int n;
double T, A, k = 0.006, Q = 99999, c[1111];
int h[1111], ans;
int main(){
	scanf("%d %lf %lf", &n, &T, &A);
	for(int i = 1; i <= n; i++) scanf("%d", &h[i]);
	for(int i = 1; i <= n; i++){
		c[i] = Abs(T - k * h[i] - A);
		if(c[i] < Q) ans = i, Q = c[i];
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI = 3.141592653589793;

const int M = 1e9+7;

int power(int x,int n)
{
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

void solve()
{
	int n;
	cin >> n;
	if(n==1)
	{
		cout << "0\n";

		return ;
	}
	int tot = power(10,n);
	tot %= M;
	tot -= power(9,n);
	tot += M;
	tot %= M;
	tot -= power(9,n);
	tot += M;
	tot %= M;
	tot += power(8,n);
	tot %= M;
	cout << tot << nl;
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	T=1;
	while(T--) solve();
	return 0;
}



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

using namespace std;

int main(void)
{
    int n, m, p;
    string s;
    scanf("%d", &n);
    scanf("%d", &m);
    int prob[n] = {};
    bool bprob[n] = {};
    for (int i = 0; i < m; i++)
    {
        cin >> p;
        cin >> s;
        if (!bprob[p - 1])
        {
            if (s == "WA")
                prob[p - 1]++;
            else if (s == "AC")
                bprob[p - 1] = true;
        }
    }
    int solved = 0, penalty = 0;
    for (int i = 0; i < n; i++)
    {
        if (bprob[i])
        {
            penalty += prob[i];
            solved++;
        }
    }
    printf("%d %d\n", solved, penalty);
}

Measured memory_bytes: 4252
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>

using namespace std;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

#define equal equalll
#define less lesss
typedef long long ll;
const int N = 1e6;
const long long INF = 1e9 + 19;


int k, t;
int a[N];

void read() {
    int n, k;
    scanf("%d%d", &k, &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    sort(a, a + n);
    int mx = a[n - 1];
    int other = k - mx; 
    cout << max(0, mx - 1 - other) << endl;
    
}

void solve() {
    


}

void stress() {

}


int main(){
#ifdef MY_DEBUG
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif
    if (1) {
        int k = 1;
        for (int tt = 0; tt < k; tt++) {
            read();
            solve();
        }
    }
    else {
        stress();
    }

    return 0;
}








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

struct Prime {
    int max_n;
    std::vector<int> primes;
    std::vector<bool> isp;

    explicit Prime(int max_n)
        : max_n(max_n), isp(max_n + 1, true) {
        isp[0] = isp[1] = false;
        for (int i = 2; i * i <= max_n; ++i) {
            if (isp[i]) {
                for (int j = i; i * j <= max_n; ++j) {
                    isp[i * j] = false;
                }
            }
        }

        for (int p = 2; p <= max_n; ++p) {
            if (isp[p]) primes.push_back(p);
        }
    }

    template <class T>
    bool isprime(T n) const {
        if (n <= max_n) return isp[n];
        for (T p : primes) {
            if (p * p > n) break;
            if (n % p == 0) return false;
        }
        return true;
    }

    template <class T>
    std::vector<std::pair<T, int>> factorize(T n) const {
        std::vector<std::pair<T, int>> facts;
        for (T p : primes) {
            if (p * p > n) break;
            if (n % p != 0) continue;
            int exp = 0;
            while (n % p == 0) {
                n /= p;
                ++exp;
            }
            facts.emplace_back(p, exp);
        }
        if (n > 1) {
            facts.emplace_back(n, 1);
        }
        return facts;
    }
};

const Prime P(1000000);

int main() {
    int x;
    std::cin >> x;

    for (auto p : P.primes) {
        if (p >= x) {
            std::cout << p << std::endl;
            return 0;
        }
    }

    std::terminate();
    return 0;
}


Measured memory_bytes: 1020
def isKaibun(text):
    n=len(text)
    if text[:n//2]==text[(n+1)//2:][::-1]:
        return 1
    else:
        return 0

S=input()
n=len(S)
if isKaibun(S):
    if isKaibun(S[:n//2]):
        print("Yes")  
    else:
        print("No")   
else:
    print("No")

Measured memory_bytes: 3060