akhauriyash/Code-Regression huggingface dataset:
n = gets
origin = Array.new
givenString = Array.new
output = Array.new

"SHCD".each_char {|ch|
    for i in 1..13
        origin.push([ch, i])
    end
}

while line = gets
    design, num = line.split
    givenString.push([design, num.to_i])
end

(origin - givenString).each{|ch, idx|
    puts "#{ch} #{idx}"
}


Measured memory_bytes: 6872
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int P = 1e9 + 7;
const int inf = 1e9;
int mul(int a,int b){
  return a * b % P;
}
void add(int &a, int b){
  a += b;
  if(a >= P)
    a -= P;
}

void sub(int &a, int b){
  a -= b;
  if(a < 0)
    a += P;
}

int licz(int n,int lim){
  debug(n,lim);
  vector<int> dp(n + 1);
  dp[0] = 1;
  dp[1] = 1;
  for(int i = 1;i < n;i++){
    add(dp[i + 1], dp[i]);
    add(dp[i + 1], dp[i]);
    if(i > lim){
      sub(dp[i + 1], dp[i - lim - 1]);
    }
  }
  debug(dp);
  int res = 0;
  R(i, lim + 1){
    add(res, mul(dp[n - 1 - i], i + 1));
  }
  return res;
}
int n,m;
string s;
void nope(){
  cout << "0\n";
  exit(0);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> m >> s;
  if(s[0] == 'B'){
    for(char& el:s)
      el = 'R' + 'B' - el;
  }
  int naj = inf;
  int ak = 0;
  bool czB = 0;
  R(i,m)if(s[i] == 'R'){
    ak++;
  }else{
    if(!czB || ak&1){
      mini(naj, ak);
    }
    czB = 1;
    ak = 0;
  }
  if(!czB){
    cout << licz(n, 1) << "\n";
  }else{
    if(n&1)nope();
    cout << mul(2, licz(n / 2, naj / 2)) << "\n";
  }
}


Measured memory_bytes: 2196
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

n = int(input())

t, x, y = 0, 0, 0
for i in range(n):
    t_new, x_new, y_new = list(map(int, input().split()))

    time = t_new-t
    dis = abs(x_new-x)+abs(y_new-y)

    if time < dis:
        print("No")
        exit()
    if time % 2 != dis % 2:
        print("No")
        exit()
    t, x, y = t_new, x_new, y_new
print("Yes")


Measured memory_bytes: 9188
def solve():
    S = input()
    result = [0] * len(S)
    children_position = []
    even_odd_sum = []
    even_sum = 0
    odd_sum = 0
    R_i = 0
    L_i = -2
    
    for idx, s in enumerate(S):
        
        if s == 'R':
            R_i = idx
            if L_i+1 == R_i:
                even_odd_sum.append((even_sum, odd_sum))
                even_sum = 0
                odd_sum = 0
        elif s == 'L':
            L_i = idx
            if R_i+1 == idx:
                children_position.append((R_i, L_i))
                
        even_sum += idx % 2 == 0
        odd_sum += idx % 2 == 1
                
    even_odd_sum.append((even_sum, odd_sum))
    # print(children_position, even_odd_sum)
    for idx in range(len(children_position)):
        t = children_position[idx]
        even_odd_R = t[0] % 2
        even_odd_L = t[1] % 2
        
        result[t[0]] = even_odd_sum[idx][0] if even_odd_R == 0 else even_odd_sum[idx][1]
        result[t[1]] = even_odd_sum[idx][0] if even_odd_L == 0 else even_odd_sum[idx][1]
        
    
    print(' '.join(map(str, result)))
solve()

Measured memory_bytes: 20900
#include <iostream>
#include <iomanip>
     
using namespace std;
     
