akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
 
int const MAX_N = 4 * 1024 * 1024;

int s[MAX_N];
vector<pair<long long, long long> > sgm, new_sgm;

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
 
    int n;
	scanf("%d",&n);
	for (int i=0; i<n; i++) scanf("%d",&s[i]);

	if (s[n-1] != 2) {
		cout<<"-1";
		return 0;
	}

	sgm.push_back(make_pair(2LL,3LL));

	for (int i=n-2; i>=0; i--) {
		new_sgm.clear();
		long long y = s[i];
		for (int j=0;j <(int) sgm.size(); j++) {
			long long A = sgm[j].first;
			long long B = sgm[j].second;

			long long first_A = A;
			long long rem = A % y;
			if (rem != 0)
				first_A += y-rem;

			if (first_A > B)
				continue;

			rem = B % y;
			if (rem == 0) B += y-1;
			else B += y-1-rem;

			new_sgm.push_back(make_pair(first_A, B));
		}

		sgm = new_sgm;

		if (sgm.empty()) {
			cout<<"-1";
			return 0;
		}
	}

	cout<<sgm.begin()->first<<" "<<sgm.back().second;
    return 0;
}  


Measured memory_bytes: 640
import math
from fractions import gcd

import numpy as np
import scipy as scp

# 入力の受け取り
h,n = map(int,input().split())
arrA = np.array(input().split(),dtype=np.int64)

atack = sum(arrA)
if atack>=h:
    ans = "Yes"
else:
    ans = "No"
# ans = "Yes" or "No"
print(ans)

Measured memory_bytes: 22892
#include <stdio.h>

int main(void) {
  int n,k,i,j,z,ans;
  z=0;
  
  int d[10000];
  int a[10000];
  scanf("%d",&n);
  scanf("%d",&k);
  ans=n;
  for(i=0;i<k;i++)
  {
    scanf("%d",&d[i]);
    {
      for(j=0;j<d[i];j++)
      {
        scanf("%d",&a[z]);
        z++;
      }
    }
  }
  for(i=1;i<=n;i++)
  {
    for(j=0;j<z;j++)
    {
      if(i==a[j])
      {
        ans--;
        break;
      }
    }
  }
  printf("%d",ans);
  return 0;
}

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

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;

typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

typedef vector<double> VD;
typedef vector<VD> VVD;

typedef vector<string> VS;
typedef vector<VS> VVS;

typedef vector<bool> VB;
typedef vector<VB> VVB;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define fst first
#define snd second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) (x).begin(), (x).end()
#define RANGE(xx,y,mx,my) (0<=(x)&&0<=(y) && (x)<(mx) && y<(my))
#define REP(i, init, N) for(int i = (init); i < (int)(N); i++)

const int INF = 0x3f3f3f3f;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const double EPS = 1e-12;

int K;
double R, L, P, E, T;
double T1, T2;

bool eq(double a, double b) {
    return abs(a - b) < EPS;
}

bool lt(double a, double b) {
    return a < b + EPS;
}

bool el(double a, double b) {
    return eq(a, b) || lt(a, b);
}

double f(double l, double r, double p, int k) {
//    printf("%5f %5f %5f %5f %3d\n", l, r, (l + r) / 2., p, k);
    if (el(T1, l) && el(r, T2)) {
//        cout << "  " << p << endl;
        return p;
    }
    if (lt(r, T1) || lt(T2, l)) {
//        cout << "  " << 0. << endl;
        return 0.;
    }

    double h = (l + r) / 2.;

    if (k == K)  {
//        cout << "  " << (el(T1, h) && el(h, T2) ? p : 0) << endl;
        return el(T1, h) && el(h, T2) ? p : 0;
    }

//    cout << "  next" << endl;

    if (lt(h, T)) return f(h, r, (1. - P) * p, k + 1) + f(l, h, P * p, k + 1);
    else          return f(l, h, (1. - P) * p, k + 1) + f(h, r, P * p, k + 1);
}

