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

int n,m,esum,dp[1<<15][15];
int g[15][15],sum[1<<15][15],cnt[1<<15];

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	int S,S0,i,j,u,v,w;
	scanf("%d%d",&n,&m);
	while (m--)
	{
		scanf("%d%d%d",&u,&v,&w);
		u--; v--;
		g[u][v]=g[v][u]=w;
		esum+=w;
	}
	for (S=0;S<1<<n;S++)
	for (i=0;i<n;i++) if ((S>>i)&1)
	for (j=0;j<n;j++)
		sum[S][j]+=g[i][j];

	memset(dp,-0x3f3f3f3f,sizeof(dp));
	dp[1][0]=0;
	for (S=0;S<1<<n;S++)
	for (i=0;i<n;i++) if (dp[S][i]>=-1e9)
	{
//		printf("dp[%d][%d]=%d\n",S,i,dp[S][i]);
		for (j=1;j<n;j++)
			if (((S>>j)&1)==0&&g[i][j])
			{
				dp[S|(1<<j)][j]=max(dp[S|(1<<j)][j],dp[S][i]+g[i][j]);
			}
		int full=(1<<n)-1-S;
		for (S0=full;S0;S0=(S0-1)&full)
		{
			int cc=0;
//			for (j=0;j<n;j++)
//				if ((S0>>j)&1) cc+=sum[S-(1<<i)][j];

			int set=S0+(1<<i);

			for (j=0;j<n;j++)
			{
				if ((set>>j)&1)
					for (int k=j+1;k<n;k++)
					{
						if ((set>>k)&1)
							cc+=g[j][k];
					}
			}

//			if (S==1&&S0==2)
//			{
//				printf("set=%d\n",set);
//				printf("cc=%d\n",cc);
//			}


			dp[S|S0][i]=max(dp[S|S0][i],dp[S][i]+cc);
		}
//		printf("dp[%d][%d]=%d\n",S,i+1,dp[S][i]);
	}

//	printf("%d\n",dp[(1<<n)-1][n-1]);
	printf("%d\n",esum-dp[(1<<n)-1][n-1]);

}




Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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


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

struct guide{
    string city;
    int point;
    
    guide(string s, int p){
        city = s;
        point = p;
    }
    bool operator<(const guide &another) const
    {
        return city==another.city ? point<another.point : city>another.city;
    };
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<pair<string,int>> v;
    REP(i,n){
        string s;
        int p;
        cin>>s>>p;
        v.push_back({s,p});
    }
    vector<int> idx(v.size());
    iota(idx.begin(),idx.end(),0);
    sort(idx.begin(),idx.end(),
         [&](int x, int y){return v[x].first == v[y].first ? v[x].second > v[y].second : v[x].first < v[y].first ;}
         );

    for(auto i:idx){
        cout<<i+1<<endl;
    }
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    s = S()

    return s[::2]


print(main())






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

int main(){
  string s;
  cin>>s;
  int price=700;
  for(int i=0;i<3;i++){
    if(s.at(i) == 'o'){
      price+=100;
    }
  }
  cout<<price<<endl;
}
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n)
    {
        cin >> a[i];
    }

    vector<vector<ll>> dp(n + 1, vector<ll>(2));
    dp[0][0] = 0;
    dp[0][1] = -999999;

    for (int i = 0; i < n; i++)
    {
        dp[i + 1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i]);
        dp[i + 1][1] = max(dp[i][0] - a[i], dp[i][1] + a[i]);
    }

    Cout(dp[n][0]);

    return 0;
}

Measured memory_bytes: 6144
import sys
from collections import deque

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, k, x, y = [ni() for _ in range(4)]
print(x * min(n, k) + y * max((n - k), 0))


Measured memory_bytes: 3316
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N = I()
A = LI()
ans = 'APPROVED'
for i in A:
    if i%2==0 and i%3!=0 and i%5!=0:
        ans = 'DENIED'
        break
print(ans)


Measured memory_bytes: 59212
let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in
  doit str []

let solve n q =
  let s = Array.init n (fun i -> i) in
  let rec find u =
    if u = s.(u) then u
    else begin
      s.(u) <- find s.(u);
      s.(u)
    end in
  let rec doit i =
    if i < q then begin
      begin match List.map int_of_string (split (read_line ()) ' ') with
      | 0 :: x :: y :: _ -> s.(find x) <- find y
      | 1 :: x :: y :: _ -> print_endline (if find x = find y then "1" else "0")
      | _ -> ()
      end;
      doit (i + 1)
    end in
  doit 0