int main(){
 int n,i;
 cin >> n;
 int a[n];
 for (i=0;i<n;i++) {
  cin >> a[i];
 }
 for (i=0;i<n;i++) {
  cout << a[n-i-1];
  if (i<n-1) cout <<" ";
 }
 cout << endl;
 return 0;
}



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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n, k;
    cin >> n >> k;
    vector<ll> p(n), c(n);
    for(auto &e: p) cin >> e, e--;
    for(auto &e: c) cin >> e;

    vector<pair<ll,ll>> lp(n);
    for(ll i=0; i<n; i++) {
	ll x = i, s = 0;
	s += c[x], x = p[x];
	ll j;
	for(j=1; x != i; j++) s += c[x], x = p[x];
	lp[i] = {s, j};
	// cout << i << ' ' << s << ' ' << j << endl;
    }

    ll res = *max_element(c.begin(), c.end());
    for(ll i=0; i<n; i++) {
	if(get<0>(lp[i]) <= 0) {
	    ll x = i, s = 0;
	    s += c[x], x = p[x];

	    ll r = s;
	    for(ll j=2; x != i && j <= k; j++) s += c[x], x = p[x], r = max(r, s);

	    res = max(res, r);
	} else {
	    auto [t, tt] = lp[i];

	    ll x = i, s = 0;
	    s += c[x], x = p[x];

	    ll j=1;
	    ll r = s + (k-j)/tt * t;
	    for(j=2; x != i && j <= k; j++) s += c[x], x = p[x], r = max(r, s + (k-j)/tt * t);

	    res = max(res, r);
	}
    }
    cout << res << endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,ans=0;
    cin>>n;
    while(n){
    	if(n>=25){
    		ans+=n/25;
    		n%=25;
    	}else if(n>=10){
    		ans+=n/10;
    		n%=10;
    	}else if(n>=5){
    		ans+=n/5;
    		n%=5;
    	}else{
    		ans+=n;
    		n=0;
    	}
    }
    cout << ans<<endl;
    return 0;
}



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

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    auto f = [&](ll e) -> ll { return (-1 + sqrt(1 + 8 * e)) / 2; };
    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        ll e = 0;
        while (n % i == 0) {
            e++;
            n /= i;
        }
        ans += f(e);
    }
    if (n != 1) ans += f(1);
    cout << ans << endl;
}

