akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static int[] min = new int[11];
	static int[] max = new int[11];
	static String[] name = new String[11];

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		initialize();

		while ((line = br.readLine()) != null) {
			float weight = Float.parseFloat(line);
			System.out.println(classfy(weight));
		}
	}

	static String classfy(float weight) {
		weight = (int) Math.ceil(weight);
		for (int i = 0; i < 11; i++) {
			if (weight > min[i] && weight <= max[i])
				return name[i];
		}
		return null;
	}

	static void initialize() {
		//
		min[0] = Integer.MIN_VALUE;
		min[1] = 48;
		min[2] = 51;
		min[3] = 54;
		min[4] = 57;
		min[5] = 60;
		min[6] = 64;
		min[7] = 69;
		min[8] = 75;
		min[9] = 81;
		min[10] = 91;
		//
		max[0] = min[1];
		max[1] = min[2];
		max[2] = min[3];
		max[3] = min[4];
		max[4] = min[5];
		max[5] = min[6];
		max[6] = min[7];
		max[7] = min[8];
		max[8] = min[9];
		max[9] = min[10];
		max[10] = Integer.MAX_VALUE;
		//
		name[0] = "light fly";
		name[1] = "fly";
		name[2] = "bantam";
		name[3] = "feather";
		name[4] = "light";
		name[5] = "light welter";
		name[6] = "welter";
		name[7] = "light middle";
		name[8] = "middle";
		name[9] = "light heavy";
		name[10] = "heavy";
	}

}

Measured memory_bytes: 16916
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep (i, n) cin >> a[i];

  int best = 0;
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] >= a[i + 1]) best++;
    else best = 0;
    ans = max(ans, best);
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3748
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;


namespace tes
{
	class contest
	{
		static void Main(string[] args)
		{
			
            string s = Console.ReadLine();
            string com = "CODEFESTIVAL2016";

            int ans = 0;
            for(int i=0; i<s.Length; i++)
            {
                if (s[i] != com[i]) ans++;
            }
            Console.WriteLine(ans);
            
            
		}	
		
	}
}

Measured memory_bytes: 2776
#include <cstdio>
#include <string>
#include <set>
#include <iostream>
#include <cstring>
using namespace std;

int n;
set<string> data[51];
bool flag[51];
bool used[51];

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		memset(flag,true,sizeof(flag));
		memset(used,false,sizeof(used));
		for(int i=0;i<=50;i++){
			data[i].clear();
		}
		for(int i=0;i<n;i++){
			string s;
			cin >> s;
			string c="";
			for(int j=0;j<s.size();j++){
				c+=s[j];
				while(j<s.size() && s[j]!='a' && s[j]!='i' && s[j]!='u' && s[j]!='e' && s[j]!='o')j++;
				used[c.size()]=true;
				if(data[c.size()].find(c)!=data[c.size()].end())flag[c.size()]=false;
				data[c.size()].insert(c);
			}
			for(int k=c.size()+1;k<=50;k++){
				used[k]=true;
				if(data[k].find(c)!=data[k].end())flag[k]=false;
				data[k].insert(c);
			}
		}
		int res=-1;
		for(int i=50;i>=0;i--){
			if(flag[i] && used[i])res=i;
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 3480
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        t: usize,
        v: [usize; n]
    }
    let mut ans = 0;
    let mut bmax = 0;
    let mut vmin = v[0];
    let mut nmin = 1;
    let mut vmax = v[0];
    let mut nmax = 0;
    for i in 1..n {
        if v[i] < vmin {
            if bmax < vmax - vmin {
                bmax = vmax - vmin;
                ans = min(nmin, nmax);
            } else if bmax == vmax - vmin {
                ans += min(nmin, nmax);
            }
            vmin = v[i];
            nmin = 1;
            vmax = v[i];
            nmax = 0;
        } else {
            if v[i] > vmax {
                vmax = v[i];
                nmax = 1;
            } else if v[i] == vmax {
                nmax += 1;
            }
        }
    }
    if bmax < vmax - vmin {
        ans = min(nmin, nmax);
    } else if bmax == vmax - vmin {
        ans += min(nmin, nmax);
    }
    println!("{}", ans);
}


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