let () =
  match List.map int_of_string (split (read_line ()) ' ') with
  | [n; q] -> solve n q
  | _ -> ()

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

#define ll long long
#define pb push_back
#define eb emplace_back
//#define st first
#define sc second

using namespace std;

const ll mod = 1e9 + 7;
const int e = 50 + 69;
const int base = 311;

// dung inverse module de tinh nCk
// beginer 78
// mbeginer
// cach tao hoan vi tu n so : n*(n+1)/2;

//vector<pair<ll,ll>>adj[e];
//vector<ll>adj[e];

/*ll Pow(ll n, ll dem)
{
    if(dem == 0) return 1;
    if(dem == 1) return n ;
    ll t = Pow(n, dem/2);
    if(dem % 2 == 0) return (t*t);
    else return ((t * t) * n);
}*/

/*ll C(ll k, ll n)
{
    if(k == 0) return 1;
    if(n < k) return 0;
    return (gt[n]%mod * (igt[k]%mod * igt[n-k]%mod)%mod)%mod;
}*/

int n, m, k;
ll d[1000];

int main()
{
    cin >> n >> k;
    map<ll,ll>kt;
    for(int i=1; i<=k; i++)
    {
        ll x;
        cin >> x;
        for(int j=1; j<=x; j++)
        {
            ll fuck;
            cin >> fuck;
            kt[fuck] ++;
        }
    }
    ll dem = 0;
    for(int i=1; i<=n; i++)
    {
        if(kt[i] == 0)
        {
            dem ++;
        }
    }
    cout << dem;
}
/*

*/


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include<bitset>
using namespace std;
const int MOD = 1e9 + 7;
int n; // no. of pairs
inline int add(int a, int b){
	a += b;
	if(a >= MOD)a -= MOD;
	return a;
}
int findways(vector<int> &dp, int male, int mask, vector<vector<int>> &check)
{
  //cout << "mask " << std::bitset<5>(mask)<<endl;
  if (mask == 0)
    return 1;
  if (dp[mask] != -1)
    return dp[mask];
  dp[mask] = 0;
// male is ith male for which female has to be choosen
  for (int female = 0; female < n; ++female) // ith female
    if (check[male - 1][female] && (mask & (1 << female))) // ith female available or not
    {
      int new_mask = mask ^ (1 << female);
     
      dp[mask] = add(dp[mask], findways(dp, male - 1,  new_mask, check));
    }
  return dp[mask];
}

int main()
{
  ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
  cin >> n;
  vector<vector<int>> check(n, vector<int>(n));
  vector<int> dp(1 << n, 0);
  for(auto &x: dp)
    x = -1;
  for (auto &x : check)
    for (auto &y : x)
      cin >> y;
  cout << findways(dp, n, (1 << n) - 1, check) << endl;

  return 0;
}