int main(void) {
    cin >> K >> L >> R;
    cin >> P >> E >> T;

    
    T1 = T - E;
    T2 = T + E;
    
//    cout << fixed << setprecision(10) << T1 << " " << T2 << endl;

    printf("%.9f\n", f(L, R, 1, 0));
    
    return 0;
}

Measured memory_bytes: 1236
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define IREP(i, v) for(auto i = (v).begin(); i != (v).end(); ++i)
#define IRREP(i, v) for(auto i = (v).rbegin(); i != (v).rend(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    ll K, A, B; cin >> K >> A >> B;
    if(B - A <= 2 || A > K){
        cout << K + 1 << endl;
        return 0;
    }
    ll t = max(0LL, (K - (A - 1)) / 2);
    ll ans(B*t - A*(t-1));
    if((K - (A - 1)) % 2) ++ans;
    cout << ans << endl;
    return 0;
}


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

typedef struct P {
	int p, d;
	bool operator<(const P &r) {
		return d < r.d;
	}
} P;
int n, d[10001], vm;
P v[10001];

int main(){
	int p, d1, d2;
	while (cin >> n && n != 0) {
		vm = 0;
		for (int i = 0; i < n; i++) {
			cin >> p >> d1 >> d2;
			v[vm++] = { p,d1 + d2 };
		}
		P m = v[0];
		for (int i = 1; i < vm; i++) {
			if (m < v[i]) {
				m = v[i];
			}
		}
		cout << m.p << " " << m.d << endl;
	}

	return 0;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int s, w;
  cin >> s >> w;
  if (w >= s) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
   s << "{";
   for (auto i = m.begin(); i != m.end(); ++i) {
      s << i->first << ":" << i->second;
      if (next(i) != m.end()) s << ", ";
   }
   s << "}";
   return s;
}

signed main()
{
   int d; cin >> d;

   cout << "Christmas ";
   rep(i, 0, 25-d) {
      cout << "Eve ";
   }
   cout << endl;

   return 0;
}


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

const int NMAX = 1e+5;
const int MMAX = 1e+5;

int par[NMAX+MMAX], rank[NMAX+MMAX];