int main(){
 string s;
 cin>>s;
 int n=s.length();
 int cnt=0;
 for(int i=0;i<n/2;i++){
   if(s[i]!=s[n-1-i]){
     cnt++;
   }
 }
 cout<<cnt<<endl;
}

Measured memory_bytes: 3588
#include<cstdio>
using namespace std;
#define INF (1<<29)

int N, M, R;
int d[201][201];
int r[9];
int A, B, C;
int res;
bool used[9];

void dfs(int c, int las, int dist) 
{
    if(c == R + 1)
    {
        if(res > dist) res = dist;
        return;
    }
    for(int i = 1; i <= R; ++i) if(!used[i])
    {
        used[i] = true;
        if(las == -1) dfs(c + 1, i, 0);
        else dfs(c + 1, i, dist + d[r[las]][r[i]]);
        used[i] = false;
    }
}

void warshall_floyd() {
    for(int k = 1; k <= N; ++k) 
        for(int i = 1; i <= N; ++i) 
            for(int j = 1; j <= N; ++j) 
                if(d[i][j] > d[i][k] + d[k][j])
                    d[i][j] = d[i][k] + d[k][j];
}

int main()
{
    scanf("%d %d %d", &N, &M, &R);
    for(int i = 1; i <= N; ++i) for(int j = 1; j <= N; ++j) if(i != j) d[i][j] = INF;
    for(int i = 1; i <= R; ++i) scanf("%d", &r[i]);
    for(int i = 1; i <= M; ++i) {
        scanf("%d %d %d", &A, &B, &C);
        if(d[A][B] > C) d[A][B] = d[B][A] = C;
    }
    warshall_floyd();
    res = INF;
    dfs(1, -1, 0);
    printf("%d\n", res);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
const bool debug = 0;
//----------------------//

int n;
map<int, int> cnt;

int main() {
	cin >> n;
	REP(i, n) {
		int a;
		scanf("%d", &a);
		cnt[a]++;
	}
	
	vector<pii> v;
	for (map<int, int>::iterator it = cnt.begin(); it != cnt.end(); ++it) {
		if (it->se >= 2) v.push_back(pii(it->fi, it->se));
	}
	
	sort(ALL(v), greater<pii>());
	
	
	if (v.size() < 1) puts("0");
	else if (v[0].se >= 4) cout << (ll)v[0].fi * v[0].fi << endl;
	else cout << (ll)v[0].fi * v[1].fi << endl;
	
	return 0;
}


Measured memory_bytes: 4992
N, M = map(int, raw_input().split())

number_dict = {}

for i, m in enumerate(range(M)):
    P, Y = map(int, raw_input().split())

    if P in number_dict:
        number_dict[P].append([i+1, Y])
    else:
        number_dict[P] = [[i+1, Y]]

L = list(number_dict.items())

result = []

for l in L:
    prefix = '%06d' % l[0]
    l[1].sort(key=lambda x: x[1])
    for i, city in enumerate(l[1]):
        number = '%06d' % (i+1)
        order = city[0]
        result.append([order, prefix+number])

result.sort(key=lambda x: x[0])
for r in result:
    print r[1]


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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    ll N; cin >> N;
    VL k(13,1); REP(i,12) k[i+1] = k[i]*26;
    REP(i,11) k[i+2] += k[i+1];
    k[0] = 0;
    int t = 1;
    while(k[t] < N) t++;
    N -= k[t-1];

    N--;
    string ans(t,'a');
    REP(i,t){
        ans[i] += N%26;
        N /= 26;
    }
    REVERSE(ans);
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3624
/*input
10
3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

const int N = 3e5 + 5;
int psum[N][61];

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int a, b, c;
  cin >> a >> b >> c;
  int ans = a + b + c;
  cout << (ans >= 22 ? "bust" : "win") << endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll mod = 998244353;
const int MAX = 510000;

int main() {
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  vector<int> l(Q), r(Q);
  for (int i=0; i<Q; i++) cin >> l[i] >> r[i];
  vector<int> t(N+1, 0); // 累積和
  for (int i=0; i<N; i++) {
    if (i+1<N&&S[i]=='A'&&S[i+1]=='C') t[i+1] = t[i]+1;
    else t[i+1] = t[i];
  }
  // クエリ
  for (int i=0; i<Q; i++) {
    l[i]--;
    r[i]--;
    // 0-indexedにする
    cout << t[r[i]]-t[l[i]] << endl;
  }
}

Measured memory_bytes: 2176
import java.util.*;

class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 111;
        for(int i=1;i<=9;i++){
            if(n<=i*111){
                ans = i*111;
                break;
            }
        }

        System.out.println(ans);
    }
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N, L;
    cin >> N >> L;
    int m = INF;
    int s = 0;
    for(int i = 1; i <= N; ++i) {
        if(abs(m) > abs(L + i - 1)) {
            m = L + i - 1;
        }
        s += L + i - 1;
    }
    cout << s - m << endl;
    return 0;
}



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

int n;
double ans1, ans2;

int main(){
	cin >> n;
	vector<double>v(n);
	for (int i=0;i<n;i++) cin >> v[i];
	sort(v.begin(),v.end());
	ans1=v[0];
	for (int i=1;i<n;i++) ans1=(ans1+v[i])/2;
	sort(v.rbegin(),v.rend());
	ans2=v[0];
	for (int i=1;i<n;i++) ans2=(ans2+v[i])/2;
	cout << max(ans1,ans2) << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
using namespace std;
int par[104];
int ran[105];
void init(int n) {
	for (int i = 0; i<n; i++) {
		par[i] = i;
		ran[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (ran[x]<ran[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
struct edge { int s, t, cost; };
bool comp(const edge& e1,const edge& e2) {
	return e1.cost < e2.cost;
}
int main()
{
	int n, m;
	while (cin >> n >> m, n != 0) {
		init(n);
		edge b[10008];
		int x, y, z;
		for (int i = 0; i < m; i++) {
			cin >> x >> y >> z;
			b[i].s = x;
			b[i].t = y;
			b[i].cost = z;
		}
		int ans = 0;
		sort(b, b + m, comp);
		for (int i = 0; i < m; i++) {
			edge now = b[i];
			if (!same(now.s, now.t)) {
				unite(now.s, now.t);
				ans += now.cost;
			}
		}cout << ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1188
from itertools import combinations

data1 = input()
data2 = [int(i) for i in input().split(" ")]

count = 0
if len(data2) >= 3:
  for d1, d2, d3 in combinations(data2, 3):
    if d1 == d2 or d2 == d3 or d1 == d3:
      continue
    if d1 + d2 <= d3 or d1 + d3 <= d2 or d2 + d3 <= d1:
      continue
    count += 1

  print(count)
else:
  print(0)

Measured memory_bytes: 9132
import java.util.*;

public class Main {
    private static final Scanner sc = new Scanner(System.in);

    private void run() {
        int N = sc.nextInt();
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
        }

        long ans = 0;
        Map<Long, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            long t = i - A[i];
            ans += map.getOrDefault(t, 0);

            long k = A[i] + i;
            map.put(k, map.getOrDefault(k, 0) + 1);
        }
        System.out.println(ans);
    }

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


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int f[26],ans=1,n;
string s;
void solve(){
    cin>>n;
    cin>>s;
    for(auto i:s) f[i-'a']++;
    rep(i,0,26) ans=ans*(f[i]+1)%hell;
    cout<<(ans-1+hell)%hell<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 512
N = int(input())
data = list(map(int,input().split()))
sw1 = 0
sw2 = 0
for i in range(0,len(data)):
    if data[i] % 2 == 0:
        sw1 += 1
        if data[i] % 3 == 0 or data[i] % 5 == 0:
            sw2 += 1

if sw1 >= 0 and sw1 == sw2:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 9124
n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

# print(r_cnt, g_cnt, b_cnt)
ans = r_cnt * g_cnt * b_cnt
# print(ans)

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        # print(i,j,k)
        if k >= n: 
            # print('/')
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1

print(ans)

Measured memory_bytes: 9152
from collections import deque
from itertools import chain


class Solver:
    def __init__(self, m):
        self.m = m
        self.label = [[-1 for _ in range(len(m[0]))] for _ in range(len(m))]

    def bfs(self, s, g):
        queue = deque()
        start = [a - 1 for a in s]
        goal = [a - 1 for a in g]
        queue.append(start)
        self.label[start[0]][start[1]] = 0
        while len(queue) > 0:
            node = queue.popleft()
            y, x = node
            dist = self.label[y][x] + 1
            if y > 0:
                if self.m[y - 1][x] != "#" and self.label[y - 1][x] == -1:
                    if y-1 == goal[0] and x == goal[1]:
                        return dist
                    else:
                        queue.append([y - 1, x])
                        self.label[y - 1][x] = dist
            if y < len(self.m)-1:
                if self.m[y + 1][x] != "#" and self.label[y + 1][x] == -1:
                    if y+1 == goal[0] and x == goal[1]:
                        return dist
                    else:
                        queue.append([y + 1, x])
                        self.label[y + 1][x] = dist
            if x > 0:
                if self.m[y][x - 1] != "#" and self.label[y][x - 1] == -1:
                    if y == goal[0] and x-1 == goal[1]:
                        return dist
                    else:
                        queue.append([y, x-1])
                        self.label[y][x-1] = dist
            if x < len(self.m[0])-1:
                if self.m[y][x + 1] != "#" and self.label[y][x + 1] == -1:
                    if y == goal[0] and x+1 == goal[1]:
                        return dist
                    else:
                        queue.append([y, x+1])
                        self.label[y][x + 1] = dist
        return -1


def main():
    H, W = list(map(int, input().split()))
    m = [list(input()) for _ in range(H)]
    sum = list(chain.from_iterable(m)).count(".")

    solver = Solver(m)
    ans = solver.bfs([1, 1], [H, W])
    if ans == -1:
      print(-1)
      quit()
    print(sum - ans -1)


if __name__ == "__main__":
    main()


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

int main(){
  int n,w[300],maxx[301][301],dp[301][301];
  cin>>n;
  while(n!=0){
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++){
        dp[i][j]=0;
        maxx[i][j]=0;
      }
    for(int i=0;i<n;i++)
      cin>>w[i];
    for(int i=0;i<n-1;i++)
      if(w[i]-w[i+1]>=-1&&w[i]-w[i+1]<=1)
        dp[i][i+1]=1;
    for(int k=2;k<=n;k++)
      for(int i=0;i+k<n;i++){
        if(dp[i+1][i+k-1]==1&&w[i]-w[i+k]>=-1&&w[i]-w[i+k]<=1)
          dp[i][i+k]=1;
        else
          for(int j=i+1;j<i+k-1;j++)
            if(dp[i][j]==1&&dp[j+1][i+k]==1){
              dp[i][i+k]=1;
              break;
            }
        
      }
    
    for(int k=1;k<n;k++)
      for(int i=0;i+k<n;i++){
        if(dp[i][i+k]==1)
          maxx[i][i+k]=k+1;
        else
          for(int j=i;j<i+k;j++)
            if(maxx[i][i+k]<maxx[i][j]+maxx[j+1][i+k])
              maxx[i][i+k]=maxx[i][j]+maxx[j+1][i+k];
      }
    cout << maxx[0][n-1]<<endl;
    cin>>n;
  }
}


Measured memory_bytes: 3724
#include<stdio.h>
#define MAX 1000000
int prime_count[MAX];
main(){
	int n=0,i,j;
	
	for(i=2;i<MAX;++i){
		if(prime_count[i]!=-1){
			for(j=i*2;j<MAX;j+=i){
				prime_count[j]=-1;
			}
			prime_count[i]=++n;
		}else{
			prime_count[i]=n;
		}
	}
	while(~scanf("%d",&n)){
		printf("%d\n",prime_count[n]);
	}
	return 0;
}

Measured memory_bytes: 4500
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n; cin >> n;
	for (int cnt2 = 0; cnt2 <= n / 7; cnt2++)
	{
		if ((n - 7 * cnt2) % 4 == 0)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

n,*a = [int(i) for i in read().split()]

from itertools import accumulate
if n%2==0:
    a1 = list(accumulate([0]+a[::2]))
    a2 = list(accumulate([0]+a[n-1::-2]))[::-1]
    #print(a1,a2)
    print(max(x+y for x,y in zip(a1,a2)))
#elif n==3: print(max(a))
else:
    dp0 = [0]*(n+9)
    dp1 = [0]*(n+9)
    dp2 = [0]*(n+9)
    for i in range(n):
        if i%2==0:
            dp0[i] = dp0[i-2]+a[i]
            if i >= 2:
                dp2[i] = max(dp2[i-2],dp1[i-3],dp0[i-4]) + a[i]
        else:
            dp1[i] = max(dp1[i-2],dp0[i-3]) + a[i]
    #print(dp0)
    #print(dp1)
    #print(dp2)
    print(max(dp2[n-1],dp1[n-2],dp0[n-3]))





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

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

int main() {
	int n;
	cin >> n;
	long long ans = 0;
	cin >> ans;
	for (int i = 0; i < n-1; i++) {
		long long geko;
		cin >> geko;
		ans = gcd(ans, geko);
	}
	cout << ans << endl;
	return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const unsigned long MAX =   1e18;
signed main()
{   
  gearup;
  int n; cin >> n;
  vl a(n);
  rep(i,n){
    cin >> a[i];
    if(a[i] == 0){
      out(0);
      return 0;
    }
  }
  ll now = a[0];
  ll ma = a[0];
  rep1(i,n){
    now *= a[i];
    ma = max(now,ma);
    if(ma > now || now > MAX){
      out(-1);
      return 0;
    }
  }
  out(now);
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int w=0;
  rep(i,101){
    if(a<=i&&i<b&&c<=i&&d>i)w++;
  }
  cout << w;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    vector<vector<int>> pat(8, vector<int>(8, 1));
    for(int i=0; i<8; i+=2){
        for(int j=1; j<8; j+=2){
            pat[i][j]=0;
        }
    }

    int q; cin>>q;
    while(q--){
        int a, b, c, d; cin>>a>>b>>c>>d;
        a--, b--, c--, d--;
        int ans=0;
        for(int i=a; i<=c; i++){
            for(int j=b; j<=d; j++){
                ans+=pat[i][j];
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = Integer.MAX_VALUE;
		int a, cnt = 0;
		for (int i = 0; i < n; i++) {
			a = sc.nextInt();
			cnt = 0;
			while (a % 2 == 0) {
				a = a / 2;
				cnt++;
			}
			max = Math.min(max, cnt);
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 21716
k, x = gets.chomp.split(" ").map(&:to_i)
if k == 1
  p x
else
  ary = []
  k.times do |m|
    k.times do |n|
      ary.push((x-m)+n)
    end
  end
  
  ary = ary.uniq.sort
  print "#{ary[0]}"
  (1..ary.size-1).each do |i|
    print " #{ary[i]}"
  end  
end

Measured memory_bytes: 1916
import java.util.Scanner;

public class Main {
	
	public static void main( String[]args ){
		
		Scanner sc = new Scanner( System.in );
		
		int n = sc.nextInt();
		int l = sc.nextInt();
		
		int[] number = new int[ n ];
		 
		int p_number = 0;//ロープのほどく可能ナンバー
		boolean l_flag = false; // ここがfalseだったらほどけないということ
		for( int i = 0;i < n;i++ ){
			
			number[i] = sc.nextInt();
			if( i == 0 && !l_flag ){
				if( number[i] == l ){
					l_flag = true;
					p_number = i;
				}
			}else if( !l_flag ){
				
				if( l > (number[i - 1] + number[i]) )
					l_flag = false;
				else{
					l_flag = true;
					p_number = i;
				}
			}
		}
		
		if( l_flag ){
			System.out.println("Possible");
			
				for( int i = n - 1;i > p_number;i-- )
					System.out.println(i);
				for( int i = 1;i <= p_number;i++ )
					System.out.println(i);
		
		}else{
			System.out.println("Impossible");
		}
		
	}

}

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

int main(){
    int x, n, ans; cin >> x >> n;
    set<int> p;
    rep(i, n){int tmp; cin >> tmp; p.insert(tmp);}
    int start = x;
    int i = start - 1; int j = start + 1;
    while (true){
        if (p.count(x) == 0){ans = x;break;}
        if (p.count(i) == 0){ans = i; break;}
        if (p.count(j) == 0){ans = j; break;}
        i --; j++;
    }
    cout << ans << endl;
}   


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <set>
using namespace std;

int main(){
    int n, cnt = 0;
    cin >> n;
    int A[100010];
    for (int i = 0; i <= 100000; i++) {
        A[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if(a>100000){
            cnt++;
            continue;
        }
        if(A[a] < a)A[a]++;
        else cnt++;
    }
    for (int i = 0; i <= 100000; i++) {
        if(A[i]<i) cnt += A[i];
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
def total_power(n, a):
    half_total = []
    start = 0
    end = len(a)
    if n%2 == 0:
        start = 0
    else:
        start = 1 
        half_total.append(a[0])

    for i in range(start, end, 2):
        half_total.append(a[i]*a[i+1])
    if len(half_total) == 1:
        return half_total[0]
    else:
        return total_power(len(half_total), half_total)


n = int(input())

a_str = input()
a_strs = a_str.split(' ')
a = [int(s) for s in a_strs]
total = total_power(n, a)

if total <= 1e+18:
    print (total)
else:
    print('-1')

Measured memory_bytes: 150520
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define w(t) int t;cin>>t; while(t--)
using namespace std;

//a5 – b5 = (a – b)(a4 + a3b + a2b2 + ab3 + b4)
set<ll> s;
void fun(){
    for(ll i=1; i<=200; i++){
        s.insert(pow(i,5));
    }
}

int main(){
    fun();
    ll x;
    cin>>x;
    //cout<<pow(100,5);
    for(ll i=1; i<=200; i++){
        ll y = pow(i,5);
        ll p = abs(y-x);
        if(p==0){
            cout<<i<<" "<<0;
            break;
        }
        if(s.find(p) != s.end()){
            if(y  > x){
                //p positive;
                
                cout<<pow(y,1/(1.0*5))<<" "<<pow(p,1/(1.0*5));
            }
            else if(x>y){
                cout<<pow(y,1/(1.0*5))<<" "<<-1*pow(p,1/(1.0*5));
            }
            
            break;
        }
    }
    //cout<<pow(32, 1/(1.0*5));
}

Measured memory_bytes: 4168
#include <iostream>

using namespace std;

int n, k, m;

int calc(int n, int k){
  if(n == 1) return 0;
  return (calc(n-1, k) + k) % n;
}

int solve(int m){
  int s = (m - k + n) % n;
  return (calc(n, k)+s+n)%n+1;
}

main(){
  while(cin >> n >> k >> m && (n|k|m)){
    cout << solve(m) << endl;
  }
}

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

int f(int x) {
    int sum=0;
    while (x>0) {
        sum+=x%10;
        x/=10;
    }
    return sum;
}

int main() {
    int n;
    cin >> n;
    if(n%f(n)==0) {
      cout << "Yes" << endl;
    } 
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int getGosa(int T,int x) {
	int a,b;
	a=T%x;
	b=x-a;
	return a<b?a:b;
}

int main(void) {
	int N,T,E,x;
	int i;
	int minError,minID;
	int nowError;
	scanf("%d%d%d",&N,&T,&E);
	minError=0x7fffffff;
	minID=-1;
	for(i=0;i<N;i++) {
		scanf("%d",&x);
		nowError=getGosa(T,x);
		if(nowError<minError) {
			minError=nowError;
			minID=i;
		}
	}
	printf("%d\n",minError<=E?minID+1:-1);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


const int mod = 1000000007;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(max_n);


int main(){
    ll n;cin >> n;
    string s;cin >> s;
    map<char,ll> mp;
    rep(i,n){
        mp[s[i]]++;
    }
    mint ans=1;
    for(auto p:mp){
        ans*=p.se+1;
    }
    cout << ans-1 <<endl;
} 

Measured memory_bytes: 3584
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r; };

Node T[MAX];
int n, D[MAX];

void print(int u) {
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] <<", ";

    if ( T[u].p == NIL ) cout << "root, ";
    else if ( T[u].l == NIL ) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
        if (i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

int rec(int u, int p) {
    D[u] = p;
    if (T[u].r != NIL) rec(T[u].r, p); 
    if ( T[u].l != NIL ) rec(T[u].l, p + 1);
}

int main() {
    int i, j, d, v, c, l, r;
    cin >> n;
    for (i = 0; i < n; i++ ) T[i].p = T[i].l = T[i].r = NIL;
    for (i = 0; i < n; i++ ) {
        cin >> v >> d;
        for (j = 0; j <d; j++ ) {
            cin >> c;
            if (j == 0 ) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for (i = 0; i <n; i++ ) {
        if (T[i].p == NIL) r = i;
    }

    rec(r, 0);

    for (i = 0; i < n; i++ ) print(i);

    return 0;
}



Measured memory_bytes: 7672
#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>;
const ll INF = ll(1e18)+1;

P f(int i){
  int a = i%10;
  int b = 0;
  while(i){
     b = i;
     i /= 10;
  }
  return P(a,b);
}

int main(){
  int n;
  cin >> n;
  map<P,int> mp;
  for(int i=1;i<=n;i++){
    P p = f(i);
    mp[p]++;
  }

  ll ans = 0;

  for(int i=1;i<=n;i++){
    P p = f(i);
    P q(p.second,p.first);
    ans += mp[q];
  }
  
  cout << ans << endl;


}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int max = a;
        if (max < b)
            max = b;
        if (max < c)
            max = c;
        int min = a;
        if (min > b)
            min = b;
        if (min > c)
            min = c;
        if (max == 7) {
            if (min == 5) {
                if (a + b + c - max - min == 5) {
                    System.out.println("YES");
                } else {
                    System.out.println("NO");
                }
            } else {
                System.out.println("NO");
            }
        } else {
            System.out.println("NO");
        }
    }
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int H,W;
char F[50][50];

signed main(){
    cin>>H>>W;
    rep(i,H)rep(j,W)cin>>F[i][j];

    int ans=1001001001;
    for(int i=1;i+1<H;i++){
        for(int j=i+1;j<H;j++){
            int cost=0;
            for(int k=0;k<i;k++)rep(l,W)cost+=F[k][l]!='W';
            for(int k=i;k<j;k++)rep(l,W)cost+=F[k][l]!='B';
            for(int k=j;k<H;k++)rep(l,W)cost+=F[k][l]!='R';
            chmin(ans,cost);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll n,a[405],dp[405][405],S[405];
main () {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	for (int i=1; i<=n; i++) {
		cin>>a[i];
		S[i]=S[i-1]+a[i];
	}
	for (int len=1; len<n; len++) {
		for (int l=1; l+len<=n; l++) {
			int r=l+len;
			dp[l][r]=1e18;
			for (int k=l+1; k<=r; k++) 
				dp[l][r]=min(dp[l][r],(S[r]-S[k-1])+(S[k-1]-S[l-1])+dp[l][k-1]+dp[k][r]);
		}
	}
	cout<<dp[1][n]<<endl;
}

Measured memory_bytes: 1536
# -*- coding: utf-8 -*-

N, K = map(int, input().split())
S = input()

number_list = []
num = 1

for i in range(N):
    if i == N - 1:
        number_list.append(num)
    else:
        if S[i] == S[i + 1]:
            num += 1
        else:
            number_list.append(num)
            num = 1

#端が0の時は,その端に1が0個あると置けば場合分けを防げる
if S[0] == '0':
    number_list = [0] + number_list
if S[-1] == '0':
    number_list.append(0)

ruiseki = [number_list[0]]
for i in range(1, len(number_list)):
    ruiseki.append(ruiseki[i - 1] + number_list[i])

max_num = 0
for i in range(0, len(ruiseki), 2):
    if i == 0:
        max_num = ruiseki[min(i + K * 2, len(ruiseki) - 1)]
    else:
        buff = ruiseki[min(i + K * 2, len(ruiseki) - 1)] - ruiseki[i - 1]
        if buff > max_num:
            max_num = buff

print (max_num)

Measured memory_bytes: 8436
X, Y = map(int, input().split())
if X > 3 and Y > 3:
    print(0)
elif (X == 3 and Y > 3) or (Y == 3 and X > 3):
    print(100000)
elif (X == 3 and Y == 3) or (X == 2 and Y > 3) or (Y == 2 and X > 3):
    print(200000)
elif X == 1 and Y == 1:
    print(1000000)
elif (X == 1 and Y == 3) or (Y == 1 and X == 3) or (Y == 2 and X == 2):
    print(400000)
elif (X == 2 and Y == 1) or (Y == 2 and X == 1):
    print(500000)
elif (X == 1 and Y > 3) or (Y == 1 and X > 3) or (X == 3 and Y == 2) or (Y == 3 and X == 2):
    print(300000)
else:
    print(400000)


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main()
{
    char c[20];
    int i;
    scanf("%s",c);
    for(i=0; i<strlen(c); i++)
    {
        if(c[i]==',')
        {
            c[i]=' ';
        }
    }
    printf("%s",c);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <sstream>

using namespace std;

string expr(int x, int y) {
    stringstream ss;
    ss << x << "x" << y << "=" << x*y;
    return ss.str();
}

int main() {
    set<string> c;
    int n = 1e5;
    while (n--) {
        int x = rand() % 9 + 1;
        int y = rand() % 9 + 1;
        c.insert(expr(x, y));
    }
    for (set<string>::iterator it=c.begin(); it!=c.end(); ++it) {
        cout << *it << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    if(n<k){
        cout<<min(k-n,n)<<'\n';
    }
    else{
        cout<<min(n%k,k-n%k)<<'\n';
    }
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;
    vint a(n); rep(i,n) cin>>a[i];

    ll tot = 0;
    for(auto e:a) tot = tot^(e);

    for(auto e:a){
        ll ans = tot^e;
        cout<<ans<<" ";
    }
    cout<<endl;


    return 0;

}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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 nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{

    int N; cin >> N;
    set<string> res;

    REP(i,N){
        string s; cin >> s;
        res.insert(s);
    }

    cout << res.size() << endl;

    return 0;
}


Measured memory_bytes: 19156
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
#define int long long
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int N,K; cin>>N>>K;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  sort(A.begin(),A.end());
  int ans=0;
  rep(i,N-K)ans+=A[i];
  cout<<ans<<endl;
}

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

 int Max(int a, int b) {
	if (a > b) {
		return a;
	}
	else {
		return b;
	}
}

int main(){
  char S[11];
  cin >> S;
  int c = 0;
  int max = 0;
  for(int i = 0 ; i <= 10 ; i++){
      if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
        c++;
      }
      else{
          max = Max(c,max);
          c = 0;
      }
  }
  cout << max << endl;
}

Measured memory_bytes: 256