Measured memory_bytes: 3680
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	int n;
	cin >> n;
	string s1,s2;
	cin >> s1 >> s2;
	
	const ll mod = 1000000007;
	ll ans = 1;
	for(int i=0; i<n; i++){
		if(s1[i]==s2[i]){
			if(i==0){
				ans = 3;
			}else if(s1[i-1]==s2[i-1]){
				ans = (ans*2)%mod;
			}
		}else{
			if(i==0){
				ans = 6;
			}else if(s1[i-1]==s2[i-1]){
				ans = (ans*2)%mod;
			}else{
				ans = (ans*3)%mod;
			}
			i++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>


void showWidth(int width){
	int w;
	for(w = 0; w < width; w++){
		putchar('#');
	}
}

void showHeight(int height, int width){
	int h;
	for(h = 0; h < height; h++){
		showWidth(width);
		putchar('\n');
	}
	putchar('\n');
}

int main(void){
	int height, width, h, w;
	
	scanf("%d %d", &height, &width);
	
	
	while(!(height == 0 && width == 0)){
		showHeight(height, width);
		scanf("%d %d", &height, &width);
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define ill long long
#define rep(i, a, b) for(ill i = (ill)(a); i < (ill)(b); i++)
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if(a+b >= 10) cout << "error\n";
  else cout << a+b << "\n";
}


Measured memory_bytes: 3580
N = int( input() )
A_list = list( map( int, input().split() ) )
B_list = list( map( int, input().split() ) )
c = min(A_list[0], B_list[0])
remain_B = max(B_list[0] - A_list[0], 0)
for i in range(1, N ):
    c += min(remain_B, A_list[i])
    remain_A = max( A_list[i] - remain_B, 0 )
    c += min(remain_A, B_list[i])
    remain_B = max(B_list[i] - remain_A, 0 )
c += min(A_list[N], remain_B)
print(c)


Measured memory_bytes: 19156
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Control.Monad
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn
  edges <- U.replicateM (n-1) $ do
    [a,b] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (a-1,b-1)
  let graph :: V.Vector [(Int,Int)]
      graph = V.create $ do
        g <- VM.replicate n []
        flip U.imapM_ edges $ \i (a,b) -> do
          VM.modify g ((b,i) :) a
          VM.modify g ((a,i) :) b
        return g
  let result :: U.Vector Int
      result = U.create $ do
        r <- UM.new (n-1)
        let go !i0 !i !c0 = do
              forM_ (zip (filter ((/= i0) . fst) $ graph V.! i) (filter (/= c0) [1..])) $ \((j,k),c) -> do
                UM.write r k c
                go i j c
        go (-1) 0 (-1)
        return r
  print (U.maximum result)
  U.forM_ result print


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

int main(){
  int n;
  cin>>n;
  int nn=2*n*n-2*n;
  vector<int> g[10001];
  for(int i=0;i<nn;i++){
    int a,b;
    cin>>a>>b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int k;
  for(int i=1;i<=n*n;i++){
    if(g[i].size()==2){
      k=i;
    }
  }
  
  int ma[111][111]={};
  int un[10010]={};
  ma[0][0]=k;
  un[k]=1;
  for(int i=0;i<n;i++){
    
    if(i){
      int tmp=ma[i-1][0];
      for(int j=0;j<g[tmp].size();j++){
	if(un[g[tmp][j]])continue;
	ma[i][0]=g[tmp][j];
	un[g[tmp][j]]=1;
	break;
      }
    }
    
    for(int j=1;j<n;j++){

      int ry=ma[i][j-1];
      if(i==0){
	for(int y=0;y<g[ry].size();y++){
	  if(un[g[ry][y]])continue;
	  if(g[g[ry][y]].size()>3)continue;
	  ma[i][j]=g[ry][y];
	  un[g[ry][y]]=1;
	  break;
	}
	continue;
      }
      int rx=ma[i-1][j];
      for(int x=0;x<g[rx].size();x++){
	for(int y=0;y<g[ry].size();y++){
	  if(un[g[rx][x]]||un[g[ry][y]])continue;
	  if(g[rx][x]!=g[ry][y])continue;
	  ma[i][j]=g[rx][x];
	  un[g[rx][x]]=1;
	}
      }   
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j)cout<<" ";
      cout<<ma[i][j];
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3808
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 998244353
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

const int N = 100 * 1000 + 5;
vector <int> v[N];
vector <bool> vis(N, false);
vector <int> t;
void dfs(int s) {
	vis[s] = true;
	t.push_back(s);
	for (auto g : v[s]) {
		if(!vis[g])
			dfs(g);
	}
}
int main() {
	int n, edges;
	cin >> n >> edges;
	vector <int> p(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < edges; i++) {
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if(!vis[i]) {
			dfs(i);
			map <int, int> m;
			for (auto g : t) 
				m[p[g]] = 1;
			for (auto g : t) {
				if(m[g] == 1)
					ans++;
			}
			t.clear();
		}
	}
	cout << ans;
}


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

int main() {
	
	long long l, r;
	cin >> l >> r;
	
	long long curr = l;
	long long at = 1;
	
	while (curr * 2 <= r) {
		curr *= 2;
		at++;
	}
	
	cout << at << endl;
	
	
	
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int gcd(int a,int b)
{
  if(a==0) return b;
  return gcd(b%a,a);
}
int32_t main()
{
  int t,n,i,j,k,l=0,max1=0;
  cin>>n;
  int a[n+1];
  for(i=1;i<=n;i++) cin>>a[i];
  sort(a+1,a+n+1);
  k=a[n];
  map<int,int> m;
  for(i=1;i<=n;i++) m[a[i]]++;
  bool hi=true;
  bool dp[k+1];
  memset(dp,1,sizeof(dp));
  dp[1]=dp[0]=0;
  for(i=2;i<=k;i++)
  {if(dp[i]){
  for(j=i*i;j<=k;j+=i)
    dp[j]=0;}
    }
  for(i=2;i<=k;i++)
  { l=0;
    if(dp[i]){
     for(j=i;j<=k;j+=i)
     {
       if(m.count(j))
         l+=m[j];
      }
      if(l>1)
      {
        hi=false;
        break;
        }
        }
  }
  
  if(hi) cout<<"pairwise coprime";
  else
  {
    l=a[1];
    for(i=2;i<=n;i++)
    {
      l=gcd(l,a[i]);
    }
    if(l==1) cout<<"setwise coprime";
    else cout<<"not coprime";
  }
}


Measured memory_bytes: 74892
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
 
//#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
 
#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
 
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int N, K;
    string S;
    cin >> N >> S >> K;

    char ch = S[K-1];

    for (int i=0; i<(int)S.length(); i++){
        if (S[i] != ch) S[i] = '*';
    }

    cout << S << endl;
 
    return 0;
}

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

vector<int> prime_table(int n) {
    vector<int> is_prime(n + 1);
    if (n) iota(is_prime.begin() + 2, is_prime.end(), 2);
    for (int i = 2; i * i <= n; i++) if (is_prime[i]) {
        for (int j = i + i; j <= n; j += i) is_prime[j] = 0;
    }
    return is_prime;
}

int main() {
    const int MAX = 1e5;
    auto is_prime = prime_table(MAX);
    vector<int> acc(MAX + 1);
    for (int i = 1; i <= MAX; i += 2) {
        acc[i] = is_prime[i] && is_prime[(i + 1) / 2];
    }
    for (int i = 1; i <= MAX; i++) acc[i] += acc[i - 1];
    int q; cin >> q;
    while (q--) {
        int l, r; cin >> l >> r;
        cout << acc[r] - acc[l - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include<string.h>
using namespace std;

int main()
{
	
	char S[101];

	cin >> S;

	int n = strlen(S);

	int count = 0;

	for (int i = 0; i < n; i++)
	{
		if (S[i] != S[n-1-i])
		{
			count++;
		}

	}

	cout << count / 2;

}

Measured memory_bytes: 256
s = input()

sl = len(s)//2
count = 0

if len(s)%2==0:
  s1 = s[:sl]
  s2 = s[sl:]
    
else:
  s1 = s[:sl]
  s2 = s[sl+1:]

for l in range(len(s1)):
  if s1[l]!=s2[len(s1)-1-l]:
    count += 1
    
print(count)

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

typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
#define MOD 1000000007
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) {return m / gcd(n, m) * n;}

int main(void) {
	ll n,ans=0;
	string hoge;
	cin >> n;
	vector<string> p;
	vector<ll> num(3);
	for (ll i = 0; i < n; i++) {
		hoge = "";
		for (ll j = 0; j < 3; j++)
			cin >> num[j];

		sort(all(num));
		for (ll i = 0; i < 3; i++)
			hoge += to_string(num[i]);
		p.push_back(hoge);
	}
	sort(all(p));
	for (ll i = 1; i < n; i++) {
		if (p[i] == p[i - 1])
			ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3360
// AOJ 1516: Nasty Boys
// 2017.9.27 bal4u@uu

#include <stdio.h>

int rr[9] = { 0,0,0,1,1,1,2,2,2 };
int cc[9] = { 0,1,2,0,1,2,0,1,2 };

int main()
{
	int i, r, c, r2, c2, f;
	char buf[20], *p;

	for (i = 0; i < 1000; i++) {
		scanf("%s", p = buf);
		r = rr[*p-'A'], c = cc[*p-'A'], p++; f = 1;
		while (*p && f) {
			f = 0;
			r2 = rr[*p-'A'], c2 = cc[*p-'A'], p++;
			if      (r2 == r) { if (c2 == c+1 || c2 == c-1) f = 1; }
			else if (c2 == c) { if (r2 == r+1 || r2 == r-1) f = 1; }
			r = r2, c = c2;
		}
		if (f) puts(buf);
	}
	return 0;
}

Measured memory_bytes: 1820
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

int main(void){
    int N,T;
    cin >> N >> T;
    pint A[N];
    rep(i,N) cin >> A[i].fi >> A[i].se;
    sort(A,A+N);
    int dp[N+1][T]={};
    rep(i,N) rep(j,T){
        if(j+A[i].fi<T) dp[i+1][j+A[i].fi]=max(dp[i+1][j+A[i].fi],dp[i][j]+A[i].se);
        dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
    }
    int ans=0;
    rep(i,N+1){
        int rem=0;
        for(int j=i;j<N;j++) rem=max(rem,A[j].se);
        rep(j,T){
            int cmp=dp[i][j]+rem;
            ans=max(ans,cmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 38816
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while (true) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      if (a == 0 && b == 0) break;
      else {
        for (int i = 0; i < a; i++) {
          for (int j = 0; j < b; j++) {
            if ((j + (i % 2)) % 2 == 0)System.out.printf("#");
            else System.out.printf(".");
          }
          System.out.printf("\n");
        }
      }
      System.out.printf("\n");
    }
  }
}



Measured memory_bytes: 63852
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include <stack>
#include<set>
#include<cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <string.h>
#include<iterator>
#include <map>
using namespace std;
// bool cmp(long long a, long long b){
//     return a > b;
// }
int  arr[3500];
string str[10];
char str_arr[5][5];
int matr[25][25], saved_matr[5][5], ish_matr[5][5];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    long long t, ch, i, curr, p = 1, x, y, weight, j, k = 0, n, m = 1, ch1, ans = 0;
    long long a, b;
    int fl, fl1, fl2, fl3;
    string s, s1;
//    cin >> t;
    long long f, size_f, size_s, weight1, weight2;
    long long sum, k_min, k_max;
//    for (auto test_case = 0; test_case < t; test_case++) {
//    }
    long long d;
    cin >> s;
    cin >> s1;
    ans = 1e9;
    long long check;
    for (i = 0; i + s1.length() - 1 < s.length(); i++){
        check = 0;
        for (j = 0; j < s1.length(); j++)
            if (s[i + j] != s1[j])
                check++;
        ans = min(ans, check);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3640
S = int(input())
DP = [0]*(S+1)
Mod = 10**9+7
if S>=3:
    DP[0] = 1
    DP[1] = 0
    DP[2] = 0
    for TS in range(3,S+1):
        DP[TS] = (DP[TS-1]+DP[TS-3])%Mod
    print(DP[S])
else:
    print(0)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
#define printArr(harry, tam) range(tam) cout << harry[i] << " \n"[i == tam -1];
#define range(n) for(int i = 0; i < n; i++)
#define maxn 100000
#define mod 1000000007
#define md(x) ((((x) % mod) + mod) % mod)
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define EPS 1e-9
#define INF INT_MAX
#define INFd 1e9

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;

//Trace dinamico
template<typename T>
void trace(T a) { cout << a << "\n"; }
template<typename T, typename... Args>
void trace(T a, Args... args) { cout << a << " "; trace(args...); }

//DP debug
int recNum = 0;
void prTabs() { range(recNum) cout << "    "; }
template<typename... Args>
void recInit(Args... args) { prTabs(); trace("rec(", args..., ")"); recNum++; }
template<typename T>
void recEnd(T a) { prTabs(); trace("->", a); recNum--;}
int n, m, a, b, c;

int main(){
	int b = 0, r = 0;
	char ch = getchar();
	sc("%d\n", &n);
	while(ch != '\n') {
		if (ch == 'B') b++;
		else if (ch == 'R')r++;
		ch = getchar();
	}
	if (r > b) pr("Yes\n");
	else pr("No\n");
 	return 0;
}


Measured memory_bytes: 256
n, a,b = map(int, input().split())
s = input() #sys.stdin.readlineは最後が改行

tmpab=0
tmpb=0
for i in range(n):
    if s[i] == 'a':
        if tmpab < a+b:
            print('Yes')
            tmpab+=1
        else:
            print('No')
    elif s[i] == 'b':
        if tmpab < a+b and tmpb <b:
            print('Yes')
            tmpab+=1
            tmpb+=1
        else:
            print('No')
    else:
        print('No')



Measured memory_bytes: 4016
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		int[][]A = new int[N][];
		for(var i=0;i<N;i++){
			string[] str2 = Console.ReadLine().Split();
			A[i] = new int[2];
			A[i][0] = int.Parse(str2[0]);
			A[i][1] = int.Parse(str2[1]);
		}
		Array.Sort(A,(x,y)=>x[0]-y[0]);
		int ct = 0;
		long ans = 0;
		for(var i=0;i<N;i++){
			if(ct+A[i][1]>=M){
				ans += (M-ct)*(long)A[i][0];
				break;
			} else {
				ct+=A[i][1];
				ans += A[i][1]*(long)A[i][0];
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 23368
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        String s = arr01[0];

        int cnt = 0;

        int l = s.length();

        for (int i = 0; i < s.length() / 2; i++) {

            String s1 = s.substring(i, i + 1);
            String s2 = s.substring(l - i - 1, l - i);

            if (!s1.equals(s2)) {
                cnt += 1;
            }
        }
        System.out.println(cnt);

    }

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<b)
#define F first
#define S second
typedef long long ll;
using namespace std;

int main(){
	int N;
	cin>>N;
	int a[300010];
	REP(i,0,3*N) cin>>a[i];
	sort(a,a+3*N);
	ll ans=0;
	REP(i,0,N)	ans+=a[3*N-2*(i+1)];
	p(ans);
	return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

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

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

  ll A, B, C;
  cin >> A >> B >> C;
  if(A%2 == 0 && B%2 == 0 && C%2==0 && (A==B) && (B == C)){
    cout << -1 << endl;
  }else if(!(A%2 == 0 && B%2 == 0 && C%2==0)){
    cout << 0 << endl;
  }else{
    bool ok = true;
    ll nA, nB, nC;
    ll ans = 1;
    while(ok){
      
      nA = (B + C) / 2;
      nB = (C + A) / 2;
      nC = (A + B) / 2;

      if(nA % 2 == 0 && nB % 2 == 0 && nC % 2 == 0){
        ans++;
        A = nA;
        B = nB;
        C = nC;
      }else{
        ok = false;
      }
    }

    cout << ans << endl;


  }

  return 0;
}


Measured memory_bytes: 256
def args():
    N = int(input())
    S = input()

    # print(N, S)

    return N, S


def solve(N, S):
    def inv_animal(animal):
        return "S" if animal == "W" else "W"

    def is_correct(st):
        for i in range(0, N):
            pre, nxt = i - 1, i + 1
            if i == 0:
                pre = -1
            elif i == N - 1:
                nxt = 0

            say = S[i]
            animal = st[i]

            if animal == "S":
                if say == "o":
                    if not st[pre] == st[nxt]:
                        return False
                else:
                    if st[pre] == st[nxt]:
                        return False
            else:
                if say == "o":
                    if st[pre] == st[nxt]:
                        return False
                else:
                    if not st[pre] == st[nxt]:
                        return False
        return True

    # print(S)

    lis = []
    def recur(i, st):
            if not i < 2:
                lis.append(st)
                return

            recur(i + 1, st + "S")
            recur(i + 1, st + "W")
    recur(0, "")

    # print(lis)

    if len(lis) == 0:
        return -1

    def fill(p, n):
        for i in range(1, n):
            pre = i - 1
            say = S[i]
            animal = p[i]

            if animal == "S":
                if say == "o":
                    p += p[pre]
                else:
                    p += inv_animal(p[pre])
            else:
                if say == "o":
                    p += inv_animal(p[pre])
                else:
                    p += p[pre]
        return p

    for p in lis:
        filled = fill(p, N - 1)
        if is_correct(filled):
            return filled
    return -1


if __name__ == '__main__':
    res = solve(*args())
    print(res)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()
 
#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>
 
#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}
 
#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue
 
#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
 
 
using namespace std;

const int max_n = 1e5 + 5;


lint ile[10];
set<PII> dupa;

int zlicz(int i, int j) {
	int ans = 0;
	FOR(x,0,3) FOR(y,0,3) {
		if (dupa.find(mp(i+x,j+y)) != dupa.end()) ans++;
	}
	return ans;
}

bool is_best(int i, int j, int x, int y) {
	FOR(u,0,3) FOR(v,0,3) {
		if (dupa.find(mp(i+u, j+v)) != dupa.end() && mp(i+u,j+v) < mp(x,y)) return false;
	}
	return true;
}

void solve() {
	make3(h, w, n);
	lint total = (h-2) * 1LL * (w-2);
	FOR(i,0,n) {
		make2(a, b);
		dupa.insert(mp(a, b));
	}
	FOR(i,0,10) ile[i] = 0;
	FORE(i, dupa) {
		PII ja = *i;
		FOR(u, ja.st-2, ja.st+1) FOR(v,ja.nd-2,ja.nd+1) {
			if (u < 1 || v < 1 || (u+2)>h || (v+2)>w) continue;
			if (is_best(u, v, ja.st, ja.nd)) ile[zlicz(u, v)]++;
		}
	}
	FOR(j,1,10) total -= ile[j];
	ile[0] = total;
	FOR(j,0,10) {
		cout << ile[j] << endl;
	}
}


int main() {
	int z = 1;
	// read(z);
	while (z--) {
		solve();
	}
}


Measured memory_bytes: 4992
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include<iomanip>

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int; // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;

/*
 * データ変換 
 */
/* char -> int */
int ctoi(char c) { return (int)(c - '0'); }

/*
 * 数学的な計算
 */
/* 階乗 */
int factorial(int n){ int ret = 1; for(int i = 1; i < n + 1; ++i) { ret = ret * i; } return ret; }

/* 最大公約数 */
template <typename T>T gcd(T x, T y){ return x % y == 0 ? y : gcd(y, x % y); }

/* 最小公倍数 */
template <typename T>T lcm(T a, T b) { return a * b / gcd(a, b); }

/* n個の整数の最小公倍数 */
template <typename T>T lcm_n(vector<T> &numbers) { T l; l = numbers[0]; for(int i = 1; i < numbers.size(); ++i) { l = lcm(l, numbers[i]); } return l; }

/*
 * DP向け
 */
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; }

/*
 * グラフ
 */
class Graph {
   public:
    vector<vector<int>> G;
    vector<int> Trans;
    vector<int> inDeg;
    int numV;
 
    Graph(int numV) {
        this->numV = numV;
        inDeg.assign(numV, 0);
        Trans.assign(numV, 0);
        G.assign(numV, vector<int>());
    }
 
    int topologicalSort(int v, vector<int> &dp) {
        if (dp[v] != -1) {
            return dp[v];
        }
 
        int res = 0;
 
        for (auto to : G[v]) {
            chmax(res, topologicalSort(to, dp) + 1);
        }
 
        return dp[v] = res;
    }
};


int main(){
int n,m;
cin >> n>>m;
cout << n*(n-1)/2 + m*(m-1)/2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N, Q;
string S, SInitial;
set<int> st[26];
int type[30000];
int l[30000];
int r[30000];
char c[30000];
int idx[30000];

void input() {
    cin >> N;
    cin >> S;
    cin >> Q;
    for(int q = 0; q < Q; q++) {
        cin >> type[q];
        if(type[q] == 1) {
            cin >> idx[q] >> c[q];
        } else {
            cin >> l[q] >> r[q];
        }
    }
}

void solve() {
    SInitial = S;
    for(int i = 0; i < 26; i++) {
        st[i].clear();
        st[i].insert(N);
    }
    for(int i = 0; i < N; i++) {
        st[(int)(S[i] - 'a')].insert(i);
    }
    for(int q = 0; q < Q; q++) {
        if(type[q] == 1) {
            st[(int)(S[idx[q]-1] - 'a')].erase(idx[q] - 1);
            S[idx[q]-1] = c[q];
            st[(int)(S[idx[q]-1] - 'a')].insert(idx[q] - 1);
        } else {
            int ANS = 0;
            for(int i = 0; i < 26; i++) {
                auto itr = st[i].lower_bound(l[q] - 1);
                if(*itr <= r[q] - 1) ANS++;
            }
            cout << ANS << "\n";
        }
    }
    return;
}

int main() {
    input();
    solve();
    return 0;
}

Measured memory_bytes: 25092
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> pint;
#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int main(){
	int n;
	for(;cin>>n;){
		int k=1;
		while(n){
			if(n&1){
				cout<<k;
				cout<<(n!=1?' ':'\n');
			}
			n/=2;
			k*=2;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void) {
char A[4],B[4];
int i,count=0;
scanf("%s %s",&A, &B);
for(i=0;i<3;i++){
	if(A[i]==B[i]){
		count++;
	}
}
printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main()
{
  int x=0,y=0,z=0,n=0,m=0,w=0;
  std::cin >> x>>y>>z>>w;
  if(x<z){
    if(z<y)std::cout << min(y,w)-max(z,x) << '\n';
    else std::cout << 0 << '\n';
  }else if(x==z){
    std::cout << min(y,w) << '\n';
  }else{
    if(x<w)std::cout <<min(y,w)-max(x,z)  << '\n';
    else std::cout << 0 << '\n';
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define SUM(v) accumulate(v.begin(),v.end(),lli(0))
#define rev(n,d) for(int i=n;i>=d;i--)
#define FOR0(n) for(int i=0;i<n;i++)
#define FOR(a,n) for(int i=a;i<n;i++)
#define FORQ(a,n) for(int i=a;i<=n;i++)
#define inf 1000000009
#define inff 0x3f3f3f3f
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define mem(ar,x) memset(ar,x,sizeof ar)
#define present(container, element) (container.find(element) != container.end())
#define max3(a,b,c) return (lli(a)>lli(b)?(lli(a)>lli(c)?a:c):(lli(b)>lli(c)?b:c))
#define max4(a,b,c,d) return (max3(a,b,c)>lli(d)?(max3(a,b,c)):d)
#define min3(a,b,c) return (lli(a)<lli(b)?(lli(a)<lli(c)?a:c):(lli(b)<lli(c)?b:c))
#define min4(a,b,c,d) return (max3(a,b,c)<lli(d)?(max3(a,b,c)):d)
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii>ppii;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<pii>vpii;
const int N=100005;
int dr8[]={0,0,1,-1,1,1,-1,-1};
int dc8[]={1,-1,0,0,-1,1,-1,1};
int dr4[]={0,1,-1,0};
int dc4[]={1,0,0,-1};
int main(){
	fast
	int n,k;
	cin>>n>>k;
	int a[n];
	FOR0(n) cin>>a[i];
	int dp[k+1];
	mem(dp,0);
//	dp[0]=1;
	for(int i=1;i<=k;i++){
		for(int j=0;j<n;j++){
			if((i-a[j])<0) continue;
			if(dp[i-a[j]]==0) dp[i]=1;
		}
	}
	if(dp[k]==1) cout<<"First";
	else cout<<"Second";
}

Measured memory_bytes: 640
// AtCoder template
// 見た奴全員saba!
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

vector<vector<int>> graph(8);

vector<bool> used(8,false);
int n;
int dfs(int now, int depth){
    if(used[now]) return 0;
    if(depth == n) return 1;
    int ret = 0;
    used[now] = true;
    rep(i,graph[now].size()) ret += dfs(graph[now][i], depth+1);    
    used[now] = false;
    return ret;
}

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

    // グラフ構築
    int m; cin >> n >> m;
    int a,b; rep(i,m){
        cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    
    int ans = 0;
    ans += dfs(0, 1);
    cout << ans << "\n";
}

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

typedef pair<int, int> P;

int main() {
    int N;
    cin >> N;
    vector<P> red(N);
    priority_queue<P, vector<P>, greater<P>> blue;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        red[i] = (P(b, a));
    }
    for (int i = 0; i < N; i++) {
        int c, d;
        cin >> c >> d;
        blue.push(P(c, d));
    }

    sort(red.begin(), red.end(), greater<P>());
    vector<bool> used(N);

    int res = 0;
    while (!blue.empty()) {
        P b = blue.top(); blue.pop();
        for (int i = 0; i < N; i++) {
            if (red[i].second < b.first && red[i].first < b.second && !used[i]) {
                res++;
                used[i] = true;
                break;
            }
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
N , M = map(int, input().split())
import numpy as np
list1=np.array(list(map(int, input().split())))
dp = np.array([float('inf') for i in range(N)])
dp[0] = 0
#print(np.abs(list1[1]-list1[1:1+1]))
for i in range(N):
    if i - M < 0:
        dp[i] = np.min(dp[:i+1]+np.abs(list1[i]-list1[:i+1]) )
    else:
        dp[i] = np.min(dp[i-M:i+1]+np.abs(list1[i]-list1[i-M:i+1]) )
    #print(dp)
print(int(dp[N-1]))

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

using namespace std;

typedef long long int lli;

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

    int n;
    cin >> n;

    int prime[100] = { 0 };
    for (int i=1; i<=n; i++) {
        int tmp = i, div = 2;
        while (tmp > 1) {
            if (tmp%div) {
                div++;
                continue;
            }
            prime[div]++;
            tmp /= div;
        }
    }

    int num[75] = { 0 };
    for (auto p : prime) num[min(p, 74)]++;
    for (int i=73; i>=0; i--) num[i] += num[i+1];

    int ans = 0;

    // 4 - 4 - 2
    ans += (num[4] * (num[4]-1) * (num[2]-2)) / 2;  
    // cout << ans << " ";
    // 24 - 2
    ans += (num[24] * (num[2]-1));
    // cout << ans << " ";
    // 14 - 4
    ans += (num[14] * (num[4]-1));
    // cout << ans << " ";
    // 74
    ans += num[74];
    // cout << ans << endl;

    cout << ans << endl;

    return 0;
}


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

int min(int i, int j){
        if (i<j) {
                return i;
        }else{
                return j;
        }
}

int desc(const void *a, const void *b) {
        return *(int *)b - *(int *)a;
}

int main(void){
        int N,K;
        int L[100001];
        scanf("%d %d", &N,&K);
        for (int i = 0; i < N; i++) {
                scanf("%d", &L[i]);
        }
        qsort(L,N,sizeof (int), desc);
        long long ans = 100000000000;
        for (int i = 0; i < N-K+1; i++) {
                //printf("%d %d\n",L[i+K-1],L[i]);
                ans = min(ans,abs(L[i+K-1] - L[i]));
        }
        printf("%lld\n",ans);
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define all(v) (v).begin(), (v).end()


int main(){
  int a[4][3][10] = {};

  int n;cin>>n;
  rep(i,n){
    int b,f,r,v;
    cin>>b>>f>>r>>v;
    b--;f--;r--;
    a[b][f][r] += v;
  }
  rep(i,4){
    rep(j,3){
      rep(k,10){
        cout<<" "<<a[i][j][k];
      }
      cout<<endl;
    }
    if(i==3)break;
    cout<<"####################"<<endl;
  }
}


Measured memory_bytes: 3116
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val S = Array(N) { "" }

    for (i in S.indices) {
        S[i] = readLine()!!
    }
    val INF = 1e6.toInt()
    val mat = Array(N) { i -> Array(N) { j -> if (i == j) 0 else INF } }

    for (i in S.indices) for (j in i + 1 until S.size) {
        if (S[i][j] == '1') {
            mat[i][j] = 1
            mat[j][i] = 1
        }
    }

    for (k in mat.indices) for (i in mat.indices) for (j in mat.indices) {
        mat[i][j] = Math.min(mat[i][j], mat[i][k] + mat[k][j])
    }

    var res = -1
    for (k in mat.indices) {
        var r = 0
        var f = true
        for (i in mat.indices) {
            r = Math.max(r, mat[k][i])

            for (j in i + 1 until mat.size) {
                f = f && (mat[k][i] != mat[k][j] || S[i][j] == '0')
            }
        }

        if (f) {
            res = Math.max(res, r + 1)
        }
    }

    println(res)
}


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

int isPalindrome(int n)
{
    int temp = n;
    int rev = 0;

	while(temp>0)
	{
		rev = 10*rev + temp%10;
		temp /= 10;
	}

	if(rev == n)	return 1;
	else			return 0;
}

int main()
{
	int n,count=0, a, b;
    cin>>a>>b;
	for(int j=a; j<=b; j++)
	{
	    if(isPalindrome(j))
	    {
	        count++;
	    }
	}
	cout<<count<<endl;
	return 0;
}



Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
const ll mod = 1e9 + 7;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
    const double PI = 3.14159265358979;

    int N;
    cin >> N;
    vector<int> d(N);
    REP(i, N) cin >> d[i];
    int res = 0;
    REP(i, N) REP(j, N) {
        if(i == j) continue;
        res += d[i]*d[j];
    }
    cout << res/2 << endl;
}

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;
//////////////////////////


ll n,k;
vector<ll>a;

bool che(ll m){
    ll sum=0;
    rep(i,0,n-1){
        ll ad=(a[i]-1)/m;
        sum+=ad;
    }
    return sum<=k;
}

int main(){fastio
    cin>>n>>k;
    a.resize(n);
    rep(i,0,n-1)cin>>a[i];
    ll ok=inf,ng=0;
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        if(che(mid))ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
    
    return 0;
}


Measured memory_bytes: 4676
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	double a,b;
	cin>>a>>b;
	cout<<(int)a/(int)b<<endl;
	cout<<(int)a%(int)b<<endl;
	printf("%.6lf\n",a/b);
	return 0;
}

Measured memory_bytes: 3268