void init(int n)
{
  for(int i = 0; i < n; i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x)
{
  if(par[x] == x) return x;
  else return par[x] = find(par[x]);
}

void unite(int x, int y)
{
  x = find(x);
  y = find(y);
  if(x == y) return;

  if(rank[x] < rank[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rank[x] == rank[y]) rank[x]++;
  }
}

bool same(int x, int y)
{
  return find(x) == find(y);
}

int main()
{
  int n, m;
  cin >> n >> m;

  init(n+m);

  for(int i = 0; i < n; i++){
    int k;
    cin >> k;

    for(int j = 0; j < k; j++){
      int l;
      cin >> l;

      unite(i, n+l-1);
    }
  }
  
  for(int i = 1; i < n; i++){
    if(!same(i, i-1)){
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

vector<pair<long long, int>> factor(long long x) {
    vector<pair<long long, int>> res;
    for (long long i = 2; i*i <= x; ++i) {
        if (x % i) continue;
        res.emplace_back(i, 0);
        while (x % i == 0) {
            x /= i;
            res.back().second++;
        }
    }
    if (x != 1) res.emplace_back(x, 1);
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n;
    cin >> n;
    auto f = factor(n);
    ll ans = n;
    for (auto&& p : f) ans *= (n - n/p.fi), ans /= n;
    cout << ans << endl;
}



Measured memory_bytes: 3224
#include<stdio.h>
int main(void){
	int i,n,min,max;
	long sum ;
	min = 0 ;
	max = 0 ;
	sum = 0 ;
	scanf("%d",&n) ;
	int a[n] ;
	for(i = 0 ;i<=n-1 ;i++){
		scanf("%d",&a[i]) ;
		if(i == 0){
			min = a[i] ;
			max = a[i] ;
		}
		if(min>a[i]){
			min = a[i] ;
		}
		if(max<a[i]){
			max = a[i] ;
		}
			sum+=a[i] ;
	}
	printf("%d %d %ld\n",min,max,sum) ;
	return 0 ;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <cstdio>
#include <numeric>

using namespace std;

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

int main()
{
	int n;

	cin >> n;
	long ans = 0;

	for (int i = 1; i <= n; ++i)
	{
		if (i % 3 != 0 && i % 5 != 0)
		{
			ans += i;
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100010;
int n,s1[N],s2[N],mx,mx11,mx12,mx21,mx22,v11,v12,v21,v22;
int main(){
	int t,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&t);
		mx=max(mx,t);
		if(i&1) s1[t]++;
		else s2[t]++;
	}
	for(int i=1;i<=mx;i++){
		if(s1[i]>=mx11){
			mx12=mx11,v12=v11;
			mx11=s1[i],v11=i;
		}
		else if(s1[i]>mx12) mx12=s1[i],v12=i;
		if(s2[i]>=mx21){
			mx22=mx21,v22=v21;
			mx21=s2[i],v21=i;
		}
		else if(s2[i]>mx22) mx22=s2[i],v22=i;
	}
	if(v11==v21){
		if(v11!=v22) ans=max(ans,mx11+mx22);
		if(v12!=v21) ans=max(ans,mx12+mx21);
	}
	else ans=mx11+mx21;
	ans=n-ans;
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>

using namespace std;
int main()
{
    int h, w, k;
    cin >> h >> w >> k;

    vector<vector<char>> c;

    c.resize(h);
    int total = 0;
    for(int i=0; i<h; i++)
    {
        string str;
        cin >> str;
        c[i].resize(w);
        for(int j=0; j<w; j++)
        {
            c[i][j] = str[j];

            if(str[j] == '#') total++;
        }

    }

    // cout << total << endl;
    // bit 全探索

    int ans = 0;
    for (int r = 0; r < (1 << h); r++)
    {
        for (int cl = 0; cl < (1 << w); cl++)
        {
            
            // 今のr, clの行と列の黒を数える
            int blk = 0;
            for(int i=0; i<h; i++)
            {
                for(int j=0; j<w; j++)
                {
                    // 今の組み合わせはどの行、列を選択しているか？
                    if(((r >> i) & 1) && ((cl >> j) & 1) && c[i][j] == '#')
                    {
                        blk ++;
                    }
                }
            }

            // cout << blk << endl;

            if (k == blk){
            // if (k - total == blk){
                ans++;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m;
vector<int> a, b;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    a.resize(n);
    double sum = 0;
    rep(i, n) cin >> a[i];
    rep(i, n) sum += a[i];
    sum /= n;
    int ans = 0;
    double d = 100000000;
    rep(i, n)
    {
        if (d > abs(sum - a[i]))
        {
            ans = i;
            d = abs(sum - a[i]);
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let N = lines[0] - 0;
    let Is = new Array(N+1);
    for (let n = 1; n <= N; n++) Is[n] = lines[n].split(/\s/).map((v) => v - 0);
    Is[0] = [0, 0, 0];

    let dp = new Array(Is.length).fill(0).map((v) => [0, 0, 0]);
    for (let n = 1; n <= N; n++)
        for (let j = 0; j < 3; j++)
            for (let k = 0; k < 3; k++)
                if (k != j) 
                    dp[n][k] = Math.max(dp[n][k], dp[n-1][j] + Is[n][k]);

    console.log(Math.max(...dp[N]));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 57772
import java.util.Scanner;
import java.util.Stack;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        for (int i = 0; i < S.length() - 1; i++) {
            if (S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 22096
#include<cstdio>
int t[100005], x[100005], y[100005];

int abs(int u){ return u>0?u:-u; }

int main(){
    int n;
    scanf("%d",&n);
    t[0] = x[0] = y[0] = 0;
    for(int i = 1; i <= n; i++) scanf("%d%d%d",&t[i],&x[i],&y[i]);
    int ok = 1;
    for(int i = 1; i <= n; i++){
        int diff = abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
        int have = t[i]-t[i-1];
        if(have<diff) ok = 0;
        else if(have%2!=diff%2) ok = 0;
    }
    if(ok) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 2828
n = int(input())
S = [list(input()) for _ in range(n)]

abc = 'abcdefghijklmnopqrstuvwxyz'
x = [50]*26
ans = []
for i in range(26):
    for j in S:
        x[i] = min(x[i],j.count(abc[i]))
for i in range(26):
    ans.append(abc[i]*x[i])
for i in range(26):
    print(ans[i],end='')


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, int> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int k;
string s;

ll mod_pow(ll x, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

ll mod_inverse(ll x) {
    return mod_pow(x, mod-2);
}

const int max_n = 2000100;
ll fact[max_n];
ll fact_inv[max_n];
void calc_fact() {
    fact[0] = 1;
    for (ll i = 1; i < max_n; i++)
        fact[i] = (fact[i-1] * i) % mod;
    fact_inv[max_n-1] = mod_inverse(fact[max_n-1]);
    for (ll i = max_n-2; i >= 0; i--)
        fact_inv[i] = (fact_inv[i+1] * (i+1)) % mod;
}
ll mod_comb(ll n, ll k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return (fact[n] * fact_inv[k] % mod) * fact_inv[n-k] % mod;
}

ll solve() {
    calc_fact();
    const int sz = (int)s.size();
    ll res = 0;
    for (int i = sz; i <= sz+k; i++) {
        ll v = mod_comb(i-1, sz-1);
        v *= mod_pow(25, i-1-(sz-1));
        v %= mod;
        v *= mod_pow(26, sz+k-i);
        v %= mod;
        res += v;
        res %= mod;
    }
    return res;
}

void input() {
    cin >> k >> s;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 35656
#include <stdio.h>
#include <limits.h>


#define MIN(a, b) ((a<b)?a:b)

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int a[m], b, c[m], tmp, ans;
  for (int i=0; i<m; i++) {
    scanf("%d%d", a+i, &b);
    c[i]=0;
    for (int j=0; j<b; j++) {
      scanf("%d", &tmp);
      c[i]+=(1<<(tmp-1));
    }
  }
  int dp[m][(1<<n)];
  dp[0][0]=0;
  for (int i=1; i<(1<<n); i++) {
    if ((c[0]&i)!=i) dp[0][i] = INT_MAX;
    else dp[0][i] = a[0];
  }
  for (int i=1; i<m; i++) {
    for (int j=1; j<(1<<n); j++) {
      if (dp[i-1][j-(c[i]&j)]==INT_MAX) dp[i][j] = dp[i-1][j];
      else dp[i][j] = MIN(dp[i-1][j], dp[i-1][j-(c[i]&j)]+a[i]);
    }
  }
  ans = (dp[m-1][(1<<n)-1]==INT_MAX) ? -1 : dp[m-1][(1<<n)-1];
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 16128
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int t;
	cin >> t;

	if (t < 1200)
	{
		cout << "ABC";
	}
	else if (t < 2800)
	{
		cout << "ARC";
	}
	else
	{
		cout << "AGC";
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define ld long double
int a[305][305];
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i = 0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    int Max=n,Min=0;
    while(Max>Min+1){
        int mid=(Max+Min)/2;
        int index[305];
        fill(index,index+n,1);
        int ok=1;
        vector<int> v[305];
        int ook[305];
        fill(ook,ook+m+1,1);
        for(int i = 0;i<n;i++)v[a[i][0]].pb(i);
        while(true){
            int out=1;
            for(int i = 1;i<=m;i++){
            //    printf("%d\n",v[i].size());
                if(v[i].size()>mid){
                    out=0;
                    ook[i]=0;
                    for(auto it:v[i]){
                        while(!ook[a[it][index[it]]]&&index[it]!=m){
                            index[it]++;
                        }
                      //  printf("?%d\n",a[it][index[it]]);
                        if(index[it]!=m)
                        v[a[it][index[it]++]].pb(it);
                        else ok=0;
                    }
                  //  printf("%d %d\n",i,mid);
                    v[i].clear();
                }
            }
            if(out)break;
        }
        if(ok)Max=mid;
        else Min=mid;
    }
    printf("%d\n",Max);
}

Measured memory_bytes: 1248
using System;
using System.Linq;

namespace abc097_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = Math.Abs(x[0] - x[1]);
            int b = Math.Abs(x[1] - x[2]);
            int c = Math.Abs(x[0] - x[2]);
            Console.WriteLine(c <= x[3] || (a <= x[3] && b <= x[3]) ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)  (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
inline LL moduloMultiplication(LL x, LL y) {
	return (x%mod * 1LL * y%mod) %
 
		mod;
}
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}
 
inline LL inv(LL a) { return power(a, mod - 2) % mod; }
LL gcd(LL a, LL b)
{
	if (!a)
		return b % mod;
	return gcd(b%a, a) % mod;
}
 
LL binomialCoeff(LL n, LL k)
{
	LL res = 1;
 
	// Since C(n, k) = C(n, n-k)  
	if (k > n - k)
		k = n - k;
 
	// Calculate value of  
	// [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]  
	for (LL i = 0; i < k; ++i)
	{
		//res *= (n - i);
		res = moduloMultiplication(res, n - i);
		res %= mod;
		res = moduloMultiplication(res, inv(i + 1));
		res %= mod;
	//	res /= (i + 1);
	}
 
	return res;
}
int main()
{
	LL n, a, b;
	cin >> n >> a >> b;
	LL f = power(2, n);
	f %= mod;
	f = add(f, -1);
	f %= mod;
	f = add(f, -binomialCoeff(n, a));
	f = (f + mod) % mod;
	f %= mod;
	f = add(f, -binomialCoeff(n, b));
	f %= mod;
	cout << (f+mod)%mod << endl;
 
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,l,a[N];
int main()
{
	scanf("%d%d",&n,&l);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<n;i++){
		if (a[i]+a[i+1]>=l){
			puts("Possible");
			for (int j=1;j<i;j++) printf("%d\n",j);
			for (int j=n-1;j>i;j--) printf("%d\n",j);
			printf("%d\n",i);
			return 0;
		}
	}
	puts("Impossible");
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;





int main()
{
//    ios::sync_with_stdio(0);
//    cin.tie(0);
    string s;
    cin>>s;
    ll ans=0;
    for(ll i=0; i<zz(s); i++)
    {
        ll c=0;
        if(s[i]=='R')
        {
            c=1;
            while(i+1<zz(s)&&s[i+1]=='R')
                c++,i++;

        }


        ans=max(ans,c);

    }

    cout<<ans<<nn;





}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






Measured memory_bytes: 3568
(let ((n (read))
      (arr (make-array 3 :initial-element 0))
      temp)
     (loop repeat n do
           (setf temp (read))
           (cond ((= 0 (mod temp 4)) (incf (aref arr 0)))
                 ((= 0 (mod temp 2)) (incf (aref arr 1)))
                 (t (incf (aref arr 2)))))
     (princ (if (or (and (zerop (aref arr 0)) (zerop (aref arr 2))) (>= (1+ (aref arr 0)) (+ (aref arr 2) (if (zerop (aref arr 1)) 0 1)))) "Yes" "No")))

Measured memory_bytes: 57704
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

void solve(){
    ll n;
    cin>>n;
    ll sum = 0;
    loop(i,1,n+1){
        if(i%3 != 0 && i%5 !=0){
            sum += i;
        }
    }
    print(sum);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        start_routine();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    #ifndef ONLINE_JUDGE
        end_routine();
    #endif
}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  while (k > 0 && a >= b) {
    b *= 2;
    k--;
  }
  while (k > 0 && b >= c) {
    c *= 2;
    k--;
  }
  if (a < b && b < c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 3632
// Problem : D - Grid Repainting
// Contest : AtCoder - AtCoder Beginner Contest 088
// URL : https://atcoder.jp/contests/abc088/tasks/abc088_d
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
int a[51][51]={0};
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int h, w, count=0;
	cin >> h >> w;
	loop(i, h)
		loop(j, w)
		{
			char c;
			cin >> c;
			if(c == '.')
				a[i][j] = 1;
			else
				count++;
		}
	int dist[51][51]={0};
	dist[0][0]=1;
	queue < pair< int, int> > q;
	q.push({0,0});
	while(!q.empty())
	{
		pi p = q.front();
		q.pop();
		int i = p.f;
		int j = p.s;
		if(i == h-1 && j == w-1)
		{
			cout << h*w - dist[h-1][w-1] - count;
			return 0;
		}
		if(j-1 >=0 && dist[i][j-1] == 0 && a[i][j-1]!=0 )
		{
			q.push({i,j-1});
			dist[i][j-1] = 1 + dist[i][j];
		}
		if(i-1 >= 0 && dist[i-1][j] == 0 && a[i-1][j]!=0)
		{
			q.push({i-1,j});
			dist[i-1][j] = 1 + dist[i][j];
		}
		if(i+1 < h && dist[i+1][j] == 0 && a[i+1][j]!=0)
		{
			q.push({i+1,j});
			dist[i+1][j] = 1 + dist[i][j];
		}
		if(j+1 < w && dist[i][j+1] == 0 && a[i][j+1]!=0)
		{
			q.push({i,j+1});
			dist[i][j+1] = 1 + dist[i][j];
		}
	//	cout<<i<<" "<<j<<nl;
		
	}
	cout<<-1;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define M 1000000007  // 10^9+7

int grid1(string arr[], int n, int m){

    vector<ll> dp(m, 0);
    for(int i=n-1; i>=0; i--){
        for(int j=m-1; j>=0; j--){
            if(i==n-1 and j==m-1){
                dp[j] = 1;
                continue;
            }
            if(arr[i][j] == '#'){
                dp[j] = 0;
                continue;
            }
            if(j+1 < m)
                dp[j] = (dp[j] + dp[j+1])%M;
        }
    }
    return dp[0];
}

int main()
{
 int n, m;
 cin>>n>>m;
 string arr[n];
 for(int i=0; i<n; i++)
    cin>>arr[i];
 int ans = grid1(arr, n, m);
 cout<<ans;
 return 0;
}



Measured memory_bytes: 5524
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<utility>
//#include<>
using namespace std;

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

int main()
{
  int N,m;
  cin >>N>>m;
  int i;
  pair<int,int> restricts[500],restricts_d_c[500];//(ci,di)と(di,ci)
  rep(i,m){
    cin>>restricts[i].first>>restricts[i].second;
    restricts_d_c[i].first=restricts[i].second;
    restricts_d_c[i].second=restricts[i].first;
  }
  sort(restricts,restricts+m);
  sort(restricts_d_c,restricts_d_c+m);
  int line[1002]={};
  line[0]=1;
  i=0;
  int start,end,j;
  while(i<m){
    start=restricts[i].first;
    end=restricts[i].second;
    i++;
    for(;i<m;i++)
      if(restricts[i].first<=end && end<restricts[i].second)
	end=restricts[i].second;
      else if(end<restricts[i].first)
	break;
    line[start]+=1;
    line[start+1]+=1;
    line[end]-=1;
    line[end+1]-=1;
  }
  int ans=line[0];
  rep(i,N){
    line[i+1]+=line[i];
    ans+=line[i+1];
    //cout<<line[i+1]<<" ";
  }
  
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(long long &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const long long &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
int n, h[100000][3], dp[100000][4];
int calc(int i, int prev) {
	if(i >= n) return 0;
	if(dp[i][prev] != -1) return dp[i][prev];
	int res = 0;
	for(int j = 0; j < 3; j++) {
		if(j != prev) {
			res = max(res, calc(i + 1, j) + h[i][j]);
		}
	}
	return dp[i][prev] = res;
}
int main() {
	R(n);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 3; j++) {
			R(h[i][j]);
		}
	}
	memset(dp, -1, sizeof(dp));
	int ans = calc(0, 3);
	W(ans);
	return 0;
}

Measured memory_bytes: 9216
#include <stdio.h>
int main(void){
	int r,c;
	scanf("%d %d\n",&r,&c);
	int a[r+1][c+1];
	int k_1,k_2;
	for(k_1=0;k_1<r;k_1++){
		a[k_1][c] = 0;
	}
	int l_1,l_2;
	for(l_1=0;l_1<c;l_1++){
		a[r][l_1] = 0;
	}
	a[r][c] = 0;
	int i,j;
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			if(j==c-1){
				scanf("%d\n",&a[i][j]);
			}else{
				scanf("%d ",&a[i][j]);
			}
		}
	}
	for(k_1=0;k_1<r;k_1++){
		for(k_2=0;k_2<c;k_2++){
			a[k_1][c] = a[k_1][c] + a[k_1][k_2];
		}
	}
	for(l_1=0;l_1<c;l_1++){
		a[r][l_1] = 0;
		for(l_2=0;l_2<r;l_2++){
			a[r][l_1] = a[r][l_1] + a[l_2][l_1];
		}
	}
	int p;
	for(p=0;p<r;p++){
		a[r][c] = a[r][c] + a[p][c];
	}
	int t_1,t_2;
	for(t_1=0;t_1<r+1;t_1++){
		for(t_2=0;t_2<c+1;t_2++){
			if(t_2==c){
				printf("%d\n",a[t_1][t_2]);
			}else{
				printf("%d ",a[t_1][t_2]);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  string T;
  cin >> T;
  for (int i = 0; i < T.size(); i++){
    if (T.at(i) == '?'){
      T.at(i) = 'D';
    }
    cout << T.at(i);
  }
  cout << endl;
}


Measured memory_bytes: 3752
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

count = 0

for i in range(N):
    a = A[i] - B[i]
    if a >= 0:
        count += B[i]
    else:
        count += A[i]
        if A[i + 1] + A[i] - B[i] > 0:
            count += B[i] - A[i]
        else:
            count += A[i + 1]
        A[i + 1] = max(0, A[i + 1] + A[i] - B[i])

print(count)

Measured memory_bytes: 18476
//my import
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
#define lll __int128
const int mod=1e9+7;
const int inf=1e9+7; 

//const int maxn=

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	string str;
	
	cin>>str;
	
	int cnt=0;
  
	  for(int i=0;i<str.size()/2;i++)
	  {
	    if(str[i]!=str[str.size()-i-1])
	      cnt++;
	  }
	  
	  cout<<cnt<<endl;
	
	return 0;
} 

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

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn make_memo(prime:[bool;100010]) -> [usize;100010] {
    let mut memo = [0; 100010];
    let size = 100010;
    for i in 2..size-5 {
        memo[i] = memo[i-1];
        if prime[i] && prime[(i+1)/2] {
            memo[i] += 1;
        }
    }
    memo
}



fn main() {
    let q = read_line().trim().parse::<usize>().expect("invalid");

    let mut prime = [true; 100010];
    let size = 100010;
    prime[0] = false;
    prime[1] = false;

    let mut i:u64 = 2;
    while i < size {
        if prime[i as usize] {
            let mut j:u64 = i;
            while i*j < size {
                let idx = (i*j) as usize;
                prime[idx] = false;
                j += 1;
            }
        }
        i += 1;
    }

    let memo = make_memo(prime);

    for _ in 0..q {
        let arr:Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
        let l = arr[0];
        let r = arr[1];


        println!("{}", memo[r]-memo[l-1]);
    }


}


Measured memory_bytes: 6396
import sys

n, k = map(int, input().split())
a = list(map(int, input().split()))

if ((n - 1) % (k - 1)) == 0:
    print((n - 1) // (k - 1))
    sys.exit()

pos = a.index(1)
start = 0
x = 0
if pos < k:
    start = k - 1
    x += 1
else:
    start = pos
    x += pos // (k - 1)
    if (pos % (k - 1)) != 0:
        x += 1

x += (n - (start + 1)) // (k - 1)
if ((n - (start + 1)) % (k - 1)) != 0:
    x += 1
print(x)

Measured memory_bytes: 13880
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  vector<int> v;
  double val;
  cin>>n;
  v.resize(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  val=v[0];
  for(int i=1;i<n;i++){
    val=(val+v[i])/2;
  }
  cout<<val<<endl;
  return 0;
}

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

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

vector<vector<int>> p(100005, vector<int>(0));
vector<int> v(100005, -1);
map<string, int> col;
void dfs(int x) {
  int y = p[x].size();
  for (int i = 0; i < y; i++) {
    string s = to_string(min(x, p[x][i]));
    string ss = to_string(max(x, p[x][i]));
    string sss = s + "#" + ss;
    if (col[sss] == 0)  {
      if (v[p[x][i]] == -1) {
        v[p[x][i]] = (v[x] + 1);
      }
      v[x] = v[p[x][i]];
      
      col[sss] = v[x];
      
      dfs(p[x][i]);
    }
  }
  return;
}
  
int main() {
  int n;
  cin >> n;
  vector<string> pa(n-1);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    p[a].push_back(b);
    p[b].push_back(a);
    string S = to_string(min(a, b));
    string SS = to_string(max(a, b));
    string SSS = S + "#" + SS;
    pa[i] = SSS;
  }
  int count = p[0].size();
  for (int i = 1; i < n; i++) {
    int P = p[i].size();
    count = max(count, P);
  }
  cout << count <<endl;
  v[0] = 0;
  dfs(0);
  for (int i = 0; i < n -1; i++) {
    int cc = col.at(pa[i]) % count;
    if (cc == 0) {
      cc = count;
    }
    cout << cc <<endl;
  }
} 


Measured memory_bytes: 35456
def get_pro(w, v):
  """
  dp[a][b] ... a番目、金額bまでで作れる最高の利益
  dp[a][b] = max(dp[a - 1][b], dp[a - 1][b - w * k] + v * k)
  """
  dp = [0] * (x + 1)
  for a in range(n):
    wa = wlst[a]
    va = vlst[a]
    for b in range(wa, x + 1):
      dp[b] = max(dp[b], dp[b - wa] + va)
  return dp[x]

n, d, x = map(int, input().split())
plst = [list(map(int, input().split())) for _ in range(d)]
for i in range(d - 1):
  vlst = [plst[i + 1][j] - plst[i][j] for j in range(n)]
  wlst = [plst[i][j] for j in range(n)]
  x += get_pro(wlst, vlst)
print(x)


Measured memory_bytes: 6676
#include <iostream>
char a[20];
char b[20];
int main() {
    scanf("%s",a);
    scanf("%s",b);
    bool test=true;
    for(int i=0;a[i]!='\0';i++){
        if(a[i]!=b[i]) test=false;
    }
    if(test) printf("Yes");
    else printf("No");
}

Measured memory_bytes: 3720
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10
	
N, P = MAP()
A = LIST()

dp = [[0, 0] for _ in range(N+1)]
dp[0][0] = 1
dp[0][1] = 0  #dp[0]は一個も選ばないときのP=0,P=1になる組み合わせ

for i, a in enumerate(A):
	if a%2 == 0:
		dp[i+1][0] = dp[i][0] * 2
		dp[i+1][1] = dp[i][1] * 2
	else:
		dp[i+1][0] = dp[i][1] + dp[i][0]
		dp[i+1][1] = dp[i][0] + dp[i][1]

print(dp[N][P])

Measured memory_bytes: 10520