Measured memory_bytes: 8448
/**
 * Created by hiramekun at 14:14 on 2019-08-27.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}


template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;

    const ll MAX_V = e5 * 2;
    vector<ll> G[MAX_V];
    vector<bool> seen(MAX_V);
    vector<ll> c(2);
    auto dfs = [&](auto &&f, ll now) -> void {
        seen[now] = true;
        c[now / e5]++;
        each(e, G[now]) {
            if (!seen[e]) {
                f(f, e);
            }
        }
    };
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        x--, y--;
        G[x].eb(y + e5);
        G[y + e5].eb(x);
    }

    ll ans = 0;
    rep(i, MAX_V) {
        if (seen[i]) continue;
        c = vector<ll>(2);
        dfs(dfs, i);
        ans += c[0] * c[1];
    }
    cout << max(0LL, ans - n) << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}



Measured memory_bytes: 9344
def main():
    import sys

    MOD = 1000000007
    N, *A = map(int, sys.stdin.buffer.read().split())
    C = [0] * (N + 1)
    C[0] = 3
    ans = 1
    for a in A:
        ans = ans * C[a]
        C[a] -= 1
        C[a + 1] += 1

    print(ans % MOD)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 12404
#include<stdio.h>

int main(void){
   int a,b,i,j;
   scanf("%d %d",&a,&b);

   if(a<=b){
      for(i=0;i<b;i++){
         printf("%d",a);
      }
   }else{
      for(j=0;j<a;j++){
         printf("%d",b);
      }
   }
   return 0;
      
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"Sunny", "Cloudy", "Rainy"};

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, n, num, cnt = 0;
  vector<int> a;
  bool pos[110] = {0};
  cin >> x >> n;
  for (int i = 0; i < n; i++) {
    cin >> num;
    pos[num] = 1;
  }
  for (int i = 0; i <= 105; i++) {
    if (pos[i] == 0) a.push_back(i);
  }
  int ans = upper_bound(a.begin(), a.end(), x) - a.begin();
  if (a[ans] - x >= x - a[ans - 1]) {
    ans--;
  }
  printf("%d\n", a[ans]);
  return 0;
}


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

using namespace std;

class RollingHash {
 private:
  const uint64_t mod = (UINT64_C(1) << 61) - 1;
  std::vector<uint64_t> hashes, pows;

  inline uint64_t add(uint64_t a, uint64_t b) const {
    a += b;
    if (a >= mod) a -= mod;
    return a;
  }

  inline uint64_t sub(uint64_t a, uint64_t b) const {
    if (a < b) a += mod;
    a -= b;
    return a;
  }

  inline uint64_t mul(uint64_t a, uint64_t b) const {
    uint64_t ah = a >> 31, al = a & ((UINT64_C(1) << 31) - 1), bh = b >> 31,
             bl = b & ((UINT64_C(1) << 31) - 1), m = ah * bl + al * bh,
             v = (ah * bh << 1) + (m >> 30) +
                 ((m & ((UINT64_C(1) << 30) - 1)) << 31) + al * bl;
    v = (v & ((UINT64_C(1) << 61) - 1)) + (v >> 61);
    return v;
  }

 public:
  template <typename T>
  RollingHash(const T &S, uint64_t base = 10007)
      : hashes(S.size() + 1, 0), pows(S.size() + 1, 0) {
    pows[0] = 1;
    for (size_t i = 0; i < S.size(); i++) {
      pows[i + 1] = mul(pows[i], base);
      hashes[i + 1] = add(mul(hashes[i], base), S[i]);
    }
  }

  // S[l, r)
  uint64_t slice(int l, int r) const {
    return sub(hashes[r], mul(hashes[l], pows[r - l]));
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  vector<int> S(N), T(N);
  for (int i = 0; i < N; i++) {
    S[i] = A[i] ^ A[(i + 1) % N];
    T[i] = B[i] ^ B[(i + 1) % N];
  }
  for (int i = 0; i < N; i++) {
    S.emplace_back(S[i]);
  }
  RollingHash rhs(S), rht(T);
  for (int i = 0; i < N; i++) {
    if (rhs.slice(i, i + N) == rht.slice(0, N)) {
      cout << i << ' ' << (A[i] ^ B[0]) << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 16996
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define ll long long

using namespace std;

int countDigit(long long n) 
{ 
    return floor(log10(n) + 1); 
}

int main()
{
	int a,b;
	cin >> a >> b;
	string lose;
	cin >> lose;
	int count = a;
	vector<int> otpt;
	bool imp = false;
	while (count > 0)
	{
		int temp = b;
		if (count<temp)
		{
			temp = count;
		}
		else
		{
			while (lose[count-temp]=='1')
			{
				temp--;
				if (temp == 0)
				{
					imp = true;
					break;
				}
			}
		}
		if (temp == 0) break;
		count = count - temp;
		otpt.insert(otpt.begin(), temp); 
	}
	if (imp) cout << -1;
	else
	{
		for (int i=0;i<otpt.size();i++)
		{
			cout << otpt[i] << " ";
		}
	}
}



Measured memory_bytes: 1144
import java.util.Scanner;
class Main{
    public static void main(String arg[]){
        Scanner scn=new Scanner(System.in);
        int r = scn.nextInt();
        int D=scn.nextInt();
        int x2000=scn.nextInt();
        for(int i=1;i<=10;i++){
            int x = r*x2000-D;
            System.out.println(x);
            x2000 =  x;
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    long long n, k;
    std::cin >> n >> k;
    long long res = k;
    for (int i = 1; i < n; ++i) {
        res *= k - 1;
    }
    std::cout << res << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int count= 0;

		String L = scan.nextLine();
		String[] l = L.split(" ");

		int n = Integer.parseInt(l[0]);
		int x = Integer.parseInt(l[1]);
		int t = Integer.parseInt(l[2]);

		if(n % x == 0) {
			count = n / x;
		}else {
			count = n / x +1;
		}

		System.out.println(count * t);

		scan.close();


	}

}


Measured memory_bytes: 35588
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long MODPOW(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


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

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std ;
using V_2 = vector<vector<int>> ;
#define M 1000000007

int s ;

int main(){
  cin>> s ;
  V_2 dp(s+1,vector<int>(s+1,0)) ;
  for(int i = 0 ; i < s + 1 ; i++) dp[i][0] = 1 ;
  for(int i = 1 ; i < s + 1 ; i++){
    for(int j = 3 ; j < s + 1 ; j++){
      dp[i][j] = (dp[i][j-1] + dp[i-1][j-3]) % M ;
      //cout << i << " " << j << " " << dp[i][j] << endl ;
    }
  }
  cout << dp[s][s] << endl ;
}

Measured memory_bytes: 19004
#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 <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    ll calc(vector<ll> X, ll L) {


        //L = 1 => n
        int n = X.size();
        ll val = L - X[0];
        ll ret = val;
        for (int i = 1; i < n; ++i) {
            val += L;
            val -= 2 * X[i];
            if (i % 2) {
                val += 2 * X[i / 2];
            } else {
                val += X[i / 2 - 1];
                val += X[i / 2];
            }

            chmax(ret, val);
        }

        val = X[n - 1];
        int state = 1;   //pt1かpt2か
        int pt1 = n - 1; //ひとつを-2
        int pt2 = n - 1; //ふたつを-1
        for (int i = n - 2; i >= 0; --i) {
            val += L;
            val += 2 * X[i];
            if (state == 1) {
                state = 2;
                val -= 2 * X[pt1];
                pt1--;
            } else {
                state = 1;
                val -= X[pt2];
                val -= X[pt2 - 1];
                pt2--;
            }

            chmax(ret, val);
        }

        return ret;
    }

    void solve() {
        input();
        ll L;
        int N;
        cin >> L >> N;

        vector<ll> X(N);
        rep(i, 0, N) cin >> X[i];

        ll ans = calc(X, L);
        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 3328
// use std::cmp::Reverse;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn check(a: &Vec<usize>, f: &Vec<usize>, x: usize, k: usize) -> bool {
    let mut count = 0;
    for i in 0..a.len() {
        if a[i] * f[i] <= x {
            continue;
        }
        count += a[i] - x / f[i];
        if count > k {
            return false;
        }
    }
    true
}

fn main() {
    let input = read_vec::<usize>();
    let (_, k) = (input[0], input[1]);
    let mut ax = read_vec::<usize>();
    let mut fx = read_vec::<usize>();

    // ax.sort_by_key(|&x| Reverse(x));
    ax.sort();
    ax.reverse();
    fx.sort();

    let mut lo = 0;
    let mut hi = ax.iter().zip(fx.iter()).map(|(a, f)| a * f).max().unwrap();

    let mut ans = hi;
    while lo < hi {
        let mid = (lo + hi) / 2;
        if check(&ax, &fx, mid, k) {
            hi = mid;
            ans = mid;
        } else {
            lo = mid+1;
        }
    }

    println!("{}", ans);
}

Measured memory_bytes: 12800
import functools
import heapq


def main():
    from sys import stdin, stdout

    def read():
        return stdin.readline().rstrip('\n')

    def read_array(sep=None, maxsplit=-1):
        return read().split(sep, maxsplit)

    def read_int():
        return int(read())

    def read_int_array(sep=None, maxsplit=-1):
        return [int(a) for a in read_array(sep, maxsplit)]

    def write(*args, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in args) + end)

    def write_array(array, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in array) + end)

    N, K = read_int_array()
    nums = read_int_array()
    ans = 0

    @functools.lru_cache(None)
    def dp(i, j, handsum):
        nonlocal ans
        left = j + 1 - i
        taken = N - left
        if taken == K:
            ans = max(ans, handsum)
            return
        moves = K - taken

        if i <= j:
            dp(i+1, j, handsum + nums[i])
            dp(i, j-1, handsum + nums[j])

        can_return = sum(sorted([x for x in (nums[:i] + nums[j+1:]) if x < 0])[:moves])
        ans = max(ans, handsum - can_return)

    dp(0, N-1, 0)
    write(ans)

main()


Measured memory_bytes: 43760
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int N=400, M=100001;

int n, m, k, u, v, x, y, t, a, b, ans;
int X[M], Y[M];
bitset<N> B[N];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m;
	for (int i=1; i<=m; i++) cin>>X[i]>>Y[i], X[i]--, Y[i]--;
	for (int i=0; i<n; i++){
		B[i].set(i);
		for (int j=m; j; j--){
			if (B[i][X[j]] && B[i][Y[j]]){
				B[i].reset();
				break ;
			}
			if (!B[i][X[j]] && !B[i][Y[j]]) continue ;
			B[i].set(X[j]);
			B[i].set(Y[j]);
		}
	}
	for (int i=0; i<n; i++)
		for (int j=i+1; j<n; j++)
			if (B[i][i] && B[j][j]) ans+=((B[i]&B[j]).count()==0);
	
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int A, B, C, X; cin >> A >> B >> C >>X;
  
  int ans = 0;
  
  rep(i, A+1) rep(j, B+1) rep(k, C+1) 
    if(500*i+100*j+50*k == X) ans++;
  
  cout << ans << endl;
  
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

priority_queue<ll> lft;
priority_queue<ll,vector<ll>,greater<ll>> rht;
ll lo = 0LL, ro = 0LL;
ll ans = 0LL;

const int limit = 100010;
ll l[limit],r[limit],p[limit];

int main(void){
	int n;
	cin >> n;

	rep(i,n){
		cin >> l[i] >> r[i];
		p[i] = r[i] - l[i];
	}

	lft.push(l[0]-lo);
	rht.push(l[0]-ro);
	

	rep(i,1,n){
		lo -= p[i],ro += p[i-1];
		
		lft.push(l[i]-lo);
		rht.push(l[i]-ro);
	
		while(lft.top() + lo > rht.top() + ro){
			ll L = lft.top() + lo, R = rht.top() + ro;
			lft.pop(),rht.pop();
			ans += L - R;
			lft.push(R - lo), rht.push(L - ro);
		}
	}


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

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,sum=1;
    string s;
    cin >> n >> s;
    for(int i = 0; i < s.size()-1; i++){
        if(s.at(i) != s.at(i+1))sum++;
    }
    cout << sum << endl;
}

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

int main() {
    long X,siawase;
    siawase = 0;
    cin >> X;
    while (X >= 500) {
        X = X - 500;
        siawase = siawase + 1000;


  }
    while (X >= 5) {
        X = X - 5;
        siawase = siawase + 5;
    }
    cout << siawase << endl;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <utility>
#include <cmath>

using namespace std;

void solve(vector<pair<int, int> > p, vector<pair<int, int> >& ret) {
  if (ret.size() > 0)
    return;
  if (p.size() == 8) {
    for (int i = 0; i < 8; ++i) {
      ret.push_back(p[i]);
    }
  } else {
    for (int i = 1; i <= 8; ++i) {
      for (int j = 1; j <= 8; ++j) {
        bool okay = true;
        for (int k = 0; k < p.size(); ++k) {
          if (p[k].first == i || p[k].second == j) {
            okay = false;
            break;
          } else if (abs(j - p[k].second) == abs(i - p[k].first)) {
            okay = false;
            break;
          }
        }
        if (okay) {
          vector<pair<int, int> > tmp = p;
          tmp.push_back(make_pair(i, j));
          solve(tmp, ret);
        }
      }
    }
  }
}

int main(int argc, char* argv[]) {
  int k;
  cin >> k;

  vector<pair<int, int> > p;
  for (int i = 0; i < k; ++i) {
    int x, y;
    cin >> y >> x;
    p.push_back(make_pair(y + 1, x + 1));
  }

  vector<pair<int, int> > ret;
  solve(p, ret);

  for (int i = 0; i < 8; ++i) {
    for (int j = 0; j < 8; ++j) {
      bool found = false;
      for (int k = 0; k < 8; ++k) {
        if (ret[k].first == i + 1 && ret[k].second == j + 1) {
          found = true;
          break;
        }
      }
      if (found)
        cout << "Q";
      else
        cout << ".";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3096
var
	n,i:Longint;
	s:String;
begin
	readln(s);
	n:=length(s);
	i:=1;
	while(i<n)and not((s[i]=s[i+1])or((i+1<n)and(s[i]=s[i+2])))do inc(i);
	if i=n then writeln('-1 -1')else if s[i]=s[i+1] then writeln(i,' ',i+1)else writeln(i,' ',i+2);
end.


Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,numpy,string,decimal
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def SS(): return map(str,sys.stdin.readline().rstrip().split())
def II(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
 
N,K = II()
A = LI()
flag = [False]*N
past = []
past.append(0)
now = 0
cnt = 1
for k in range(K):
  now = A[now]-1
  if flag[now]:
    past = past[past.index(now)::]
    print(past[(K - cnt) % len(past)]+1)
    exit()
  flag[now] = True
  cnt += 1
  past.append(now)
print(now+1)

Measured memory_bytes: 50856
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>

int main() {
	constexpr long long int mod = 2019;
	constexpr long long int f = 673;
	long long int l, r; std::cin >> l >> r;
	if (l + f <= r) {
		std::cout << 0 << std::endl;
	}
	else {
		auto min = mod;
		for (auto i = l; i < r; ++i) {
			for (auto j = i + 1; j <= r; ++j) {
				if (min > (i * j) % mod) {
					min = (i * j) % mod;
				}
			}
		}
		std::cout << min << std::endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)
#include "string"

const int N = 1001;
const int inf = 1e9;
int g[N][N];
vector<int>adj[N];

void print(int n){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)
			cout<<g[i][j]<<" ";
		cout<<endl;
	}
}

void bfs(int x){
	memset(g[x],1,sizeof g[x]);
	queue<int>q;
	q.push(x);
	g[x][x] = 0;

	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(int v:adj[u]){
			if(g[x][v]>g[x][u]){
				g[x][v] = g[x][u] + 1;
				q.push(v);
			}
		}
	}
}

int32_t main() { 
	boost;
	int n,m;
	cin>>n>>m;
	memset(g,1,sizeof g);
	for(int i=0,u,v;i<m;i++){
		cin>>u>>v;
		g[u][v] = 1;
		adj[u].push_back(v);
	}
	for(int i=1;i<=n;i++)
		bfs(i);
	//print(n);
	int root = 1,mx = g[0][0];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i == j)
				continue;
			if(g[i][j]+g[j][i] < mx){
				mx = g[i][j]+g[j][i];
				root = i;
			}
		}
	}

	if(mx > 2002){
		cout<<-1<<endl;
		return 0;
	}

	cout<<mx<<endl;
	for(int i=1;i<=mx;i++){
		cout<<root<<endl;
		for(int v:adj[root]){
			if(g[v][root] + g[root][v] == mx){
				root = v;
				break;
			}
		}
	}
}	 

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

int main() {
  int h,w;
  cin >> h >> w;
  rep(i,0,h){
    rep(j,0,w){
      string s;
      cin >> s;
      if(s == "snuke"){
        char a = 'A'+j;
        cout << a << i+1 << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    double t,x;
    cin >> t >> x;
    cout << t/x;
}

Measured memory_bytes: 384
N = int(input().strip())

x, y, z = 1, 1, 1

f = [0] * (N + 1)

# while x**2 + y**2 + z**2 + x*y + y*z + x*z <= N:
def calc(x, y, z, f, axis="xyz"):
    # print(x, y, z)
    n = x**2 + y**2 + z**2 + x*y + y*z + x*z

    if n <= N:
        f[n] += 1
        if axis == "xyz":
            f = calc(x+1, y, z, f, axis="xyz")
            f = calc(x, y+1, z, f, axis="yz")
            f = calc(x, y, z+1, f, axis="z")
        elif axis == "yz":
            f = calc(x, y+1, z, f, axis="yz")
            f = calc(x, y, z+1, f, axis="z")
        elif axis == "z":
            f = calc(x, y, z + 1, f, axis="z")
        return f
    else:
        return f

f = calc(x, y, z, f)


for i in range(1, N+1):
    print(f[i])

Measured memory_bytes: 9404
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll h, w;
    cin >> h >> w;
	vector<vector<char>> board(h, vector<char>(w));
	rep(i, h){
        bool flag = true;
        rep(j, w){
			cin >> board[i][j];
            if(board[i][j] == '#'){
                flag = false;
            }
        }
        if(flag){
            board.erase(board.begin() + i);
            i--;
            h--;
        }
    }
    rep(j, w){
        bool flag = true;
        rep(i, h){
            if(board[i][j] == '#'){
                flag = false;
            }
        }
        if(flag){
            rep(i, h){
                board[i].erase(board[i].begin() + j);
            }
            j--;
            w--;
        }
    }
    rep(i, h){
        rep(j, w){
            cout << board[i][j];
        }
        cout << endl;
    }

}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

struct stack{
  int a[101];
  unsigned n;
  stack():a(),n(0){}
  int pop(){return a[--n];}
  void push(int in){a[n++]=in;}
};

int main(){
  stack s;
  char buf[10];

  while(scanf("%s",buf) != EOF){
    int a,b;
    switch(buf[0]){
      case '+' : a = s.pop(); b = s.pop(); s.push(b+a); break;
      case '-' : a = s.pop(); b = s.pop(); s.push(b-a); break;
      case '*' : a = s.pop(); b = s.pop(); s.push(b*a); break;
      default  : s.push(atoi(buf));
    }
  }
  printf("%d\n",s.pop());
}

Measured memory_bytes: 980
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int lm=4280;
		int m=0;
		while(true){
			int w=sc.nextInt();
			if(w==-1)break;
			if(w<=10)m=1150;
			else if(w<=20)m=1150+125*(w-10);
			else if(w<=30)m=1150+125*10+140*(w-20);
			else m=1150+125*10+140*10+160*(w-30);
			System.out.println(lm-m);
		}
	}
}

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

long long combinations(int n) {
	int k = 2;
	ll top = 1;
	for (int i=n; i>1 && i>n-k; i--) {
		top *= i;
	}
	return top / k;
}

int main() {
	int n, m;
	cin >> n >> m;
	int total = combinations(n) + combinations(m);
	printf("%d\n", total);
}


Measured memory_bytes: 256
import fileinput
T = [0 for i in range(26)]
for line in fileinput.input():
 S = list(map(int, line.encode() ))
 A = ord('A')
 Z = ord('Z')
 a = ord('a')
 z = ord('z')
 for c in S:
  if A<=c<=Z:
   T[c-A] = T[c-A]+1
  elif a<=c<=z:
   T[c-a] = T[c-a]+1
for c in range(a,z+1):
 print(chr(c),":",T[c-a])



Measured memory_bytes: 5592
#include<stdio.h>

int main() {
	int n, m; //max100
	int A[100][100];
	int B[100];
	int O[100] = {0};

	//READ
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			scanf("%d", &A[i][j]);
		}
	}
	for (int j = 0; j < m; j++) {
		scanf("%d", &B[j]);
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			O[i] += A[i][j] * B[j];
		}
	}

	for (int i = 0; i < n; i++) {
		printf("%d\n", O[i]);
	}

	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	ll n, k;
	cin>>n>>k;
	ll ans = 0;
	ll mod = 1000000007;
	for(ll i = k; i <= n + 1; i++){
		ll tmp = (1 + i*(n - i + 1))%mod;
		ans += tmp; if(ans >= mod)ans -= mod;
	}
	cout<<ans<<endl;

	return 0;
}

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

template<typename T>
struct LevenshteinDistance {
	static constexpr T INF = numeric_limits<T>::max();
	const T costInsert, costErase, costReplace;
	LevenshteinDistance(T i, T e, T r) :
		costInsert(i),
		costErase(e),
		costReplace(r)
		{}
	T distance(string& s1, string& s2){
		int n1 = s1.size(), n2 = s2.size();
		// dp[i][j]:=s1のi文字目までとs2のj文字目までの距離
		vector<vector<T>> dp(n1 + 1, vector<T>(n2 + 1, INF));
		for(int i = 0; i <= max(n1, n2); ++i) {
			if(i <= n1) dp[i][0] = (T)i * costErase;
			if(i <= n2) dp[0][i] = (T)i * costInsert;
		}
		for(int i = 1; i <= n1; ++i) {
			for(int j = 1; j <= n2; ++j) {
				dp[i][j] = min(dp[i][j], dp[i][j - 1] + costInsert);
				dp[i][j] = min(dp[i][j], dp[i - 1][j] + costErase);
				dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + (s1[i - 1] == s2[j - 1] ? 0 : costReplace));
			}
		}
		return dp[n1][n2];
	}
};

int main() {
	LevenshteinDistance<int> ld(1, 1, 1);
	string s1, s2; cin >> s1 >> s2;
	cout << ld.distance(s1, s2) << endl;
	return 0;
}



Measured memory_bytes: 6912
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int g = n / 2;
        int k = n % 2 == 0 ? (n / 2) : (n / 2 + 1);
        System.out.println(g * k);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std; 
using P = pair<int,int>;
using ll = long long;
using Graph = vector<vector<P>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

vector<int> color;
void dfs(const Graph &G, int v, int cur = 0){
	color[v] = cur;
	for(auto next_v : G[v]){
		if(color[next_v.first]!=-1){
	//		cout << "color[v]:"<< endl;
			 continue;
		}
		if(next_v.second%2 == 0){
	//			cout << "color1[v]:"<< endl;
			dfs(G,next_v.first,cur);	
		}else{
	//			cout << "color2[v]:"<< endl;
			dfs(G,next_v.first,1-cur);
		}
	}
	return;
}

int main(void){
	int n;
  	cin >> n;
	Graph G(n);
	rep(i,n-1){
		int a,b,c;
		cin >> a >> b >> c ;
      	std::pair<int,int> p1= std::make_pair(b-1,c);
      	std::pair<int,int> p2= std::make_pair(a-1,c);
		G[a-1].push_back(p1);
		G[b-1].push_back(p2);
	}
	
	color.assign(n,-1);
	dfs(G,0);
	rep(i,n) cout << color[i] <<endl;
	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    ll r, d, x;
    cin >> r >> d >> x;
    rep(i,10){
        x = r*x - d;
        cout << x << endl;
    }
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std;



int main() {
	int n;
	cin >> n;
	char c;
	vector<int> w(n);
	for (int i = 0; i < n; i++) {
		cin >> c;
		w[i] = (i == 0 ? 0 : w[i - 1]);
		if (c == 'W') w[i] += 1;
	}
	int ans = n - w[n - 1] - (1 - w[0]);
	int tmp;
	for (int i =1; i < n; i++) {
		tmp = w[i - 1] + (n - w[n - 1] - (i + 1 - w[i]));
		ans = min(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n,k;
  cin >> n >> k;
  ll i,ans=0,j,mod=1e9+7;
  for(i=k;i<=n+1;i++){
    ll sum=0,sum1=0;
    sum=i*(i-1)/2;
    sum1=i*(n+n-i+1)/2;
    ans+=sum1-sum+1;
    ans%=mod;
  }
  cout << ans;
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] , cnt[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int x = 1 ; x <= n ; ++x)
	{
		for(int y = 1 ; y <= n ; ++y)
		{
			if(x*x + y*y + x*y > n)
				break ;
			for(int z = 1 ; z <= n ; ++z)
			{
				int res = x*x + y*y + z*z + x*y + y*z + x*z ;
				if(res > n)
					break ;
				cnt[res]++ ;
			}
		}
	}
	for(int i = 1 ; i <= n ; ++i)
		cout<<cnt[i]<<"\n" ;
	return 0 ;
}		

Measured memory_bytes: 3648
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[(int)Math.pow(10,5)+1];
        for (int i=0;i<n;i++){
            a[scanner.nextInt()]++;
        }
        int max = 0;
        for (int i = 1; i<a.length-2; i++){
            max = Math.max(max,a[i-1]+a[i]+a[i+1]);
        }
        System.out.println(max);

    }

}

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

int main() {
	int A, B, M;
	int a[100000], b[100000];
	int s = INT_MAX;
	cin >> A >> B >> M;
	for(int i = 0; i < A; i++)
		cin >> a[i];
	for(int i = 0; i < B; i++)
		cin >> b[i];
	for(int i = 0; i < M; i++) {
		int x, y, c;
		cin >> x >> y >> c;
		s = min(s, a[x-1] + b[y-1] - c);
	}
	s = min(s, *min_element(a, a + A) + *min_element(b, b + B));
	cout << s << endl;
}



Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vvl G;
vl ans;  // ans[v] : 頂点vのカウンターの値

void dfs(ll v, ll p = -1) {
    // 行きの処理はこのへんに書く
    for(auto u : G[v]) {
        if(u == p) {
            continue;
        }
        ans[u] += ans[v];
        dfs(u, v);
        // 帰りの処理はこのへんに書く
    }
}

int main() {
    ll n, q;
    cin >> n >> q;    

    G.resize(n);
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
    }

    ans.resize(n);
    rep(i, q) {
        ll p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }

    const ll root = 0;
    dfs(root);

    rep(v, n) {
        cout << ans[v] << " ";
    }
    
    cout << endl;
    re0;
}

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

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

  for (int tmp = 0; tmp < (1 << 3); tmp++) {
    bitset<3> bs(tmp);

    int sum = s.at(0) - '0';
    string formula = to_string(sum);
    for (int i = 0; i < (int)s.size() - 1; i++) {
      int n = s.at(i + 1) - '0';
      string sign;

      // 加算
      if (bs.test(i) == 1) {
        sum += n;
        sign = "+";
      // 減算
      } else {
        sum -= n;
        sign = "-";
      }
      formula += sign + to_string(n);
    }

    if (sum == 7) {
      cout << formula << "=7" << endl;
      return 0;
    }
  }

  return 0;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001000;

int main() {
    int n; cin >> n;
    rep(i,10) {
        rep(j,10) {
            if (i*j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  string O, E; cin >> O; cin >> E;
  if(O.size() >= E.size()) {
    for(int i = 0; i < O.size(); i++) {
      if(E[i]) cout << O[i] << E[i];
      else cout << O[i];
    }
  } else {
    for(int i = 0; i < E.size(); i++) {
      if(O[i]) cout << O[i] << E[i];
      else cout << E[i];
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,k;
  int num=1;
  scanf("%d %d",&n,&k);
  for(int i=0;i<n;i++){
    if(num*2<num+k){
      num*=2;
    }else{
      num+=k;
    }
  }
  printf("%d\n",num);
  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++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  rep(i,1000){
    c-=b;
    if(c<=0){
      cout << "Yes" << endl;
      return 0;
    }
    a-=d;
    if(a<=0){
      cout << "No" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3624