akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 100'000 + 6;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    i64 n;
    string s;
    cin >> n >> s;
    if (s.size() <= n) {
        cout << s << endl;
        return 0;
    }

    cout << s.substr(0, n) << "..." << endl;

    
    return 0;
}

Measured memory_bytes: 3656
N, K = map(int, input().split())
array = [0 for i in range(10 ** 5)]
for _ in range(N):
    a, b = map(int, input().split())
    array[a-1] += b

count = 0
for i, a in enumerate(array, 1):
    count += a
    if count >= K:
        print(i)
        break

Measured memory_bytes: 5900
# 押しだしながらDPする場合
N = int(input())
h = list(map(int, input().split()))
h.extend([0,0]) # 要らない足場
dp = [0] + [1e10]*(N+1) # 初期状態だけ定義(cost0)
for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1] - h[i]))
    dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2] - h[i]))
    
print(dp[N-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

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

    if (s.size() <= k)
        cout << s;
    else {
        rep(i, k) cout << s[i];
        cout << "...";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k,s=0,t;
	scanf("%d %d %d %d",&a,&b,&c,&k);
	s=a+b+c;
	for(int i=1;i<=k;i++)
	{
		int max=0;
		if(a>max)
		{
			max=a;
			t=1;
		}
		if(b>max)
		{
			max=b;
			t=2;
		}
		if(c>max)
		{
			max=c;
			t=3;
		}
		switch(t)
		{
			case 1:a*=2;
					s+=a/2;
					break;
			case 2:b*=2;
					s+=b/2;
					break;
			case 3:c*=2;
					s+=c/2;
					break;
		}
	}
	printf("%d",s);
	return 0;
}

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

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

void rectangle(int h, int w) {
	for (int i = 0; i < h; i++ ) {
		for (int i = 0; i < w; i++ ) {
			cout << "#";
		}
		cout << endl;
	}
	cout << endl;
}

int main() {
	while (1) {
		int H, W;
		cin >> H >> W;
		if (H == 0 and W == 0) {
			break;
		}
		rectangle(H, W);
	}
	return 0;
}



Measured memory_bytes: 3088
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
#define int            		long long
#define x              		first
#define y              		second
#define all(aaa)       		(aaa).begin(),(aaa).end()
#define REP(i,sss,eee) 		for(int i=sss;i<=eee;++i)
#define pb             		push_back
#define pii            		pair<int,int>
#define vi             		vector<int>
#define speed          		ios_base::sync_with_stdio(0);cin.tie(0);
#define N              		998244353
#define inf					1000000000000000000
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;//for multiset use less_equal above

inline int ex(int a, int b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	int tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
inline int inv(int k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
int solve()
{
	int n;cin>>n;
	int ans=ex(3,n);
	vi inp(n+1,0);
	int sum=0;
	REP(i,1,n){cin>>inp[i];sum+=inp[i];}
	std::vector<std::vector<int>> dp(n+1,std::vector<int>(sum+1,0));
	dp[0][0]=1;
	REP(i,1,n)
	{
		REP(red,0,sum)
		{
			int prev=red-inp[i];
			dp[i][red]=((dp[i-1][red]*2)+((prev>=0)?dp[i-1][prev]:0));
			dp[i][red]%=N;
		}
	}
	if(!(sum%2))
	{
		int st=sum/2;
		REP(i,st,sum)
		{
			ans-=(dp[n][i]*3);
			ans%=N;
		}
		std::vector<std::vector<int>> dp2(n+1,std::vector<int>(sum,0));
		dp2[0][0]=1;
		REP(i,1,n)
		{
			REP(red,0,sum)
			{
				int prev=red-inp[i];
				dp2[i][red]=(dp2[i-1][red]+((prev>=0)?dp2[i-1][prev]:0));
				dp2[i][red]%=N;
			}
		}
		ans+=(3*dp2[n][sum/2]);
		ans%=N;
	}
	else
	{
		int st=((sum/2)+1);
		REP(i,st,sum)
		{
			ans-=(dp[n][i]*3);
			ans%=N;
		}
	}
	ans+=N;ans%=N;
	cout<<ans<<"\n";
}
signed main(){
	speed
	int tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 423872
package main

import (
	"fmt"
	"io"
	"os"
)

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	var x, a int
	fmt.Fscanf(in, "%d%d", &x, &a)
	ans := 0
	if x >= a {
		ans = 10
	}
	fmt.Fprintln(out, ans)
}


Measured memory_bytes: 512
from collections import deque
n = int(input())
s = [input() for i in range(n)]
ans = -2
for k in range(n):
    q = deque([k])
    d = [float('inf')] * n
    d[k] = 0
    while q:
        flg = 0
        p = q.popleft()
        for i, c in enumerate(s[p]):
            if c == '1':
                if d[i] == float('inf'):
                    d[i] = d[p] + 1
                    q.append(i)
                elif d[i] != d[p] + 1 and d[i] != d[p] - 1:
                    flg = 1
                    break
        if flg:
            break
    if flg:
        continue
    for i in range(n):
        ans = max(ans, d[i])
print(ans + 1)


Measured memory_bytes: 44764
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, 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 true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ll n; cin >> n;
  vector<ll> v(n);
  rep(i, n)
    cin >> v.at(i);
  
  bool fin = false;
  ll ans = 0;
  
  rep(i, 30){
    
    rep(j, n){
      if(v.at(j)%2 == 1){
        fin = true;
        break;
      }
      else
        v.at(j) /= 2;
    }
    
    if(fin)
      break;
      
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
object Main {
  def SelectionSort(A: Array[Int]):(Int,Array[Int]) = {
    var count = 0
    def swap(i: Int, j: Int){
      if(i != j){
        count += 1
      }
      val tmp = A(i)
      A(i) = A(j)
      A(j) = tmp
    }

    for(i <- 0 to A.length - 1){
      var mini = i
      for(j <- i + 1 to A.length - 1){
        if (A(j) < A(mini)){
          mini = j
        }
      }
      swap(i,mini)
    }
    (count,A)
  }


  def main(args: Array[String]){
    val N = readLine().map(_.toInt)
    val input = readLine().split(" ").map(_.toInt).toArray
    val result = SelectionSort(input)
    println(result._2.mkString(" "))
    println(result._1)
  }
}

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

int main() {
	int H, W, N, a;
	cin >> H >> W >> N;
	int ans[110][110];
	int x = 0, y = 0, sayu = 1;
	for (int i = 0;i < N;i++) {
		cin >> a;
		while (a) {
			ans[y][x] = i + 1;
			x += sayu;
			if (x == -1) {
				x++; y++;
				sayu = 1;
			}
			if (x == W) {
				x--; y++;
				sayu = -1;
			}
			a--;
		}
	}
	for (int i = 0;i < H;i++) {
		for (int j = 0;j < W;j++) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

ll gcd(ll a, ll b) {
    if (a<b) swap(a, b);
    while(b!=0) {
        ll t = a;
        a = b;
        b = t%b;
    }
    return a;
}

ll lcm(ll a, ll b) { return a/gcd(a, b)*b; }

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

ll f(ll h) {
    if (h==0) return 0;
    return 1+2*f(h/2);
}

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

    ll h; cin >> h;
    cout << f(h) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long int ulli;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
/* TUMSE NAA HO PAAYEGA HAR DO DIN MAI LAGEGA
   LEKIN RUKNE KA NAHI :P */

int main() {
	// your code goes here
	FASTIO
	int n;
	cin >> n;
	int a[n][2];
	for(int i=0;i<n;i++){
	    cin >> a[i][0] >> a[i][1];
	}
	int flag=0;
	for(int i=0;i<=n-3;i++){
	    if(a[i][0]!=a[i][1]){
	        flag=1;
	        continue;
	    }
	    flag=0;
	    for(int j=i+1;j<i+3;j++){
	        if(a[j][0]!=a[j][1]){
	            flag=1;
	            break;
	        }
	    }
	    if(flag==0){
	        break;
	    }
	}
	if(flag){
	    cout << "No" << endl;
	} else {
	    cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 3628
#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(){
	char a;
	cin >> a;
	if(a-'a' < 0){
		cout << 'A' << endl;
	}else{
		cout << 'a' << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
k = int(input())

digit_len = 1

def df(num, depth):
    if len(str(num)) == depth:
        return [num]

    df_result = []
    tmp_num = int(str(num)[-1])
    tmp = [tmp_num]
    if tmp_num-1>=0:
        tmp.append(tmp_num-1)
    if tmp_num+1<10:
        tmp.append(tmp_num+1)
    for i in tmp:
        df_result.extend(df(int(str(num)+str(i)), depth))
    return df_result

num_list = []
while 1:
    tmp = []
    for i in range(1,10):
        tmp.extend(df(i, digit_len))
    num_list.extend(sorted(tmp))
    if len(num_list)>=k:
        break
    digit_len+=1

print(num_list[k-1])


Measured memory_bytes: 18892
#include <iostream>
#include <iomanip>

int main(){
   int N;
   std::cin >> N;
   double A;
   double ans = 0;
   for(int i=0; i<N; ++i){
      std::cin >> A;
      A = 1./A;
      ans += A;
   }

   ans = 1./ans;
   std::cout << std::setprecision(10) << ans << std::endl;
   return 0;
}


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

int main() {

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

    return 0;

}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,C = II()
D = []
for i in range(C):
    D.append(III())
c = []
for i in range(N):
    c.append(III())

d1 = []
d2 = []
d3 = []
for i in range(N):
    for j in range(N):
        if (i+j)%3==0:
            d1.append(c[i][j])
        elif (i+j)%3==1:
            d2.append(c[i][j])
        else:
            d3.append(c[i][j])

d1val = []
d2val = []
d3val = []

for cl in range(C):
    temp1 = 0
    temp2 = 0
    temp3 = 0
    for dcl in d1:
        temp1 += D[dcl-1][cl]
    for dcl in d2:
        temp2 += D[dcl-1][cl]
    for dcl in d3:
        temp3 += D[dcl-1][cl]
    d1val.append(temp1)
    d2val.append(temp2)
    d3val.append(temp3)

ans = float('inf')
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i==j or i==k or j==k:
                continue
            else:
                temp = d1val[i]+d2val[j]+d3val[k]
                if temp<ans:
                    ans = temp

print(ans)

Measured memory_bytes: 56924
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    string s, prv = "", cur = "";
    ll ans = 0;
    cin >> s;
    rep(i, s.size()){
        cur += s[i];
        if(cur != prv){
            prv = cur;
            cur = "";
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
n = int(input())
c0, c1, c2, c3 = 0, 0, 0, 0
for _ in range(n):
    s = input()
    if s == 'AC':
        c0 += 1
    elif s == 'WA':
        c1 += 1
    elif s == 'TLE':
        c2 += 1
    else:
        c3 += 1
print('AC x',c0)
print('WA x',c1)
print('TLE x',c2)
print('RE x',c3)

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

using namespace std;

const int N = 3e3 + 2;
const int OFF = N + 1;

int n;
double p[N];
double dp[N][N + OFF + 5];

void load() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;

    for(int i = 1; i <= n; ++i)
        cin >> p[i];
}

void solve() {
    dp[0][OFF] = 1;

    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= N + OFF; ++j) {
            dp[i][j - 1] += dp[i - 1][j] * (1 - p[i]);
            dp[i][j + 1] += dp[i - 1][j] * p[i];
        }
    }

    double sol = 0;
    for(int i = OFF; i <= N + OFF; ++i)
        sol += dp[n][i];

    cout << fixed << setprecision(10) << sol << endl;
}

int main() {
    load();
    solve();

    return 0;
}


Measured memory_bytes: 141056
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

static const unsigned long long int MOD = 1000000007LL;

int main()
{
    double w, h, x, y;
    cin >> w >> h >> x >> y;

    cout << w * h / 2 << " ";

    if (x == w / 2 && y == h / 2)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  int A[N]; rep(i,N) cin >> A[i];
  string result = "APPROVED";
  rep(i,N) {
    if (A[i]%2==0) {
      if (A[i]%3!=0&&A[i]%5!=0) result = "DENIED";
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    if (s == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
    return 0;
}


Measured memory_bytes: 3572
str = input()
cnt = 0
num = 0
for i in str:
    if cnt % 2 == 0:
        if i == '0':
            num += 1
    else:
        if i == '1':
            num += 1
    cnt += 1

cnt2 = 0
num2 = 0
for i in str:
    if cnt2 % 2 == 0:
        if i == '1':
            num2 += 1
    else:
        if i == '0':
            num2 += 1
    cnt2 += 1

print(min(num,num2))


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

int main()
{
    int c=0;
    double liu;
    int a[2000];
    int n,m,count=0;;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        count=count+a[i];
    }
    liu=count/(4.0*m);
    for(int i=0;i<n;i++){
        if(liu<=a[i]){
            c++;
        }
    }
    if(c>=m){
        cout<<"Yes";
    }else
    {
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n";
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;

int main(){
	migmig;
	int a,b;
	cin>>a>>b;
	if(a<=5){
		cout<<0;
		return 0;
	}else if(a<=12){
		cout<<b/2;
	}else cout<<b;
	return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	string s, ss,t;
	int cnt = 0;
	int ans = 1000000;
	cin >> s >> ss;
	rep(i, s.size() - ss.size() + 1) {
		t = s.substr(i, ss.size());
		cnt = 0;
		rep(j, ss.size()) {
			if (ss[j] != t[j])cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int Mod=1e9+7;
const int INF=0x3f3f3f3f;
//组合数 
const int __Mod=1e9+7;
int C[100000][2000];
void init(int n,int m){
	for(int i=0;i<=n;++i){
		C[i][0]=1;
		for(int j=1;j<=i && j<=m;++j){
			C[i][j]=(C[i-1][j]+C[i-1][j-1]) %__Mod;
		}
	}
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int s;
	cin>>s;
	int limit=s/3;
	init(s,limit);
	LL ans=0;
	for(int i=1;i<=limit;++i){
		ans=(ans+C[s-2*i-1][i-1]%Mod)%Mod;
	}
	cout<<ans<<endl;
	return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI a(n), b(n), c(n-1);
  rep(i,n) cin >> a[i];
  ll ans = 0;
  rep(i,n){
    cin >> b[i];
    ans += b[i];
  }
  rep(i,n-1) cin >> c[i];

  rep(i,n-1){
    if(a[i] == a[i+1] - 1){
      ans += c[a[i]-1];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace Watch{
	 class class1{
		 static void Main(){
			int S=int.Parse(Console.ReadLine());
			Console.Write("{0}:{1}:{2}\n",h(S),m(S),s(S));
		}

		 static int s(int S){return S%3600%60;}
		 static int m(int S){return S%3600/60;}
		 static int h(int S){return S/3600;}	
		
	}
}

Measured memory_bytes: 9172
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 1145141919
for _ in range(m):
    x, y, c = map(int, input().split())
    if ans > A[x - 1] + B[y - 1] - c:
        ans = A[x - 1] + B[y - 1] - c
if min(A) + min(B) < ans:
    ans = min(A) + min(B)
print(ans)

Measured memory_bytes: 18612
// #include <iostream>
// #include <vector>
// #include <queue> //priority queue
// #include <stack>
// #include <map> // multimap
// #include <set> //multiset
// #include <list> 
// #include <utility> // pair
// #include <iterator>
// #include <deque> // insertion as both ends
// #include <string>
// // g1=s.substr(0,n/2);
// // g2=s.substr(n/2+n%2,n/2);
// #include <cctype> //isaplha
// #include <iomanip>      // std::setprecision
// #include <algorithm> //binary_search,sort, next_permutation in lexicographically greater permutation, fill(it1,it2,val)
// #include <cmath>
// #include <limits.h> //INT_MIN,INT_MAX
// #include <numeric>  //iota,partial_sum,inner_product,accumulate(begin,end,num)
// #include <functional>  //Arithmetic, comparators, logical
// #include <bitset>
// #include <unordered_map>
// #include <unordered_set>
// #include <stdio.h> 
// #include <cstring>
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define pi 3.14159
#define ll long long 
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = s; 
    for (int i=1; i<n;i++) 
        s += s1;
    return s; 
}
string getString(char x) {
    string s(1, x); 
    return s;    
} 

void optimizeIO(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
}

vector<ll> primeFactors(ll n)  { 
    vector<ll> v;
    if(n%2==0) v.pb(2); 
    while (n % 2 == 0)  {  
        n = n/2;  
    }  
    for (ll i = 3; i <= sqrt(n); i = i + 2) {  
        if(n%i==0) v.pb(i);
        while (n % i == 0) {  
            n = n/i;  
        }  
    } 
    if (n > 2)  v.pb(n);
    return v;
}  
bool isPrime(ll n){
    if (n <= 1)  return false; 
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false; 
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; 
} 
int main(){
    optimizeIO();
    string x[7]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}   ;
    string s;
    cin>>s;
    rep(i,0,7){
        if(x[i]==s){
            cout<<7-i<<endl;
            break;
        }
    }
    
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;
const ll MAX = 26;

ll D;
ll C[30];
ll S[400][30];
ll T[400];
ll P[400];
set<ll> Last[30];
ll Damage[400][30];

ll calc(ll t, ll d, ll score) {
    score += S[d][t];
    REP(i, MAX) {
        if (t == i)
            continue;
        score -= C[i] * (d - *Last[i].rbegin());
    }
    return score;
}

ll changeCalc(ll d, ll q, ll score) {
    ll old = P[d];
    score += S[d][q] - S[d][old];

    auto oldIt = Last[old].lower_bound(d);
    auto newIt = Last[q].lower_bound(d);

    {
        oldIt--;
        ll p = *oldIt;
        oldIt++;
        oldIt++;
        ll n = D;
        if (oldIt != Last[old].end()) {
            n = *oldIt;
        }
        score += Damage[d - p - 1][old] + Damage[n - d - 1][old];
        score -= Damage[n - p - 1][old];
    }
    {
        ll n = D;
        if (newIt != Last[q].end()) {
            n = *newIt;
        }
        newIt--;
        ll p = *newIt;
        score += Damage[n - p - 1][q];
        score -= Damage[d - p - 1][q] + Damage[n - d - 1][q];
    }

    return score;
}

ll change(ll d, ll q, ll score) {
    score = changeCalc(d, q, score);
    ll old = P[d];
    {
        auto it = Last[old].lower_bound(d);
        Last[old].erase(it);
    }
    {
        Last[q].insert(d);
    }
    P[d] = q;
    return score;
}

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

    cin >> D;
    REP(i, MAX) {
        cin >> C[i];
    }
    REP(i, D) {
        REP(j, MAX) {
            cin >> S[i][j];
        }
    }
    REP(i, D) {
        T[i] = 0;
    }
    ll score = 0;
    REP(i, MAX) {
        Last[i].insert(-1);
    }
    REP(i, D) {
        score = calc(T[i], i, score);
        Last[T[i]].insert(i);
        P[i] = T[i];
    }

    memset(Damage, 0, sizeof(Damage));
    REP(i, MAX) {
        REP(j, D) {
            Damage[j + 1][i] = Damage[j][i] + C[i] * (j + 1);
        }
    }

    REP(i, D) {
        pll mx = pll(score, T[i]);
        REP(j, MAX) {
            ll s = changeCalc(i, j, score);
            if (s > mx.first)
                mx = pll(s, j);
        }
        score = change(i, mx.second, score);
        T[i] = mx.second;
    }

    REP(i, D) {
        cout << T[i] + 1 << endl;
    }

    return 0;
}

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

#define MAX 1000000
using namespace std;

int n;
int vet[MAX];

void getPrimos(){
    int limite = MAX;
    int raiz = sqrt(limite);

    for(int i=2;i<=raiz;i++){
        if(vet[i] == 0){
            for(int j = 2*i;j<=limite;j+=i){
                vet[j] = 1;
            }
        }
    }
}

int main(){
    getPrimos();
    scanf("%d",&n);
    while(1){
        if(vet[n] == 0){
            printf("%d\n",n);
            break;
        }else n++;
    }
}


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

int main() {
  char X;
  cin >> X;
  
  if (X == 'a') cout << "vowel" << endl;
  
  else if (X == 'e') cout << "vowel" << endl;

  else if (X == 'i') cout << "vowel" << endl;

  else if (X == 'o') cout << "vowel" << endl;
  
  else if (X == 'u') cout << "vowel" << endl;

  else cout << "consonant" << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#define LLMAX 9223372036854775807

using namespace std;
using ll = long long;

int main() {
	ll argN, argK;
	cin >> argN >> argK;

	ll counter = argK;
	for (ll i = 1; i < argN; ++i) {
		counter *= argK - 1;
	}

	cout << counter << endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
    int W,H,N,x,y,a;
    cin >> W >> H >> N;
    int right_black=W,left_black=0,high_black=H,low_black=0;
    for(int i=0;i<N;i++){
        cin >> x >> y >> a;

        if(a==1){left_black=max(left_black,x);}
        if(a==2){right_black=min(right_black,x);}
        if(a==3){low_black=max(low_black,y);}
        if(a==4){high_black=min(high_black,y);}
    }
    if((right_black-left_black)>=0 && (high_black-low_black)>=0){
        cout << (right_black-left_black)*(high_black-low_black) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
#include<numeric>
#include<utility>
#define INF (int)1e9
#define DINF (double)1e9
#define MOD 1000000007
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> p;



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];
		b[i] = a[i];
	}
	sort(a.begin(), a.end());
	int small = a[(n - 1) / 2];
	int big = a[(n + 1) / 2];
	for (int i = 0; i < n; i++) {
		if (b[i] <= small) {
			cout << big << endl;
		}
		else {
			cout << small << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	int h, w;
	int n, co = 0, co1 = 0, co2 = 0;
	bool bo = false;
	int a[10010];
	int c[100][100];
	cin >> h >> w >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (;;) {
		for (int j = 0; j < w; j++) {
			c[co2][j] = co1 + 1;
			co++;
			if (co == a[co1]) {
				if (co1 == n - 1) {
					bo = true;
					break;
				}
				co1++;
				co = 0;
			}
		}
		co2++;
		if (bo == true) {
			break;
		}
		for (int k = w - 1; k >= 0; k--) {
			c[co2][k] = co1 + 1;
			co++;
			if (co == a[co1]) {
				if (co1 == n - 1) {
					bo = true;
					break;
				}
				co1++;
				co = 0;
			}
		}
		if (bo == true) {
			break;
		}
		co2++;
	}
	for (int d = 0; d < h; d++) {
		for (int e = 0; e < w; e++) {
			cout << c[d][e];
			if (e != w - 1) {
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}
	

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <math.h>


using namespace std; 

bool allCharactersSame(string s) 
{ 
    int n = s.length();
    for (int i = 1; i < n; i++) 
        if (s[i] != s[0]) 
            return false; 
  
    return true; 
}

int main() { 
	string s;
    cin >> s;
    if(allCharactersSame(s) == true){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
	
	return 0;		
    
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  map<int,int> mp;
  REP(i, N){
    cin >> A[i];
    mp[A[i]]++;
  }
  
  int cnt = 0;
  for(auto x:mp){
    if(x.second%2==0){
      cnt++;
    }
    if(x.second%2==0&&x.second>=2){
      x.second=2;
    }else if(x.second%2==1&&x.second>=3){
      x.second=1;
    }
  }

  if(cnt%2==0){
    cout << mp.size() << endl;
  }else{
    cout << mp.size()-1 << endl;
  }
}

Measured memory_bytes: 5376
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        // Your code here!
        int a=0,b=0;
        int n=int.Parse(System.Console.ReadLine());
        int[] x=System.Console.ReadLine().Trim().Split(' ').Select(z=>int.Parse(z)).ToArray();
        Array.Sort(x);
        for(int i=0;i<n;i++){
            if(i%2==0) a+=x[n-1-i];
            else b+=x[n-1-i];
        }
        System.Console.WriteLine(a-b);
    }
}


Measured memory_bytes: 13396
n, s = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0] * (s + 1) for _ in range(n + 1)]

mod = 998244353
# dp[i][s] A[i]まで見た時、合計sになる数。
# 各々の地点で新しく開始されるものも有るので毎回dp[i][0]は＋1
dp[0][0] = 1
ans = 0
for i in range(n):
    ni = i + 1
    for j in range(s + 1):
        nj = j
        dp[ni][nj] += dp[i][j]
        dp[ni][nj] %= mod
        nj = j + A[i]
        if nj <= s:
            dp[ni][nj] += dp[i][j]
            dp[ni][nj] %= mod
    dp[ni][0] += 1
    ans += dp[ni][s]
    ans %= mod
print(ans)


Measured memory_bytes: 112988
#include <bits/stdc++.h>
using namespace std;
int n,m,q,a[50],b[50],c[50],d[50],o,p[10];
void u(int l,int f){
    if(l==n){
        int s=0;
        for(int i=0;i<q;i++)if(p[b[i]-1]-p[a[i]-1]==c[i])s+=d[i];
        o=max(o,s);
        return;
    }
    for(int i=f;i<=m;i++){
        p[l]=i;
        u(l+1,i);
    }
}
int main(){
    cin>>n>>m>>q;
    for(int i=0;i<q;i++)cin>>a[i]>>b[i]>>c[i]>>d[i];
    u(0,1);
    cout<<o;
}


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

using namespace std;

struct QueueItem
{
  uint64_t y, x, d;
  
  QueueItem(uint64_t y, uint64_t x, uint64_t d)
    : y(y), x(x), d(d) {}
};

int main()
{
  uint64_t H, W;
  cin >> H >> W;
  
  queue<QueueItem> q;
  
  vector<string> A(H);
  for (uint64_t h = 0; h < H; ++h) {
    cin >> A[h];
    
    for (uint64_t w = 0; w < W; ++w) {
      if (A[h][w] == '#') {
        q.emplace(h, w, 0);
      }
    }
  }
  
  vector<vector<uint64_t>> d(H);
  for (uint64_t h = 0; h < H; ++h) {
    d[h] = vector<uint64_t>(W, -1);
  }
  
  uint64_t max_d = 0;
  while (!q.empty()) {
    QueueItem item = q.front(); q.pop();
    
    if (d[item.y][item.x] <= item.d) {
      continue;
    }
    
    d[item.y][item.x] = item.d;
    max_d = max(max_d, item.d);
    
    int dy[4] = {+1, -1, 0, 0}, dx[4] = {0, 0, +1, -1};
    for (int dir = 0; dir < 4; ++dir) {
      uint64_t y = item.y + dy[dir], x = item.x + dx[dir];
      if ((y < H) && (x < W) && (d[y][x] > item.d + 1)) {
        q.emplace(y, x, item.d + 1);
      }
    }
  }
  cout << max_d << endl;
  
  return 0;
}

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

using namespace std;

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

	char chr = s[0];
	int a = 0;

	for (int i = 1; i < s.length(); i++) {
		if (chr != s[i]) {
			chr = s[i];
			a++;
		}
	}

	cout << a << endl;
}


Measured memory_bytes: 512
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

ll N, K;

void init()
{
}

void solve()
{
    ll ans = 0;
    FOR(b, K+1, N+1){
        ans += (b-K) * (N/b);
        ans += max(0ll, (N % b) - (K-1));
    }
    cout << (K > 0 ? ans : N*N) << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int a = sc.nextInt();
		int[] n = new int[a];
		int num = sc.nextInt();
		for (int i = 0; i < num; i++) {
			for (int j = sc.nextInt(); j > 0; j--) {
				n[sc.nextInt() - 1]++;
			}
		}
		int count = 0;
		for (int i : n) {
			count += i == 0 ? 1 : 0;
		}
		System.out.println(count);
	}

	static class FastScanner {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public String nextLine() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					return reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken("\n");
		}

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

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

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

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
	}
}

Measured memory_bytes: 33536
# coding: utf-8
# Your code here!

while True:
   m, f, r = map(int, input().split())
   if m == -1 and f == -1 and r == -1:
      break
   
   if m == -1 or f == -1 or m + f < 30:
      print("F")
   elif m + f >= 80:
      print("A")
   elif m + f >= 65 and m + f < 80:
      print("B")
   elif m + f >= 50 and m + f < 65:
      print("C")
   else:
      if r >= 50:
         print("C")
      else:
         print("D")


Measured memory_bytes: 5600
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <string>
#include <math.h>
#include<set>
#include<stdio.h>
#include <bitset>
#include<string.h>
#define ii int64_t
#define PI 3.14
#define lli long long int
#define li long int
#define deb(x) cout<<"\nhi"<<x<<"\n"
#define mod 1000000007
#define f(x,n) for(int x=0;x<n;++x)
#define ff(x,y,z) for(x=y;x<=z;++x)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// while(scanf("%d",&n)!=EOF)




using namespace std;
 

int main()
 
{
    fio
    ii n,W,i,j=0,x;
    cin>>n>>W;
    ii w[n+3],v[n+3],dp[n+3][W+2];
    memset(dp,0,sizeof(dp));
    
    for(i=1;i<=n;i++)cin>>w[i]>>v[i];
    
    for(i=1;i<=n;++i)
    {
        for(x=0;x<w[i];++x)dp[i][x]=dp[i-1][x];
        for(x=w[i];x<=W;++x)
        {
            dp[i][x]=max(dp[i-1][x],dp[i-1][x-w[i]]+v[i]);
            //cout<<i<<" "<<x<<" "<<dp[i][x]<<endl;
        }
        //cout<<endl;
    }
    for(i=0;i<=W;++i)if(dp[n][i]>j)j=dp[n][i];
    cout<<j;
    
    
}





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

long long cnt;
vector<int> G; 

void insertionSort(int a[], int n, int g) {
    for (int i = g; i < n; i++) {
        int v = a[i];
        int j = i - g;
        while (j >= 0 && a[j] > v) {
            a[j + g] = a[j];
            j -= g;
            cnt++;
        }
        a[j + g] = v;
    }
}

void shellSort(int a[], int n) {
    for (int h = 1;;) {
        if (h > n) {
            break;
        }
        G.push_back(h);
        h = 3 * h + 1;
    }

    for (int i = G.size() - 1; i >= 0; i--) {
        insertionSort(a, n, G[i]);
    }
}

int main() {
    int a[1000000];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    cnt = 0;

    shellSort(a, n);

    cout << G.size() << endl;
    for (int i = G.size() - 1; i >= 0; i--) {
        cout << G[i];
        if (i > 0) {
            cout << " ";
        }
    }
    cout << endl;
    cout << cnt << endl;
    for (int i = 0; i < n; i++) {
        cout << a[i] << endl;
    }
}



Measured memory_bytes: 6952
#include<iostream>
using namespace std;
int main(int W,int H,int x,int y,int r){
    cin >> W >> H >> x >> y >> r;
    if (x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n,m;cin>>n>>m;
  vector<int> x(n+1,-inf);
  vector<int> y(m+1,-inf);
  rep1(i,n)cin>>x[i];
  rep1(i,m)cin>>y[i];
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  vector<int> sumx(n+1,0);
  vector<int> sumy(m+1,0);
  rep(i,n){
    sumx[i+1]=sumx[i]+i*(x[i+1]-x[i]);
    sumx[i+1]%=MOD;
  }
  rep(i,m){
    sumy[i+1]=sumy[i]+i*(y[i+1]-y[i]);
    sumy[i+1]%=MOD;
  }
  int SX=0;
  int SY=0;
  rep1(i,n){
    SX+=sumx[i];
    SX%=MOD;
  }
  rep1(i,m){
    SY+=sumy[i];
    SY%=MOD;
  }
  cout<<SX*SY%MOD<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
void f(int i,vector<vector<int>> &g,vector<int> &c,vector<int> &qu,vector<int> &ch){
  c.at(i-1)+=qu.at(i-1);
  ch.at(i-1)=1;
  for(auto j:g.at(i-1)){
    if(ch.at(j-1)==0){
      qu.at(j-1)+=qu.at(i-1);
      f(j,g,c,qu,ch);
    }
  }
}
int main() {
  int n,q,a,b,p,x,i;
  cin>>n>>q;
  vector<vector<int>> g(n,vector<int>(0));
  vector<int> c(n),qu(n),ch(n);
  for(i=0;i<n-1;i++){
    cin>>a>>b;
    g.at(a-1).push_back(b);
    g.at(b-1).push_back(a);
  }
  for(i=0;i<q;i++){
    cin>>p>>x;
    qu.at(p-1)+=x;
  }
  f(1,g,c,qu,ch);
  for(i=0;i<n;i++){
    cout<<c.at(i);
    if(i<n-1) cout<<' ';
    else cout<<endl;
  }
}

Measured memory_bytes: 34432
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
la = {k:v for k,v in Counter(a).items()}
ans = 0
for k,v in la.items():
    if k != v:
        if k < v:
            ans += abs(k-v)
        else:
            ans += v
print(ans)


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

using namespace std;


    


int main() {
    int N;
    cin >> N;
    string str;
    str=to_string(N);
    int cnt=1, tmp=str[0];
    for(int i=1; i<4; i++){
        if(str[i]==tmp){
            cnt+=1;
        }
        else if(cnt>=3){
            break;
        }
        else{
            tmp=str[i];
            cnt=1;
            
            
        }
    }
        if(cnt>=3){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
}
        

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c&&c==a)cout<<"No\n";
    else if(a!=b&&b!=c&&c!=a)cout<<"No\n";
    else cout<<"Yes\n";

    return 0;
}

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

const int dh[4] = {0,1,0,-1};
const int dw[4] = {1,0,-1,0};

int main(void){
    int H,W;
    cin >> H >> W;
    bool allblack = true;
    vector<string> field(H);
    queue<pair<int,int>> q;
    for(int i=0;i<H;i++){
        cin >> field[i];
        for(int j=0;j<W;j++){
            if(field[i][j]=='#')  q.push(make_pair(i,j));
        }
    }

    vector<vector<bool>> seen(H, vector<bool>(W, false));
    int count=-1;
    while(!q.empty()){
        vector<pair<int,int>> todo;
        while(!q.empty()){
            todo.push_back(q.front());
            q.pop();
        }
        for(auto pos : todo){
            int h = pos.first, w = pos.second;
            for(int k = 0; k < 4; k++){
                int nh = h + dh[k], nw = w + dw[k];
                if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
                if (field[nh][nw] == '#') continue;
                field[nh][nw] = '#';
                q.push(make_pair(nh, nw));
            }
            
        }
        /*
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout << field[i][j];
            }
            cout << endl;
        }
        */
        count++;
    }
    cout << count << endl;


    /*時間超過
    int count = 0;
    while(!allblack){
        vector<pair<int,int>> shapepos;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(field[i][j]=='#') shapepos.push_back(make_pair(i,j));
            }
        }
        for(auto p: shapepos){
            int h = p.first, w = p.second;
            for(int k=0;k<4;k++){
                int nh = h+dh[k], nw = w+dw[k];
                if(nh<0||nh>=H||nw<0||nw>=W) continue;
                field[nh][nw] = '#';
            }
        }
        
        bool ok = true;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(field[i][j]=='.') ok = false;
            }
        }
        if(ok) allblack = true;

        count++;
    }
    

    cout << count << endl;
    */
}

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

int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i += 2){
    int cnt = 0;
    for(int j = 1; j <= i; j += 2){
      if(i%j == 0) cnt++;
      if(cnt == 8) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
  	int a[3];
  	cin >> a[0] >> a[1] >> a[2];
  	cout << *min_element(a,a+3) << " " << *max_element(a,a+3) << endl;
	return 0;
}


Measured memory_bytes: 3104
package main

import "fmt"

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

	var cnt int
	for i := a; i <= b; i++ {
		d := digits(i)
		if d[0] == d[4] && d[1] == d[3] {
			cnt++
		}
	}

	fmt.Println(cnt)
}

func digits(n int) []int {
	var res []int
	for n > 0 {
		res = append(res, n%10)
		n /= 10
	}
	return res
}


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

int main() {
  long long int n, k;
  cin >> n >> k;
  if(n >= k) {
  	long long int sho = n / k;
    n = n - sho * k;
  }
  
  if(n > k - n) n = k - n;
  
  cout << n << endl;
  
  
  return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n + 1];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		long inf = 1000000000000000L;
		long[] max = new long[n + 1];
		max[0] = 1 - a[0];
		if (max[0] < 0) {
			System.out.println(-1);
			return;
		}
		for (int i = 1; i <= n; i++) {
			max[i] = max[i - 1] * 2 - a[i];
			if (max[i] < 0) {
				System.out.println(-1);
				return;
			}
			if (max[i] >= inf) {
				for (int j = i; j <= n; j++) {
					max[j] = inf;
				}
				break;
			}
		}

		long ans = 0;
		long sum = 0;
		for (int i = n; i >= 0; i--) {
			sum = Math.min(sum, max[i]);
			ans += a[i] + sum;
			sum += a[i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 59160