akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,W;
    cin>>n>>W;
    long long int val[n+1];
    long long int wt[n+1];
    for(long long int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    
	long long int i, w; 
	long long int dp[n + 1][W + 1]; 

	for (i = 0; i <= n; i++) { 
		for (w = 0; w <= W; w++) { 
			if (i == 0 || w == 0) 
				dp[i][w] = 0; 
			else if (wt[i - 1] <= w) 
				dp[i][w] = max( 
					val[i - 1] + dp[i - 1][w - wt[i - 1]], 
					dp[i - 1][w]); 
			else
				dp[i][w] = dp[i - 1][w]; 
		} 
	} 

	cout<<dp[n][W]<<endl;
    return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	cin>>s;
	if(s=="Sunny"){
		cout << "Cloudy";
	}
	else if(s=="Cloudy"){
		cout << "Rainy";
	}
	else{
		cout << "Sunny";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, M;
int k[11];
int p[11];
int s[11][11];
int ison[11];
int cnt = 0;

void solve(int i) {
    if(i < N) {
        ison[i+1] = 1;
        solve(i+1);

        ison[i+1] = 0;
        solve(i+1);
        return;
    }else {
        for(int j = 0; j < M; ++j) {
            int oncnt = 0;
            for(int m = 0; m < k[j]; ++m) {
                if(ison[s[j][m]] == 1) {
                    oncnt++;
                }
            }
            if(oncnt % 2 != p[j]) {
                return;
            }
        }
        cnt++;
    }
}

int main() {
    cin >> N >> M;
    for(int i = 0; i < M; ++i) {
        cin >> k[i];
        for(int j = 0; j < k[i]; ++j) {
            cin >> s[i][j];
        }
    }

    for(int i = 0; i < M; ++i) {
        cin >> p[i];
    }

    solve(0);

    cout << cnt << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		float r = sc.nextFloat();
		int a=22;
		int b=7;
		float circum = (float)2*a*r/b;
		sb.append(circum);
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 37340
#include <iostream>
#include <string>

int main(){

    std::string s;
    std::string t;
    std::string condition = "Yes";

    std::cin >> s;
    std::cin >> t;

    while (condition == "Yes"){
        if(s.size() + 1 != t.size()){
            condition = "No";
        }
        else if(s.size() + 1 == t.size()){
            for(int i = 0; i < s.size(); i++){
                if(s[i] != t[i]){
                    condition = "No";
                }
            }
        }
        break;
    }

    std::cout << condition << std::endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int m = n;
  int s = 0;
  while ( m > 0 ){
    s += m%10;
    m = m/10;
  }
  if ( n%s == 0 ){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
n, h, d = map(int, input().split())
MOD = 10 ** 9 + 7

fact, fact_acc = 1, 1
for i in range(2, n + 1):
    fact = fact * i % MOD
    fact_acc = (fact_acc + fact) % MOD

dp = [0] * (h + 1)
dp[0] = base = fact
for i in range(1, h):
    dp[i] = base * fact_acc % MOD
    base = (base + dp[i]) % MOD
    if i >= d:
        base = (base - dp[i - d]) % MOD
print(base)


Measured memory_bytes: 42588
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    R = I()

    if R < 1200:
        print('ABC')
    elif 1200 <= R < 2800:
        print('ARC')
    else:
        print('AGC')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9984
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
		if(b&1)
		    r=(r*a)%m;
		b>>1;
		a=(a*a)%m;
	}
	return r%m;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	string s; cin>>s;
	ll n = s.size();
	bool flag = false;
	for(ll i =0;i<n-1;i++)
    {
        if(s[i]!=s[i+1])flag = true;
    }
    if(flag)cout<<"Yes\n";
    else cout<<"No\n";
	return 0;
}


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

#define llint long long int

using namespace std;

int main()
{
    int N, K;

    cin >> N >> K;

    vector<int> A(N + 1);

    for (int i = 1; i <= N; i++)
    {
        cin >> A[i];
    }
    for (int i = K + 1; i <= N; i++)
    {
        if (A[i - K] < A[i])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 3968
n=gets.chomp.to_i;
a=gets.chomp.split(" ").map(&:to_i);
b=gets.chomp.split(" ").map(&:to_i);

sum_a = 0
sum_b = 0
for i in 0..n-1
  sum_a = sum_a + a[i]
  sum_b = sum_b + b[i]
end

if sum_a < sum_b
  p -1
else
  count = 0
  odds = 0
  list = []
  for i in 0..n-1
    if a[i] < b[i]
      count = count + 1
      odds = odds + (b[i]-a[i])
    else
      list.push(a[i]-b[i])
    end
  end
  if count == 0
    p 0
  else
    list = list.sort.reverse
    len = list.length
    sum = 0
    i = 0
    while sum < odds && i < len
      sum = sum + list[i]
      count = count + 1
      i = i+1
    end
    p count
  end
end

Measured memory_bytes: 18448
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 50;
const int MAXD = 12;

int n;
int d[MAXN];

int cnt[MAXD + 1];
int opt[MAXD], nopt;
int cur[MAXN], ncur;
int solve() {
	REPE(i, MAXD) cnt[i] = 0; REP(i, n) ++cnt[d[i]];
	REPE(i, MAXD) if (cnt[i] >= (i == 0 ? 1 : i == MAXD ? 2 : 3)) return 0;
	nopt = 0; FORE(i, 1, MAXD - 1) if (cnt[i] == 1) opt[nopt++] = i;
	int ret = 0;
	REP(mask, 1 << nopt) {
		ncur = 0;
		cur[ncur++] = 0;
		FORE(i, 1, MAXD - 1) if (cnt[i] == 2) cur[ncur++] = i, cur[ncur++] = 2 * MAXD - i;
		REP(i, nopt)  cur[ncur++] = (mask&(1 << i)) == 0 ? opt[i] : 2 * MAXD - opt[i];
		if (cnt[MAXD] == 1) cur[ncur++] = MAXD;
		assert(ncur == n + 1); sort(cur, cur + ncur);
		int curval = INT_MAX; REP(i, ncur) curval = min(curval, (cur[(i + 1) % ncur] - cur[i] + 2 * MAXD) % (2 * MAXD));
		//printf("%x:", mask); REP(i, n) printf(" %d", cur[i]); printf(" -> %d\n", curval);
		if (curval > ret) ret = curval;
	}
	return ret;
}

void run() {
	scanf("%d", &n); REP(i, n) scanf("%d", &d[i]);

	printf("%d\n", solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 256
def main():
  from collections import deque
  N = int(input())
  ab = [list(map(int,input().split())) for _ in range(N-1)]
  mod = 10**9+7
  fact = [1]*(N+1)
  fact_inv = [1]*(N+1)
  for i in range(1,N+1):
    fact[i] = (fact[i-1]*i)%mod

  fact_inv[-1] = pow(fact[-1], mod-2, mod)
  for i in range(N,0,-1):
    fact_inv[i-1] = fact_inv[i] * i % mod

  g = [deque([]) for _ in range(N+1)]
  for a,b in ab:
    g[a].append(b)
    g[b].append(a)

  parents = [0]*(N+1)
  q = deque([])
  s = deque([1])
  while s:
    x = s.pop()
    q.append(x)
    for y in g[x]:
      if y==parents[x]:
        continue
      else:
        parents[y] = x
        s.append(y)

  q = list(q)
  size_forward = [0]*(N+1)
  dp_forward = [1]*(N+1)
  for i in q[::-1]:
    p = parents[i]
    s = size_forward[i] + 1
    size_forward[p] += s
    dp_forward[i] *= fact[size_forward[i]]
    dp_forward[p] *= dp_forward[i] * fact_inv[s]
    dp_forward[p] %= mod

  size_back = [N-1-i for i in size_forward]
  dp_back = [1]*(N+1)
  for i in q[1:]:
    p = parents[i]
    x = dp_back[p]
    x *= fact_inv[size_back[p]]
    x *= dp_forward[p]
    x *= fact_inv[size_forward[p]]
    x *= fact[size_forward[i]+1]
    x *= pow(dp_forward[i],mod-2,mod)
    x *= fact[size_back[i]-1]
    dp_back[i] = x % mod

  for a,b,c,d in zip(size_forward[1:], dp_forward[1:], size_back[1:], dp_back[1:]):
    ans = b * d * fact[a+c] * fact_inv[a] * fact_inv[c]
    ans %= mod
    print(ans)
    
main()

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

#define PI 3.1415926535
#define X real()
#define Y imag()

typedef complex<double> point;
typedef point vec;

vec rotate(vec v, double r) {
	return v*vec(cos(r), sin(r));
}

void f(int n,point p,point q){
	if(n--==0){
		cout<<setprecision(6)<<fixed<<p.X<<" "<<p.Y<<endl;
		return;
	}
	vec v=(q-p)/(point)3;
	point r=p+v;
	point s=r+rotate(v,PI/3);
	point t=q-v;
	f(n,p,r);
	f(n,r,s);
	f(n,s,t);
	f(n,t,q);
	return;
}

int main(){
	int n;
	cin>>n;
	f(n,(point)0,(point)(100));
	cout<<100<<" "<<0<<endl;
}



Measured memory_bytes: 3296
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
int solve()
{
	int n,m;
	cin>>n>>m;
	int a[n+1]={0};
	int pen[n+1]={0};
	for(int i=0;i<m;i++)
	{
		int x;
		string y;
		cin>>x>>y;
		if(y=="WA" && a[x]==0)
			pen[x]++;
		if(y=="AC" && a[x]==0)
		{
			a[x]=1;
		}
	}
	int corr=0,wr=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i])
			corr++, wr+=pen[i];
	}
	cout<<corr<<" "<<wr<<endl;
	



}
signed main()
{
	fastio;
	clock_t start, end;
//	test
	{
		start=clock();
		solve();
		end=clock();
		double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
//		cout<<time_taken<<endl;
	}
}


Measured memory_bytes: 1792
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
def insertion_sort(a)
  puts a.join(" ")
  n = a.size
  1.upto(n - 1) do |j|
    temp = a[j]
    i = j
    while i > 0 && a[i - 1] > temp
      a[i] = a[i - 1]
      i -= 1
    end
    if a[i] != temp
      a[i] = temp
      puts a.join(" ")
    else
      puts a.join(" ")
    end
  end
end

insertion_sort a



Measured memory_bytes: 6896
import java.util.*;
import java.io.*;

public class Main {
    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

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

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

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

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

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

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int cnt = 0;
        char[] c = sc.next().toCharArray();
        for(int i = 0; i < c.length; ++i){
            if(c[i]=='2'){
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 32660
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pt;

#define fi first
#define se second
#define lson (p<<1)+1
#define rson (p<<1)+2
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll n, m;
ld r[607], mx, ans;
vector<ll> g[607];

ld dfs(li v) {
    if(r[v] > -1) return(r[v]);
    r[v] = 0;
    if(!g[v].size()) return(0);
    for(auto i : g[v]) r[v] += dfs(i);
    r[v] = r[v] / g[v].size() + ld(1);

    return(r[v]);
}

int main () {
    fastIO
    cin >> n >> m;
    for(li i = 0, u, v; i < m; i ++) {
        cin >> u >> v;
        g[--u].push_back(--v);
    }

    for(li i = 0; i < n; i ++) r[i] = -1;
    dfs(0);
    ans = r[0];

    for(li i = 0; i < n - 1; i ++) {
        if(g[i].size() < 2) continue;
        for(li i = 0; i < n; i ++) r[i] = -1;
        dfs(i);
        r[i] = 0;
        mx = 0;
        for(li j = 0; j < g[i].size(); j ++) {
            r[i] += r[g[i][j]];
            if(r[g[i][j]] > mx) mx = r[g[i][j]];
        }
        r[i] = (r[i] - mx) / (g[i].size() - 1) + 1;
        dfs(0);

        ans = min(ans, r[0]);
    }

    cout << fixed << setprecision(9) << ans;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
template<class G>
class fenwick_tree{
	vector<G> a;
public:
	fenwick_tree(int n):a(n){}
	void add(int i,G val){
		for(i++;i<=a.size();i+=i&-i) a[i-1]+=val;
	}
	G sum(int l,int r)const{
		if(l==0){
			G res{};
			for(;r>0;r-=r&-r) res+=a[r-1];
			return res;
		}
		return sum(0,r)-sum(0,l);
	}
	int lower_bound(G val)const{
		if(val<=G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<val) val-=a[x+k-1], x+=k;
		return x;
	}
	int upper_bound(G val)const{
		if(val<G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<=val) val-=a[x+k-1], x+=k;
		return x;
	}
};
int main(){
	int n;
	string s;
  cin>>n>>s;
	vector<fenwick_tree<int>>F(26,fenwick_tree<int>(n));
	for(int i=0;i<n;i++)F[s[i]-'a'].add(i,1);
	int q;scanf("%d",&q);
	while(q--){
		int type,a;
    scanf("%d%d",&type,&a);
    a--;
		if(type==1){
      char before=s[a];
			char after;
      scanf(" %c",&after);
			s[a]=after;
			F[before-'a'].add(a,-1);
			F[after-'a'].add(a,1);
		}
		else{
			int b;
      scanf("%d",&b);
			int ans=0;
			for(int c=0;c<26;c++)if(F[c].sum(a,b)>0)ans++;
			printf("%d\n",ans);
		}
	}
	return 0;
}


Measured memory_bytes: 53636
#include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
    	int h,w,k,res=0;
    	cin>>h>>w>>k;
    	vector<vector<char> > v(h,vector<char>(w));
    	for(int i=0;i<h;i++)
    	{
    		for(int j=0;j<w;j++)
    		cin>>v[i][j];
    	}
    	for(int maskR=0;maskR<=(1<<h)-1;maskR++)
    	{
    		for(int maskC=0;maskC<=(1<<w)-1;maskC++)
    		{
    			int black=0;
    			for(int i=0;i<h;i++)
    			{
    				for(int j=0;j<w;j++)
    				if((maskR&(1<<i))==0&&(maskC&(1<<j))==0&&v[i][j]=='#') black++;
    			}
    			if(black==k) res++;
    		}
    	}
    	cout<<res<<endl;
    	return 0;
    }

Measured memory_bytes: 3588
import java.util.*;
 
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    long a = sc.nextInt();
    long b = sc.nextInt();
    
    long low;
    long high;
    
    if (a<b) {
      low = a;
      high = b;
    }
    else {
      low = b;
      high = a;
    }
    
    long highMultipler = high;
    long count = 2;
    while ((highMultipler%low)!=0) {
      highMultipler = high * count;
      count++;
    }
    
    System.out.println(highMultipler);
        
  }
}

Measured memory_bytes: 23380
n,m = map(int, input().split())

# 約数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

div_max = m//n + 1
divs = sorted(make_divisors(m))
from bisect import bisect_left

ind = bisect_left(divs, div_max)
print(divs[ind-1])

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n;
    cin>>n;
    vl ps(n);
    cin>>ps;
    vl cnt(n, 0);
    rep(i, n) {
        ll p = ps[i] - 1;
        if (p - 1 >= 0) cnt[p] = cnt[p - 1] + 1;
        else cnt[p] = 1;
    }
    ll m = 0;
    rep(i, n) chmax(m, cnt[i]);
    cout<<n - m<<endl;
}

Measured memory_bytes: 3456
// SeeAlso: https://atcoder.jp/contests/abc055/tasks/abc055_a

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 50
#define NIL -1

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int N;

int main() {
    cin >> N;
    int ans;
    ans = N * 800 - 200*(N/15);
    print(ans);    
    return 0;
}


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

int main(){
    int n,q;
    cin >> n;
    cin >> q;
    //vector<int> tm[n];
    //vector<string> name[n];
    int tm[100000];
    string name[100000];
    int total = 0;//??????????????¨
    for(int i=0;i<n;i++){
        cin >> name[i];
        cin >> tm[i];
        total += tm[i];
    }
    int ptm=0;//passed time
    while(1){
        for(int i=0;i<n;i++){
            if(tm[i]==0){
                
            }
            else if(tm[i]<=q){
                ptm += tm[i];
                tm[i] = 0;
                cout << name[i] << " " << ptm << endl;
                if(total==ptm)return 0;
            }else{
                ptm += q;
                tm[i] -= q;
            }
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 6472
#include <bits/stdc++.h>
 
#define ll long long
#define ull unsigned ll
#define vi vector<ll>
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define ld long double
#define pii pair<ll, ll>
#define mt make_tuple
#define mn(a, b) a = min(a, b)
#define mx(a, b) a = max(a, b)
 
using namespace std;
 
const ll INF = (ll)2e9;
const ll inf = (ll)2e18;
const ld eps = (ld)1e-8;
const ll mod = (ll)998244353;
const ll MAXN = (ll)4e5 + 1;
const ll MAXC = (ll)1e6 + 1;
const ll MAXE = (ll)1000;
const ll MAXLOG = 21;
const ll maxlen = (ll)1e5;
const ll asci = (ll)256;
const ll block = 480;
const ld PI = acos(-1);
const ld e = 2.7182818284;
 
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<
pii,
null_type,
less<pii>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
 
template <class T>
istream& operator >>(istream &in, vector<T> &arr){
    for (T &cnt : arr) {
        in >> cnt;
    }
    return in;
};

struct num{
    int x = -1, i = -1;
    num(int x, int i): x(x), i(i) {}
    num() {}
};

struct mxs{
    num f, s;
    mxs(num f, num s): f(f), s(s) {}
    mxs() {}
};

mxs merge(mxs a, mxs b) {
    if (a.f.x > b.f.x) {
        if (a.s.x > b.f.x) return a;
        else return mxs(a.f, b.f);
    } else if (b.f.x > a.f.x) {
        if (b.s.x > a.f.x) return b;
        else return mxs(b.f, a.f);
    } else if (b.f.i == a.f.i) {
        if (a.s.x > b.s.x) return a;
        else return b;
    } else {
        return mxs(a.f, b.f);
    }
}

void solve() {
    int n; cin >> n;
    vi a(1 << n); cin >> a;
    vector<mxs> dp(1 << n);
    for (int i = 0; i < 1 << n; ++i) {
        dp[i] = mxs(num(a[i], i), num());
    }
    for (int i = 1; i < 1 << n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (1 << j & i) dp[i] = merge(dp[i], dp[1 << j ^ i]);
        }
    }
    int ans = 0;
    for (int i = 1; i < 1 << n; ++i) {
        ans = max(dp[i].f.x + dp[i].s.x, ans);
        cout << ans << "\n";
    }
}

int main() {
    srand(time(0));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#endif
    cout.precision(30);
    solve();
 
    return 0;
}

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

typedef pair<int,int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define mkt make_tuple
#define all(x) x.begin(), x.end()

int n;
const int MAXS = 5e5;
int fen[MAXS + 3];
int a[MAXS + 3];
queue<int> elems[MAXS + 3];
vii queries[MAXS + 3];

void update(int pos, int delta){
    while(pos <= n){
        fen[pos] += delta;
        pos += pos & (-pos);
    }
}

int query(int pos){
    int answer = 0;
    while(pos){
        answer += fen[pos];
        pos -= pos & (-pos);
    }
    return answer;
}

int main(){
	ios::sync_with_stdio(false), cin.tie(nullptr);
    cin>>n;
    int q; cin>>q;
    vii arq;
    bool vis[n+2] = {};
    for (int i=1; i<=n; i++){
        cin>>a[i];
        elems[a[i]].push(i);
        if (!vis[a[i]]){
            update(i, 1);
            vis[a[i]] = 1;
        }
    }
    for (int i=0; i<q; i++){
        int l,r; cin>>l>>r;
        queries[l].pb(ii(i, r));
    }
    
    vii ans;
    for (int i=1; i<=n; i++){
        //first answer all, then update:
        for (int j=0; j<queries[i].size(); ++j){
            int r = queries[i][j].second;
            int index = queries[i][j].first;
            int cans = query(r);
            ans.pb(ii(index, cans));
        }
        queries[i].clear();
        int el = a[i];
        int pos = elems[el].front();
        elems[el].pop();
        update(pos, -1);
        if (!elems[el].empty()) update(elems[el].front(), 1);
    }
    sort(all(ans));
    for (int i=0; i<q; i++){
        cout<<ans[i].second<<'\n';
    }
    
	return 0;
}
/*
NARCO
*/


Measured memory_bytes: 371252
#define ll long long
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

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

	ll n,x;
	cin >> n >> x;
	vector<ll> a(n+1,0);//要素n+1を0で初期化
	rep(i,n) cin >> a[i];

	ll count = 0;
	if(a[0]>x){
		count +=a[0]-x;
		a[0] = x;
	}
	rep(i,n-1){
		ll wa = 0;
		wa += a[i] + a[i+1];
		if(wa <= x) continue;
		else if(wa > x){
			a[i+1] -= (wa - x);
			count+= (wa-x);
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll x,y;
    cin>>x>>y;
    if(x==2 || y==2)
    {
        cout<<"No"<<endl;
        return 0;
    }
    vector<ll>a{1,3,5,7,8,10,12};
    vector<ll>b{4,6,9,11};
    if(binary_search(a.begin(),a.end(),x)==1)
    {
        if(binary_search(a.begin(),a.end(),y)==1)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        else
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    else
    {
        if(binary_search(b.begin(),b.end(),y)==1)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        else
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import numpy
import itertools

N = int(input())
A = [int(i) for i in input().split()]

per = itertools.product([-1,0,1], repeat=N)
ans = 0
for p in per:
  combined = numpy.array([x - y for (x,y) in zip(A,p)])
  product = numpy.prod(combined)
  if product % 2 == 0:
    ans += 1
print(ans)

Measured memory_bytes: 14440
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);
int compress(int *x1, int *x2, int w, int n) {
	vector<int>xs;
	for (int i = 0; i < n; i++) {
		for (int d = -1; d <= 1; d++) {
			if (x1[i] + d >= 0 && x1[i] + d < w)xs.push_back(x1[i] + d);
			if (x2[i] + d >= 0 && x2[i] + d < w)xs.push_back(x2[i] + d);
		}
	}
	sort(ALL(xs));
	UNIQ(xs);
	for (int i = 0; i < n; i++) {
		x1[i] = lower_bound(ALL(xs), x1[i]) - xs.begin();
		x2[i] = lower_bound(ALL(xs), x2[i]) - xs.begin();
	}
	return xs.size();
}


int main() {
	int H, W, N;
	while (cin >> W >> H >> N) {
		int x1[1000], x2[1000], y1[1000], y2[1000];
		for (int i = 0; i < N; i++) {
			cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
		}

		W = compress(x1, x2, W, N);
		H = compress(y1, y2, H, N);
		short int **maze = new short int*[H + 1];
		for (int i = 0; i < H + 1; i++) {
			maze[i] = new short int[W + 1];
			for (int j = 0; j < W + 1; j++)maze[i][j] = 0;
		}

		for (int i = 0; i < N; i++) {
			maze[y1[i]][x1[i]]++;
			maze[y1[i]][x2[i]]--;
			maze[y2[i]][x1[i]]--;
			maze[y2[i]][x2[i]]++;
		}
		for (int i = 0; i <= H; i++) {
			for (int j = 0; j <= W; j++) {
				maze[i][j] += (i > 0 ? maze[i - 1][j] : 0) + (j > 0 ? maze[i][j - 1] : 0) - (i > 0 && j > 0 ? maze[i - 1][j - 1] : 0);
			}
		}

		LL ans = 0;
		for (int y = 0; y < H; y++) {
			for (int x = 0; x < W; x++) {
				if (maze[y][x])continue;
				ans++;
				queue<pair<int, int> >Q;
				Q.push(mp(y, x));
				maze[y][x] = true;
				while (!Q.empty()) {
					int sy = Q.front().first, sx = Q.front().second;
					Q.pop();
					for (int i = 0; i < 4; i++) {
						int ty = sy + dy[i], tx = sx + dx[i];
						if (ty < 0 || ty >= H || tx < 0 || tx >= W)continue;
						if (maze[ty][tx] >= 1)continue;
						Q.push(mp(ty, tx));
						maze[ty][tx] = true;
					}

				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 11052
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c;
int i[1000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>a;
  if(a<=11){
      if(a>6) cout <<2<<'\n';
      else cout <<1<<'\n';
  }else{
      if(a%11>6) cout <<a/11*2+2<<'\n';
      else{
	  if(a%11==0) cout <<a/11*2<<'\n';
	  else cout <<a/11*2+1<<'\n';
      }
  }
  return (0);
}


Measured memory_bytes: 256
# C - Guess The Number
N,M = map(int,input().split())
ans = [0]*(N+1)
if N>1:
    ans[1] = 1
check = [0]*(N+1)
for _ in range(M):
    s,c = map(int,input().split())
    if N>1 and s==1 and c==0:
        ans = -1
        break
    elif check[s]==0:
        ans[s] = c
        check[s] = 1
    elif ans[s]!=c:
        ans = -1
        break
if ans!=-1:
    ans = ''.join([str(x) for x in ans[1:]])
print(int(ans))

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, v, m, x, y, q, k, W;
string s, t, s0, s1, s2;

vll w[4];

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> W;
	cin >> x >> v;
	ll w1 = x;
	w[0].pb(v);

	for (ll i = 1; i < n; i++) {
		cin >> x >> v;
		w[x - w1].pb(v);
	}

	for (ll i = 0; i < 4; i++) {
		sort(all(w[i]));
		reverse(all(w[i]));
		w[i].insert(w[i].begin(), 0);

		for (ll j = 1; j < w[i].size(); j++) w[i][j] += w[i][j - 1];
	}

	ll maxi = 0;

	for (ll a = 0; a < w[0].size(); a++) {
		for (ll b = 0; b < w[1].size(); b++) {
			for (ll c = 0; c < w[2].size(); c++) {
				for (ll d = 0; d < w[3].size(); d++) {
					if (a * (w1) + b * (w1 + 1) + c * (w1 + 2) + d * (w1 + 3) > W) break;
					maxi = max(maxi, w[0][a] + w[1][b] + w[2][c] + w[3][d]);
				}
			}
		}
	}
	cout << maxi;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3660
fn main() {
    let stdin = std::io::stdin();
    let s = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()))
            .by_ref()
            .map(|r|r.unwrap() as char)
            .skip_while(|c|c.is_whitespace())
            .take_while(|c|!c.is_whitespace())
            .collect::<Vec<_>>();
    let mut switch = 0;
    let mut prev = s[0];
    for byte in s {
        if byte != prev {
            switch += 1;
            prev = byte;
        }
    }
    println!("{}", switch);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
using namespace std;
int main(){
	int t,n,k,y,x,sum;
	cin>>t;
	while(t--){
		vector<int> in,box;
		sum=0;
		cin>>n>>k;
		for(int i=0;i<n;i++){
			cin>>x;
			box.push_back(x);
		}
		if(n<=k)
		cout<<0<<endl;
		else{
			for(int i=0;i<n-1;i++){
				in.push_back(box[i+1]-box[i]);
				sum+=in[i];
				
			}
			sort(in.begin(),in.end(),greater<int>());
			for(int i=0;i<k-1;i++){
			sum-=in[i];
			}
			cout<<sum<<endl;
		}
	}
	return 0;
}

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

using namespace std;

const int seed = chrono::steady_clock::now().time_since_epoch().count();
mt19937 generator(seed);

int rnd() {
    return generator() >> 1;
}

int rnd(int r) {
    return rnd() % r;
}

int rnd(int l, int r) {
    return l + rnd(r - l + 1);
}

const int max_n = 3000111, inf = 1000111222;

int n, a[max_n], ans[max_n];
char s[max_n];

void proc() {
    for (int i = 0; i + 1 < n; ++i) {
        a[i] = abs(a[i] - a[i + 1]);
    }
    --n;
}

void solve(int num) {
    if (num == 0) {
        ans[0] = 1;
        return;
    }
    int pw = 1;
    while (num >= pw) {
        pw *= 2;
    }
    solve(num - pw / 2);
    for (int i = pw / 2; i < pw; ++i) {
        ans[i] = ans[i - pw / 2];
    }

}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    if (0) {
        n = rnd(1, 10);
        //n = 1000000;
        for (int i = 0; i < n; ++i) {
            a[i] = rnd(1, 3);
            cout << a[i];
        }
        cout << endl;
    } else {
        scanf("%d%s", &n, s);
        for (int i = 0; i < n; ++i) {
            a[i] = s[i] - '0';
        }
    }
    proc();
    if (n == 1) {
        printf("%d\n", a[0]);
        return 0;
    }
    int c2 = 0, c0 = 0;
    for (int i = 0; i < n; ++i) {
        c0 += a[i] == 0;
        c2 += a[i] == 2;
    }
    int coef = 1;
    if (c0 + c2 == n) {
        coef = 2;
        for (int i = 0; i < n; ++i) {
            a[i] /= 2;
        }
    } else {
        for (int i = 0; i < n; ++i) {
            a[i] %= 2;
        }
    }
    solve(n - 1);
    int res = 0;
    for (int i = 0; i < n; ++i) {
        if (ans[i]) {
            res ^= a[i];
        }
    }
    printf("%d\n", res * coef);
    if (0) {
        while (n > 1) {
            proc();
        }
        printf("%d\n", a[0]);
    }
    return 0;
}


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

const int N = 100;

char s[N+5];

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

    int res = 0;
    for (int i=0; s[i]; i++) {
        res += (s[i] != s[n-1-i]);
    }

    printf("%d\n", res / 2);
    return 0;
}


Measured memory_bytes: 256
n = int(input())

t = list(map(int, input().split()))

m = int(input())

for i in range(m):
    ans = t
    p, x = map(int, input().split())
    tar = ans[p-1]
    ans[p-1] = x
    print(sum(ans))
    ans[p-1] = tar


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	static Scanner sc = new Scanner(System.in);
	private static final int GROUP = 8; //1???????????°
	public static int numb = 0;

	public static void main(String[] args) {
		Map<Double, Integer> runnerList1 = new TreeMap<Double, Integer>();
		Map<Double, Integer> runnerList2 = new TreeMap<Double, Integer>();
		Map<Double, Integer> runnerList3 = new TreeMap<Double, Integer>();

		for(int $ = 0; $ < GROUP * 3; $++) {
			//??\???????????????
			int num = sc.nextInt();
			double time = sc.nextDouble();

			if($ < GROUP) {
				runnerList1.put(time, num);
			} else if($ < GROUP * 2) {
				runnerList2.put(time, num);
			} else {
				runnerList3.put(time, num);
			}
		}

		//????????¨???
		double[] ans = new double[3];
		ans = choice(ans, runnerList1);
		ans = choice(ans, runnerList2);
		ans = choice(ans, runnerList3);

		Arrays.sort(ans);
		for(int $ = 0; $ < 2; $++) {
			int number = 0;
			if(runnerList1.containsKey(ans[$])) {
				number = runnerList1.get(ans[$]);
			} else if(runnerList2.containsKey(ans[$])) {
				number = runnerList2.get(ans[$]);
			} else {
				number = runnerList3.get(ans[$]);
			}
			System.out.println(number + " " + ans[$]);
		}

	}

	public static double[] choice(double[] array, Map<Double, Integer> list) {
		int count = 0;
		for(Double doub : list.keySet()) {
			if(count == 2) {
				array[numb++] = doub;
			} else if(count >= 3) {
				break;
			} else {
				System.out.println(list.get(doub) + " " + doub);
			}
			count++;
		}
		return array;
	}

}

Measured memory_bytes: 28212
#include <stdio.h>
#define swap(x, y) {int z; z=y; y=x; x=z;}
int main ()
{
	int a, b, c, div=0;	
	scanf("%d %d %d", &a, &b, &c);
	for(int i = a; i <= b; i++)
	{
	
		if(c % i == 0)
		{
			div++;
		}
	
	}
		printf("%d\n", div);
	
	
	return 0; 
} 


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

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    int ans = INT_MAX;
    for (int i = 0; i + m - 1 < n; i++) {
        int cnt = 0;
        for (int j = 0; j < m; j++) {
            if (s[i + j] != t[j]) 
                cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3608
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();

		// 計算
		String result = "NO";
		int len = s.length();
		while(len >= 0){
		    if(len == 0){
		        result = "YES";
		        break;
		    }
    	    if(len >= 5 && "dream".equals(s.substring(len - 5, len))){len -= 5; continue;}
    	    if(len >= 5 && "erase".equals(s.substring(len - 5, len))){len -= 5; continue;}
    	    if(len >= 6 && "eraser".equals(s.substring(len - 6, len))){len -= 6; continue;}
    	    if(len >= 7 && "dreamer".equals(s.substring(len - 7, len))){len -= 7; continue;}
    	    len = -1;
		}
		
		// 出力
		System.out.println(result);
        
	}
}


Measured memory_bytes: 28128
#include <stdio.h>
#define LENGTH 256
#define NUM 5

int main(void) {
    char input[LENGTH];
    int n;
    fgets(input, LENGTH-1, stdin);
    sscanf(input, "%d", &n);
    int m = n % 1000;
    if (m == 0) {
        printf("0");
    }else{
        //int result = 1000 - m;
        printf("%d",1000-m);
    }
    //printf("%d",n);
    
    return 0;
}


Measured memory_bytes: 1772
def candies(k, a):
    mod = 10 ** 9 + 7
    cur = [0] * (k + 1)
    cur[0] = 1
    prefix = cur[:]
    nxt = cur[:]
    for x in a:
        for i in range(1, k + 1):
            prefix[i] = (prefix[i - 1] + cur[i]) % mod
        for i in range(1, k + 1):
            # nxt[i] = sum(cur[(i - x if i - x >= 0 else 0):i + 1]) % mod
            nxt[i] = (prefix[i] - (prefix[i - x - 1] if i - x - 1 >= 0 else 0)) % mod
        cur, nxt = nxt, cur
    return cur[k]


def main():
    n, k = [int(x) for x in input().split()]
    a = [int(x) for x in input().split()]
    return candies(k, a)


print(main())


Measured memory_bytes: 41328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	ll ans = LINF;
	vl v(n);
	rep(i, n) {
		cin >> v[i];
	}
	sort(all(v));
	rep(i, n - k + 1) {
		ans =min(ans,v[i+k-1]-v[i]);
	}cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <list>

int main() {
    const char* s = "CODEFESTIVAL2016";

    std::string str;

    std::cin >> str;

    int cnt = 0;
    for(int i = 0; i < str.size(); ++i) {
        if(str[i] != s[i]) {
            ++cnt;
        }
    }

    std::cout << cnt << std::endl;
}

Measured memory_bytes: 764
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn
int main()
{
	IO;
	string s,ss;
	cin>>s>>ss;
	s=s+ss;
	int x=stoi(s),f{};
	for(int i=0;i*i<=x;i++)if(i*i==x){f=1;break;}
	(f)?cout<<"Yes\n":cout<<"No\n";
	//system("pause");
	return 0;
}

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

using namespace std;
typedef long long ll;
#define SIZE 64

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

	vector<int> bit_cnt(SIZE, 0);

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

		bitset<SIZE> bits(val);

		for (int j = 0; j < SIZE; j++) {
			if (bits[j]) bit_cnt[j]++;
		}
	}

	ll cur_val = 0;
	ll cur_num = 0;
	for (int i = 41; i >= 0; i--) {
		ll add = pow((ll)2, (ll)i);

		if (cur_num + add > k) {
			cur_val += bit_cnt[i] * add;
			continue;
		}
		
		if (bit_cnt[i] > n / 2) {
			cur_val += bit_cnt[i] * add;
		}
		else {
			cur_num += add;
			cur_val += (n - bit_cnt[i]) * add;
		}
	}

	cout << cur_val;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        
        String result = "";
        if ("AT".contains(s)) {
            result = "AT".replace(s, "");
        } else if ("CG".contains(s)) {
            result = "CG".replace(s, "");
        } 
        
        System.out.println(result);
    }
}


Measured memory_bytes: 35684
#include<bits/stdc++.h>
using namespace std;
struct node{
	int r,next,v;}side[1000000];
int sidetot,f[2000000],now[2000000];
bool boo[2000000];
void add(int i,int j,int v){
	sidetot++;
	side[sidetot].r=j;
	side[sidetot].next=now[i];
	side[sidetot].v=v;
	now[i]=sidetot;
}
void dfs(int i){
	boo[i]=1;
	for (int p=now[i];(p);p=side[p].next)
	if (!boo[side[p].r])
	{
		f[side[p].r]=f[i]+side[p].v;
		dfs(side[p].r);
	}
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		add(x,y,z);
		add(y,x,-z);
	}
	for (int i=1;i<=n;i++)
	if (!boo[i])
		{
			f[i]=0;
				dfs(i);
	}
	for (int i=1;i<=n;i++)
	{
		for (int p=now[i];(p);p=side[p].next)
		{
			if ((f[side[p].r]-f[i])!=side[p].v)
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 12672
s = input()
t = input()
minDiff = 1001

for i in range(len(s) - len(t) + 1):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            cnt += 1
    if cnt < minDiff:
        minDiff = cnt
print(minDiff)

Measured memory_bytes: 67656
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		int ans = 0;

		ans = A - B * 2;

		if(ans > 0){
			System.out.println(ans);
		}
		else{
			System.out.println(0);
		}

		stdIn.close();
	}
}


Measured memory_bytes: 35580
#include <bits/stdc++.h>
using namespace std;
int main(){
	string str[104];
    int y,z;
    cin>>y>>z;
    for(int i=0;i<y;i++){
        cin>>str[i];
    }
    sort(str,str+y);
    for(int i=0;i<y;i++){
        cout<<str[i];
    }
    cout<<endl;
}


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

int main() {
	int a = 0;
        int b = 0;
        int c = 0;

	cin >> a >> b >> c;

	if (a <= b&&b <= c&&a <= c) {
		cout << a << " " << b << " " << c << endl;
	}
	else if (a <= b && b >= c && a <= c) {
		cout << a << " " << c << " " << b << endl;
	}
	else if (a >= b && b <= c && a <= c) {
		cout << b << " " << a << " " << c << endl;
	}
	else if (a >= b && b <= c && a >= c) {
		cout << b << " " << c << " " << a << endl;
	}
	else if (a >= b && b >= c && a >= c) {
		cout << c << " " << b << " " << a << endl;
	}
	else if (a <= b && b >= c && a >= c) {
		cout << c << " " << a << " " << b << endl;
	}
	return 0;

}


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

int main()
{

        int X, A, B;
        cin >> X >> A >> B;
        if (A >= B) {
                cout << "delicious" << endl;
        }
        else if ((B-A) <= X) {
                cout << "safe" << endl;
        }
        else {
                cout << "dangerous" << endl;
        }


}


Measured memory_bytes: 256